gpt4 book ai didi

javascript - 读取 list : Error processing content_script: An unexpected property was found in the WebExtension manifest

转载 作者:行者123 更新时间:2023-11-30 19:48:53 24 4
gpt4 key购买 nike

我正在尝试创建一个简单的 firefox 插件,它将在页面上的 XHR 请求后修改页面。不幸的是,在加载脚本后,它在 about:debugging 上显示错误:“读取 list :处理 content_script 时出错:在 WebExtension list 中发现了一个意外的属性。”似乎内容脚本根本不起作用。

试图将 matches 属性更改为 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"
]
}

关于javascript - 读取 list : Error processing content_script: An unexpected property was found in the WebExtension manifest,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54677735/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com