Tôi đang cố gắng tạo tiện ích chrome cho luồng radio nhưng có sự cố. Khi tôi chạy kịch bản của tôi trong trình duyệt như JS bình thường + HTML + CSS nó hoạt động, nhưng khi tôi cố gắng runing nó giống như phần mở rộng Chrome tôi nhận được lỗi này:Lỗi chỉ thị chính sách bảo mật nội dung của tiện ích mở rộng của Chrome
Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self' chrome-extension-resource:". Either the 'unsafe-inline' keyword, a hash ('sha256-...'), or a nonce ('nonce-...') is required to enable inline execution.
Sau đó tôi thêm này để biểu hiện của tôi:
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'"
Nhưng sau đó tôi đã nhận được thông báo lỗi (lỗi trong dòng manifest với mã trên)
Đây là biểu hiện của tôi:
{
"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'"
}
Đây là tập tin html chính:
<!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>
Xin chào, tnx đã giải quyết được một nửa vấn đề của tôi, bây giờ tôi có thể chạy nó như tiện ích mở rộng nhưng tôi gặp phải lỗi này: 'Từ chối tải tập lệnh 'http://ws.audioscrobbler.com/2.0/? callback = jQuery17105420794193632901_13982… rtist = David + Craig + ft + Sting & track = Rise + và + Fall & format = json & _ = 1398287917991 'vì nó vi phạm chỉ thị Chính sách bảo mật nội dung sau: "script-src' self 'chrome-extension-resource:".' Và do đó tôi không thể có tên bài hát. – user3397388
@ user3397388 Đọc kỹ về Chính sách bảo mật nội dung. Nó giải thích cách bạn cần sửa đổi nó. – Xan