chrome.webRequest 未定义
chrome.webRequest is undefined
不确定我哪里出错了:
content.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.*
不适用于页面。
不确定我哪里出错了:
content.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.*
不适用于页面。