开发者

Modify contents of Firefox download dialog from add-on kit

开发者 https://www.devze.com 2023-04-11 03:31 出处:网络
I\'d like 开发者_开发问答to be able to add an option to the download dialog that pops-up in Firefox when starting a file download. Is it possible to do so using the new add-on SDK or do I have to do i

I'd like 开发者_开发问答to be able to add an option to the download dialog that pops-up in Firefox when starting a file download. Is it possible to do so using the new add-on SDK or do I have to do it the old way?

edit: Obviously, if the new option is selected, I need a way to know it and execute code based on it.


That's something you would use XUL overlays for. I guess that the dialog you are talking about is chrome://mozapps/content/downloads/downloads.xul - the download manager. AFAIK doing this isn't possible with the Add-on SDK, it only provides the most common UI integration points. You could create a traditional extension however, it can overlay any dialog.


There is no existing module that will help you that I know of, so you would have to create one, or wait for one to be made by someone else. But the main idea to extending browser UI is simple, and goes like this:

  1. When the addon is loaded, scan for open windows of the type that you wish to extend.
  2. extend the open windows by adding xul elements and javascript to the page.
  3. listen for newly opened windows, and test that they are the type that you are looking for once they open
  4. extend newly opened windows while your addon is active
  5. Clean up after yourself when windows close or when your addon is disabled/uninstalled.

The last step is the most important and never matter with old school extensions which were not restartless.

Some for the built-in modules that you can look at that do this are the widget module, the context menu module, and the hotkeys module, all of which you can find here.

I've made a couple myself which are the toolbar button module, the xulkeys module, the menuitems module, and a few others, all of which you can find here.


Recently I wrote an extension do the same things. A bootstrap extension, not using addon-sdk.

I already submit it on AMO, but wait for review

https://addons.mozilla.org/en-US/firefox/addon/download-dialog-tweak/

And the source code

https://github.com/muzuiget/download_dialog_tweak

0

精彩评论

暂无评论...
验证码 换一张
取 消