javascript - Chrome extension Content Security Policy directive error -
i'm trying make radio stream chrome extension there problem. when run script in browser normal js+html+css works, when try runing chrome extension error:
refused execute inline script because violates following content security policy directive: "script-src 'self' chrome-extension-resource:". either 'unsafe-inline' keyword, hash ('sha256-...'), or nonce ('nonce-...') required enable inline execution.
after added manifest:
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'"
but after getting error message(error in manifest line code above)
this manifest:
{ "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'" }
this main html file:
<!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 seeing error has occurred!</div> </body> </html>
your problems follows:
chrome csp forbids inline code, , not subject override.
'unsafe-eval'
not address issue, ,'unsafe-inline'
would've helped will ignored chrome.you need rid of inline code:
<script>$(function(){$("#radioplayere").plate({playlist: [{file:"http://radio_station_stream_url/;"}], phpgetter: "http://hostingshoutcast.com/stream/plate/php/plate.php"});});</script>
this needs moved in js file.
there typo in manifest.json, forgot comma:
"version": "1.0",
in general, using json validator can catch errors.
Comments
Post a Comment