清单V3:"web_accessible_resources的无效值"或“必须列出资源"错误 [英] ManifestV3: "invalid value for web_accessible_resources" or "resources must be listed" errors
问题描述
这是我第一次尝试编写Chrome扩展程序.我在 manifest.json 中添加了"web_accessible_resources":["images/icon.png"]
,因为我想从内容脚本访问该图像.添加此行后,出现错误"web_accessible_resources [0]的无效值".无法加载清单."我已检查以确保文件路径正确,否则我可能在哪里出错?感谢您的帮助.
This is my first attempt writing a Chrome extension. I added "web_accessible_resources": ["images/icon.png"]
to manifest.json because I wanted to access the image from content script. After adding this line, I got the error "Invalid value for 'web_accessible_resources[0]'.
Could not load manifest." I have checked to make sure the file path is correct, where else could I be wrong?
Any help is appreciated.
{
"name": "Bookmark Checker",
"version": "1.0",
"manifest_version": 3,
"permissions": [
"bookmarks",
"activeTab"
],
"background": {
"service_worker": "background.js"
},
"content_scripts": [
{
"matches":["https://www.google.com/search?*"],
"js": ["content/content.js"]
}
],
...
"web_accessible_resources": ["images/icon.png"]
}
推荐答案
清单V3中 web_accessible_resources
的语法已更改:
The syntax for web_accessible_resources
in Manifest V3 has changed:
"web_accessible_resources": [{
"resources": ["/images/icon.png"],
"matches": ["<all_urls>"]
}]
matches
键必须指定从Chrome 89开始公开这些资源的位置.
The matches
key must specify where to expose these resources since Chrome 89.
这篇关于清单V3:"web_accessible_resources的无效值"或“必须列出资源"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!