【问题标题】:Browser extensions detect install浏览器扩展检测安装
【发布时间】:2012-04-11 08:20:48
【问题描述】:

我在 Firefox 中有一个扩展程序,在 Chrome 中有一个扩展程序。我想在安装或卸载扩展程序时调用 javascript 函数。在这些浏览器中都可以吗?

【问题讨论】:

    标签: javascript google-chrome-extension firefox-addon xul


    【解决方案1】:

    火狐

    谷歌浏览器

    在 Chrome 中,没有内置的方法来检测安装或卸载。

    • 可以检查background page 上的localStorage 标志是否存在,然后采取行动。

      if (!localStorage.getItem('my-extension-first-time')) {
          // Do something
          alert('Hello first timer!');
          // Set flag
          localStorage.setItem('my-extension-first-time', true);
      }
      
    • 无法监听自身的卸载。
    • chrome.management API 可用于monitor 外部扩展(卸载)安装。

    【讨论】:

      猜你喜欢
      • 2013-05-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-14
      • 1970-01-01
      • 2017-01-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多