清单 v3,无法加载扩展:"web_accessible_resources[0]"的值无效。匹配模式无效。无法加载清单



考虑到这个Manifest v3(在v2上运行后,我调整了一些规范以匹配v3(,在将扩展添加到Chrome中时遇到了一些问题(未打包加载(。

准确的错误是:

Invalid value for 'web_accessible_resources[0]'. Invalid match pattern.
Could not load manifest.

这是清单

{
"author": "Hugo Gresse",
"description": "",
"name": "app",
"version": "1.0.0",
"content_scripts": [
{
"js": [
"src/entries/contentScript/primary/main.js"
],
"matches": [
"https://play.google.com/*"
]
}
],
"icons": {
"16": "icons/16.png",
},
"permissions": [],
"action": {
"default_icon": {
"16": "icons/16.png",
},
"default_popup": "src/entries/popup/index.html"
},
"host_permissions": [
"*://*/*"
],
"manifest_version": 3,
"web_accessible_resources": [
{
"resources": [
"assets/src/entries/contentScript/primary/main.5ebc631d.js",
],
"matches": [
"https://play.google.com/console/*"
],
"use_dynamic_url": true
}
]
}

根据此处web_accessible_resources的v3规范细节,matches中使用的模式必须仅基于tld:

URL匹配模式列表,指定哪些页面可以访问资源。只有原点用于匹配URL。原点包括子域匹配。路径被忽略。

更新2023:Google Chrome emits an "Invalid match pattern" error if the pattern has a path other than '/*'.

上面写着";路径";,在我的例子中:console/被忽略,但并不是因为它无法加载扩展。

✅:https://play.google.com/*
❌:https://play.google.com/console/*

正确的web_accessible_resources节点如下:

"web_accessible_resources": [
{
"resources": [
"assets/src/entries/contentScript/primary/main.5ebc631d.js",
],
"matches": [
"https://play.google.com/*"
],
"use_dynamic_url": true
}
]

相关内容

最新更新