Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an API to disable/enable a Firefox extension?

Is there an API call allowing one to enable/disable a Firefox add-on?

like image 813
DVK Avatar asked Dec 03 '25 03:12

DVK


2 Answers

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;
    });
}
like image 137
Paul Lammertsma Avatar answered Dec 04 '25 17:12

Paul Lammertsma


You want to use the nsIExtensionManager interface.

like image 45
sdwilsh Avatar answered Dec 04 '25 16:12

sdwilsh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!