繁体   English   中英

chrome.webRequest 未定义

[英]chrome.webRequest is undefined

不知道我哪里错了:

内容.js

chrome.webRequest.onBeforeRequest.addListener(
  function(info) {
    console.log("URL intercepted: " + info.url);
  },
  // filters
  {
    urls: [
      "<all_urls>"
    ]
  },
  // extraInfoSpec
  ["blocking"]
);

manifest.json

{
  "name": "Color Changer",
  "author": "Microsoft Edge Extension Developer",
  "description": "Change the color of the body on docs.microsoft.com",
  "version": "1.0",
  "manifest_version": 2,
  "icons": {
    "25": "images/color-changer25.png",
    "48": "images/color-changer48.png"
  },
    "permissions": [
    "webRequest",
    "webRequestBlocking",
        "tabs",
        "notifications",
        "http://*/",
        "https://*/"
    ], 
  "browser_action": {
    "default_icon": {
      "20": "images/color-changer20.png",
      "40": "images/color-changer40.png"
    },
    "default_title": "Color Changer",
    "default_popup": "popup.html"
  },
  "content_scripts": [{
    "matches": [
        "<all_urls>"
    ],
    "js": [
      "js/jquery-3.5.1.min.js",
      "js/content.js"
    ],
    "run_at": "document_end"
  }],
  "background": {
    "scripts": ["js/background.js"],
    "persistent": true
  },
  "web_accessible_resources": [
    "css/*.css",
    "js/*.js",
    "html/*.html"
  ]
}

错误:

未捕获的类型错误:无法读取未定义的属性“onBeforeRequest”

内容脚本在它们被注入的页面的上下文中运行。 chrome.*不适用于页面。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM