读取清单:处理错误 content_script:在 WebExtension 清单中发现意外的 属性
Reading manifest: Error processing content_script: An unexpected property was found in the WebExtension manifest
我正在尝试创建一个简单的 firefox 插件,它将在页面上的 XHR 请求后修改页面。不幸的是,在加载脚本后,它在 about:debugging "Reading manifest: Error processing content_script: An unexpected property was found in the WebExtension manifest." 上显示错误似乎内容脚本根本不起作用。
尝试将匹配 属性 更改为 content_scripts 和 content_scripts 内部,但没有成功
{
"manifest_version": 2,
"name": "Some Name",
"version": "0.01a",
"applications": {
"gecko": {
"id": "some id"
}
},
"description": "Some Description",
"author": "Some Author",
"icons": {
"48": "icon.png",
"96": "icon.png"
},
"background": {
"scripts": ["jquery.min.js","declarations.js","bg.js"]
},
"content_script": [
{
"matches": ["*://somewebsite/folder/*"],
"js": ["jquery.min.js", "content.js"]
}
],
"permissions": [
"storage",
"*://somewebsite/folder/*",
"webRequest",
"webRequestBlocking"
]
}
manifest.json 有什么问题?错误在哪里?
顺便说一句,content.js:
console.log("CONTENT_SCRIPT");
function someFunction(request, sender, sendresponse) { somecode... }
browser.runtime.onMessage.addListener(someFunction);
第一个是 console.log,它在调试控制台和 Web 控制台上都没有显示 CONTENT_SCRIPT。
bg.js:
browser.runtime.sendMessage({
action: "timetodo",
result: requestDetails
});
问题是 "content_script"
键应该是 "content_scripts"
(如 documentation 中所写)。
所以使用:
{
"manifest_version": 2,
"name": "Some Name",
"version": "0.01a",
"applications": {
"gecko": {
"id": "some id"
}
},
"description": "Some Description",
"author": "Some Author",
"icons": {
"48": "icon.png",
"96": "icon.png"
},
"background": {
"scripts": ["jquery.min.js","declarations.js","bg.js"]
},
"content_scripts": [
{
"matches": ["*://somewebsite/folder/*"],
"js": ["jquery.min.js", "content.js"]
}
],
"permissions": [
"storage",
"*://somewebsite/folder/*",
"webRequest",
"webRequestBlocking"
]
}
我正在尝试创建一个简单的 firefox 插件,它将在页面上的 XHR 请求后修改页面。不幸的是,在加载脚本后,它在 about:debugging "Reading manifest: Error processing content_script: An unexpected property was found in the WebExtension manifest." 上显示错误似乎内容脚本根本不起作用。
尝试将匹配 属性 更改为 content_scripts 和 content_scripts 内部,但没有成功
{
"manifest_version": 2,
"name": "Some Name",
"version": "0.01a",
"applications": {
"gecko": {
"id": "some id"
}
},
"description": "Some Description",
"author": "Some Author",
"icons": {
"48": "icon.png",
"96": "icon.png"
},
"background": {
"scripts": ["jquery.min.js","declarations.js","bg.js"]
},
"content_script": [
{
"matches": ["*://somewebsite/folder/*"],
"js": ["jquery.min.js", "content.js"]
}
],
"permissions": [
"storage",
"*://somewebsite/folder/*",
"webRequest",
"webRequestBlocking"
]
}
manifest.json 有什么问题?错误在哪里?
顺便说一句,content.js:
console.log("CONTENT_SCRIPT");
function someFunction(request, sender, sendresponse) { somecode... }
browser.runtime.onMessage.addListener(someFunction);
第一个是 console.log,它在调试控制台和 Web 控制台上都没有显示 CONTENT_SCRIPT。
bg.js:
browser.runtime.sendMessage({
action: "timetodo",
result: requestDetails
});
问题是 "content_script"
键应该是 "content_scripts"
(如 documentation 中所写)。
所以使用:
{
"manifest_version": 2,
"name": "Some Name",
"version": "0.01a",
"applications": {
"gecko": {
"id": "some id"
}
},
"description": "Some Description",
"author": "Some Author",
"icons": {
"48": "icon.png",
"96": "icon.png"
},
"background": {
"scripts": ["jquery.min.js","declarations.js","bg.js"]
},
"content_scripts": [
{
"matches": ["*://somewebsite/folder/*"],
"js": ["jquery.min.js", "content.js"]
}
],
"permissions": [
"storage",
"*://somewebsite/folder/*",
"webRequest",
"webRequestBlocking"
]
}