如何查找Firefox扩展禁用状态

时间:2014-03-30 03:22:27

标签: arrays firefox firefox-addon

有没有办法找到Firefox扩展禁用状态?

我可以使用以下脚本检测扩展安装状态。

var autoform_img = document.createElement("img");

autoform_img.addEventListener("load", function(e){
    console.log( 'installed successfully' );
    btn = "<button onclick='fireKey()' class='btn btn-success pull-right' id='copy'> Copy</button>";
    $('#btn-con').append( btn );

}, false);

autoform_img.addEventListener("error", function(e){
    console.log( 'extension not installed on your machine' );
    btn = "<button onclick='fireKey()' class='btn btn-success pull-right' id='copy'> Install </button>";
    $('#btn-con').append( btn );
}, false);

autoform_img.setAttribute("src", "chrome://autoform/skin/firebug64.png");

3 个答案:

答案 0 :(得分:0)

答案 1 :(得分:0)

这是复制粘贴。将其粘贴到暂存器,将环境设置为浏览器。它会告诉您是否启用了插件AdBlock Plus。我之所以选择这个插件,是因为每个人都安装了它。

//this checks to see if AdBlock Plus is enabled
AddonManager.getAddonsByIDs(["{d10d0bf8-f5b5-c8b4-a8b2-2b9879e08c5d}"], function ([aAddon1]) {
    console.log(aAddon1);
    var isAddonEnabled = aAddon1.isActive;
    alert('AdBlock plus enabled = ' + isAddonEnabled)
    //for other properties see here: https://developer.mozilla.org/en-US/Add-ons/Add-on_Manager/Addon#Required_properties
});

答案 2 :(得分:0)

const { Cu } = require("chrome");
let AddonManager = Cu.import("resource://gre/modules/AddonManager.jsm").AddonManager;
AddonManager.getAddonByID( "jid1-Ek4rsiwaZyfJnw@jetpack123" , function(addons){
     if ( !addons ) {
          addonStatus.push({
            status : 'not installed'
          });
      } else {
           addonStatus.push({
            status : 'installed',
            id: addons.id,
            appDisabled: addons.appDisabled,
           });
      }

    console.log( addonStatus );
});

使用上面的脚本来获取您的扩展安装状态.....

请参考,您有任何疑问

https://blog.mozilla.org/addons/2012/02/16/using-jsm-modules-in-the-sdk/