是否有可能修改一个使用XUL编写的Firefox插件和使用Addon SDK编写的插件 [英] Is it possible to modify a firefox addon written using XUL with an addon written using the Addon SDK

查看:188
本文介绍了是否有可能修改一个使用XUL编写的Firefox插件和使用Addon SDK编写的插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写一个增强现有插件的插件(例如添加一个选项对话框)。我不想直接修改原来的插件代码。原来的插件,我希望是用XUL编写的。
这是否意味着我必须使用XUL编写我的插件?或者我可以使用最新的Addon SDK?



谢谢!

解决方案

是的,可以扩展其他附加组件。实际上有不少附加组件可以扩展或与其他附加组件交互,例如元素隐藏助手扩展Adblock Plus和大量的Firebug附加组件。



如何做到这一点取决于你试图扩展的实际插件的实现。因此,我只能给你一些一般的指针/注释:


  • 你可以用XUL覆盖来加载XUL窗口/覆盖,只是就像你对 browser.xul 或其他核心代码可能有一些。

  • 你当然也可以使用DOM API来操纵任何第三方的XUL DOM。

  • 你可以 monkey-patch Javascript中的全局函数和对象和/或替换/包装大多数XPCOM组件。

  • 附加组件SDK不能使用叠加。因此,您必须使用 window / utils 或类似的方法来到达XUL窗口,并且可以使用DOM API。 是一些在Javascript代码模块中修改代码的方法,如果你真的需要的话...

  • SDK模块和/或内容脚本的猴子修补是非常困难和非常脆弱的从我记忆中。

  • 平衡一个附加组件的作者寻求帮助,反馈或者提醒,总是很好的。通常作者可能甚至愿意公开他们自己的扩展API来使他们的插件更容易扩展。例如。我在过去创建了这样的API,也有其他作者为我创建了API。


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.

这篇关于是否有可能修改一个使用XUL编写的Firefox插件和使用Addon SDK编写的插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆