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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With