开发者

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

开发者 https://www.devze.com 2022-12-16 09:38 出处:网络
Is there an API call 开发者_如何学运维allowing one to enable/disable a Firefox add-on?Starting from Firefox 4, this can be done via AddonManager.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消