Javascript 将附加SDK移植到Webextension

Javascript 将附加SDK移植到Webextension,javascript,firefox,firefox-addon-sdk,firefox-addon-webextensions,firefox-57+,Javascript,Firefox,Firefox Addon Sdk,Firefox Addon Webextensions,Firefox 57+,我希望有人能帮助我在Firefox57中使用webextensions。 我正在尝试将插件从附加SDK移植到Webextension 我只有以下代码 Package.json { "name": "myPlugin", "title": "Grafic", "id": "myID", "main": "lib/main.js", "description": "myDescription", "author": "", "license": "MPL 2.0",

我希望有人能帮助我在Firefox57中使用webextensions。 我正在尝试将插件从附加SDK移植到Webextension

我只有以下代码

Package.json

{
  "name": "myPlugin",
  "title": "Grafic",
  "id": "myID",
  "main": "lib/main.js",
  "description": "myDescription",
  "author": "",
  "license": "MPL 2.0",
  "version": "1.0.1"
}

而main.js

browser.tabs.getCurrent实际上只用于后台脚本。您需要的只是window.location.href.

browser.tabs.getCurrent实际上只用于后台脚本。您需要的只是window.location.href.

要在页面处于活动状态时获取其URL,您可以使用:

document.addEventListener("visibilitychange", function () {
  if (!document.hidden) {
      console.log('URL: ' + location.href);
  }
}, false);

要在页面处于活动状态时获取其URL,可以使用:

document.addEventListener("visibilitychange", function () {
  if (!document.hidden) {
      console.log('URL: ' + location.href);
  }
}, false);