Chrome扩展程序“拒绝加载脚本,因为它违反了以下内容安全策略指令” [英] Chrome Extension "Refused to load the script because it violates the following Content Security Policy directive"
问题描述
我正在尝试创建一个Chrome扩展程序,但是我的JS都无法运行。控制台显示以下错误:
I'm trying to create a Chrome extension, but none of my JS works. The console shows this error:
拒绝加载脚本
' https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js
,因为它违反了以下内容安全策略指令:
script-src'self'blob:filesystem:chrome-extension-resource:。
Refused to load the script 'https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js' because it violates the following Content Security Policy directive: "script-src 'self' blob: filesystem: chrome-extension-resource:".
为什么它会阻止我的jQuery运行?
Why is it blocking my jQuery from running?
推荐答案
清单JSON文件。像这样:
Did you allow it in your manifest JSON file. Something like this:
manifest.json
$ b
manifest.json
{
"name": "My Extension",
"content_scripts": [{
"js": ["jquery.min.js", "YourJavaScriptFile.js"],
"matches": ["http://*/*", "https://*/*"]
}]
}
但只是给出了基本的想法。
There are required fields I left out, but just giving the basic idea.
这篇关于Chrome扩展程序“拒绝加载脚本,因为它违反了以下内容安全策略指令”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!