I am writing a Firefox addon for Firefox 4 which allows you to create bootstraped addons (addons that do not require a restart of the browser), however, they do not allow you to use XUL to create UI elements. What is an easy way to create UI elements in places like the tools menu (with JavaScript), and how do I make my addon open a new window to interface with the browser?
It's not easy right now. You need to keep track of browser windows as they open and close and add your UI to each window manually via DOM APIs
See how it's implemented in the Addon (formerly Jetpack) SDK: https://github.com/mozilla/addon-sdk/blob/master/packages/addon-kit/lib/widget.js#L215 (browserManager
, in case the line numbers change).
The Mozilla Add-on SDK which is also known as JetPack has evolved to the point where it can be used to create entire add-ons. Not only are the add-ons fast and simple to create, but they are also restartless.
The best way to add UI elements with the SDK is to use the Widget API which will easily allow you to add an icon to the status bar. There are also other APIs for the context-menu and creating panels.
来源:https://stackoverflow.com/questions/4484719/how-to-add-ui-elements-from-a-bootstraped-firefox-addon