Twitch number online streamers in Chrome Plugin

Hi,
thanks for tip, now are without errors. But “On” in BadgeText still miss :[

chrome.browserAction.setBadgeText( { text: “$stats” } );

var clientID = ‘app-ID-key’;
var baseKraken = ‘https://api.twitch.tv/kraken/’;

function getKrakenAPI(endpoint, data, method) {
return $.ajax({
url: baseKraken + endpoint,
method: method,
data: data,
dataType: ‘json’,
headers: {
‘Client-ID’: clientID,
Accept: ‘application/vnd.twitchtv.v5+json’
}
});
}

getKrakenAPI(
‘streams’,
{
channel: [ ‘ivelios_christopher’, ‘esl_sc2’ ]
}
)
.done(function(data) {
if(data._total > 0) {

$stats = write: “On”;

  }

});

Maybe in somethink like this will be working? But I dont know how do it in .js Maybe BadgeText cant be in “If” function.

Best,
Ivelios