1

I am planning to start writing a Firefox extension in the near future and found out that part of the functionality I would like my extension to have is already done in another extension. Now I am wondering if it is possible to program an extension that uses the functionality of another extension (i.e. that the existing extension would have to be installed before mine). Is there for example the possibility to call another extensions functions?
I am not trying to pass off somebody elses work as my own (hence the dependency on the existing extension), I just think it might not be necessary to program the same functionality twice.

I would assume that other people also had this problem/question, but unfortunately I could not find any answer on Stackoverflow or the internet in general. Apparently it is possible to change an existing extension, but this is not exactly what i want.

I'm happy for any tips or pointers!
Thanks in advance!

4

1 回答 1

0

没有关于实现此目的的可靠方法的文档(在 Firefox < 4 中曾经有一种方法),但您应该能够使用 AddonManager API 在您的附加代码中滚动您自己的依赖项检查:

Components.utils.import("resource://gre/modules/AddonManager.jsm");

AddonManager.getAllAddons(function(aAddons) {
  // Here aAddons is an array of Addon objects
});

更多信息:https ://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/Add-on_Manager#Accessing_installed_add-ons

此外,如果您通过主附加组件站点 ( https://addons.mozilla.org ) 分发您的附加组件,您最多可以列出三个您依赖的附加组件。这不会阻止人们在没有依赖项的情况下安装您的插件,但它应该为您插件的绝大多数潜在用户提供良好的用户体验。

于 2013-07-04T12:38:04.893 回答