Is it possible to modify a firefox addon written using XUL with an addon written using the Addon SDK

梦想与她 提交于 2019-12-11 07:51:50

问题


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!


回答1:


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.


来源:https://stackoverflow.com/questions/18747606/is-it-possible-to-modify-a-firefox-addon-written-using-xul-with-an-addon-written

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!