【发布时间】:2014-06-06 16:01:56
【问题描述】:
我正在尝试制作无线电流 chrome 扩展,但出现了问题。当我像普通的 JS+HTML+CSS 一样在浏览器中运行我的脚本时,它可以工作,但是当我尝试像 Chrome 扩展程序一样运行它时,我得到了这个错误:
拒绝执行内联脚本,因为它违反了以下内容 内容安全策略指令:“script-src 'self' chrome-extension-resource:"。要么是 'unsafe-inline' 关键字,要么是 哈希 ('sha256-...') 或 nonce ('nonce-...') 需要启用 内联执行。
之后我将它添加到我的清单中:
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'"
但在那之后我收到了错误消息(清单行中的错误与上面的代码)
这是我的清单:
{
"background": {
"scripts": [ "jquery.js", "jquery-ui.js", "plate.js" ]
},
"browser_action": {
"default_icon": "Images/action-normal.png",
"default_popup": "player.html",
"default_title": ""
},
"description": "Chrome Player",
"manifest_version": 2,
"name": "Radio Chrome Player",
"permissions": [ "http://www.radio-station.com/" ],
"version": "1.0"
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'"
}
这是主要的 html 文件:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="jquery.js"></script>
<script src="jquery-ui.js"></script>
<script src="main.js"></script>
<script>$(function(){$("#radioplayere").plate({playlist: [{file:"http://RADIO_STATION_STREAM_URL/;"}], phpGetter: "http://hostingshoutcast.com/stream/plate/php/plate.php"});});</script>
</head>
<body>
<div id="radioplayer">If you are seeing this then an error has occurred!</div>
</body>
</html>
【问题讨论】:
标签: javascript html google-chrome google-chrome-extension content-security-policy