json - ManifestV3: "invalid value for web_accessible_resources" or "resources must be listed" errors
问题描述
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"]
}
解决方案
The syntax for web_accessible_resources
in Manifest V3 has changed:
"web_accessible_resources": [{
"resources": ["/images/icon.png"],
"matches": ["<all_urls>"]
}]
The matches
key must specify where to expose these resources since Chrome 89.
推荐阅读
- python - 重定向到用户个人资料详细信息不正确
- android - 在android上进行双向数据绑定的正确方法是什么?
- python - 将连接错误作为python中的参数的while循环
- jenkins - Jenkins 声明式管道记录一条在 Blue Ocean 中可见的警告消息
- json - pyspark - 读取 json 文件
- angular - 如何使用 Observable 存储状态管理以角度实现反应式编程?
- javascript - 如果对象数组中的值为假,如何返回具有布尔值的函数?
- javascript - Gulpfile 不适用于 import X from './X' statements
- security - SoftHSM V2 库文件?
- reactjs - React Material UI 条件渲染表格单元格颜色