错误处理响应:TypeError:无法读取未定义的属性“ setPopup”

时间:2020-08-16 16:33:25

标签: javascript jquery google-chrome-extension browser

最终目标是检查标签url,如果匹配则在徽章中显示消息或警报,但是在chrome.browserAction中变得不确定,而在我的background.js中则是偶数。浏览了几篇文章,但无法解决该错误。

  1. Why is chrome.browserAction.onClicked undefined (in the background script)?
  2. Why is chrome.browserAction.onClicked undefined?

background.js

chrome.tabs.onUpdated.addListener(function(tabId, changeInfo,tab) {
  chrome.browserAction.setPopup({"tabId":tabId,"popup": "popup.html"});
});

Manifest.json

{
  "name": "",
  "version": "1.0",
  "description": "Extension for",
  "permissions": ["tabs","activeTab", "declarativeContent", "storage","identity","identity.email"],
  "options_page": "options.html",
  "background": {
    "scripts": ["background.js"],
    "persistent": false,
    "browser_action": {
      "default_popup": "popup.html"
    }
  },
  "page_action": {
    "default_popup": "popup.html",
    "default_icon": {
      "16": "images/get_started16.png",
      "32": "images/get_started32.png",
      "48": "images/get_started48.png",
      "128": "images/get_started128.png"
    }
  },
  "icons": {
    "16": "images/get_started16.png",
    "32": "images/get_started32.png",
    "48": "images/get_started48.png",
    "128": "images/get_started128.png"
  },
  "manifest_version": 2,
  "content_scripts": [{
    "matches": ["<all_urls>"],
    "js": ["popup.js"]
    }]
}

0 个答案:

没有答案