Chrome扩展程序“拒绝加载脚本,因为它违反了以下内容安全策略指令” [英] Chrome Extension "Refused to load the script because it violates the following Content Security Policy directive"

查看:5311
本文介绍了Chrome扩展程序“拒绝加载脚本,因为它违反了以下内容安全策略指令”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆