I'm trying to create a Chrome extension, but none of my JS works. The console shows this error:
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:".
Why is it blocking my jQuery from running?
解决方案
Did you allow it in your manifest JSON file. Something like this:
{
"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.