I'm doing a chrome extension for my viewers to know when i'm on stream or not, so i've done it but it returns an error
First i've tried to do it with JQuery XMLHttpRequest, but I found out that the JSONP was better for those extensions, so I done it with JSONP requests like this
checkStream();
setInterval(function(){
checkStream();
}, 5000);
function checkStream() {
$.ajax({
url: 'https://api.twitch.tv/kraken/streams/cew_kuhaku?client_id=myclientid',
jsonp: "callback",
dataType: "jsonp",
data: {},
// Work with the response
success: function( response ) {
console.log( response ); // server response
$("#json").html(response)
if(response["stream"] == null){
$("#info").html("Kuhaku n'est pas en stream");
chrome.browserAction.setIcon({path: "img/off.png"});
}else {
$("#info").html("Kuhaku est en stream")
chrome.browserAction.setIcon({path: "img/on.png"});
}
}
});
}
My manifest looks like this :
{
"manifest_version":2,
"name":"CEW Kuhaku Streaming",
"version":"1.0",
"description":"Extension de stream de CEW Kuhaku",
"browser_action": {
"default_popup":"index.html"
},
"icons":{
"64" : "img/on.png"
},
"background": {
"scripts": ["jquery.js", "background.js"]
}
}
Here is my index.html
<h1>Stream CEW Kuhaku</h1>
<p id="info">Kuhaku est en live</p>
<p id="json"></p>
<script src="jquery.js"></script>
<script src="app.js"></script>
I expect to verify my stream status but i got this :
Refused to load the script because it violates the following Content Security Policy directive: "script-src 'self' blob: filesystem: chrome-extension-resource:". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.