I want to write an addon which enhances an existing addon (e.g., adding an options dialog). I do not want to modify the original addon's code directly. The original addon I wish is written using XUL.
Does this mean I have to write my addon using XUL as well? Or can I use the newer Addon SDK?
Thanks!
Yes, it is possible to extend other add-ons. There are actually quite a few add-ons that either extend or interact with other add-ons, for example Element Hiding Helper extending Adblock Plus and lots of Firebug add-ons.
How to do it depends on the implementation of actual add-on you're trying to extend. Hence, I can only give you some general pointers/notes:
- You can have XUL overlays to add-on XUL windows/overlays, just like you may have some for
browser.xul
or other core code.
- You can, of course, use the DOM APIs as well to manipulate any third party XUL DOM.
- You can monkey-patch global functions and objects in Javascript and/or replace/wrap most XPCOM components.
- The Add-on SDK cannot use overlays. Hence you have to use
window/utils
or similar means to get to the XUL windows and can use DOM APIs from there.
- There are certain ways to monkey-patch code in Javascript code modules, if you really have to...
- Monkey-patching of SDK modules and/or content-scripts is extremely hard and extremely fragile from what I remember.
- It is always good to ping the author of an add-on for help, feedback or just for a heads-up. Often authors might be even willing to expose their own extension APIs to make their add-ons easier to extend. E.g. I created such APIs in the past and also had other authors create APIs for me.