开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜