我正在尝试创建一个chrome扩展。我的清单文件是
{
"name": "Alert-Beep",
"action": {},
"manifest_version": 3,
"version": "0.1",
"description": "Beeps if alert() is called",
"content_security_policy": "script-src 'self'; object-src 'self'",
"permissions": [
"activeTab",
"scripting"
],
"content_scripts": [
{
"matches": ["https://*.com/*"],
"js": ["alert-beep.js"],
"run_at": "document_start"
}
]
}
加载扩展模块失败,并显示消息
Failed to load extension
File
~\alert-beep
Error
Invalid value for 'content_security_policy'.
Could not load manifest.
我做错了什么?
发布于 2021-08-11 23:14:36
另一个对我有帮助的例子是:
清单v3
"content_security_policy": {
"extension_pages": "script-src 'self'; object-src 'self'; script-src-elem 'self' 'unsafe-inline' https://music.yandex.ru/;"
}
发布于 2021-07-15 22:45:48
我已经研究了CSP for chrome扩展(访问here了解更多关于清单v3的信息)。
使用的
"content_security_policy": {
"extension_pages": "script-src 'self'; object-src 'self'"
}
发布于 2022-02-03 07:36:57
由于manifest现在更新为V3,因此content_security_policy是一个字典。在这种情况下,您应该更改此行
"content_security_policy": "script-src 'self'; object-src 'self'",
到这个
"content_security_policy": {
"script-src": 'self',
"object-src": 'self'
}
点击此处阅读更多信息:https://developer.chrome.com/docs/extensions/mv3/intro/mv3-migration/#content-security-policy
https://stackoverflow.com/questions/67130826
复制相似问题