Is there an API call 开发者_如何学运维allowing one to enable/disable a Firefox add-on?
Starting from Firefox 4, this can be done via AddonManager
.
For instance, to disable an add-on:
AddonManager.getAddonByID(id, function(addon) {
addon.userDisabled = true;
});
To support both Gecko <= 1.9.1 and > 1.9.1:
var man = Components.classes["@mozilla.org/extensions/manager;1"];
if (man) {
man = man.getService(Components.interfaces.nsIExtensionManager);
}
if (man) {
man.disableItem(id);
} else {
Components.utils.import("resource://gre/modules/AddonManager.jsm");
AddonManager.getAddonByID(id, function(addon) {
addon.userDisabled = true;
});
}
You want to use the nsIExtensionManager interface.
精彩评论