Hello, i coding a web extension for chrome and firefox for twitch streamer and I’ve got a issue this morning, I understand its the kraken v3 api shutdown which is the problem.
Can someone help me for migrate to v5, im don’t good at JS
the app :
var streamerName = "Gregggg"; /*your name*/
var streamerURL = "gregggg_"; /*your twitch channel name !important*/
var xhr = new XMLHttpRequest()
xhr.open("GET", "https://id.twitch.tv/streams/" + streamerURL + "?client_id=68jskcduf24nyrvd1px4sp8ju3ucrc", true)
xhr.onreadystatechange = function(channel) {
if(xhr.readyState == 4) {
var data = JSON.parse(xhr.responseText)
var elm = document.getElementById("info")
if(data["stream"] === null){
elm.style.color = "#ccc"; /*<-- color for offline text */
elm.innerHTML = "Offline"; /* <-- offline text here*/
}else{
elm.style.color = "#fff"; /*<-- color for online text */
elm.innerHTML = streamerName + " " + "is now live !"; /*<-- text online here*/
}
}
}
xhr.send()
the background script :
var tickRate = 30000
var streamerName = "Gregggg"; /*your name*/
var streamerURL = "gregggg_"; /*your twitch channel name !important*/
function checkStream() {
var xhr = new XMLHttpRequest()
xhr.open("GET", "https://id.twitch.tv/streams/" + streamerURL + "?client_id=68jskcduf24nyrvd1px4sp8ju3ucrc", true)
xhr.onreadystatechange = function (channel) {
if(xhr.readyState == 4) {
var data = JSON.parse(xhr.responseText)
if(data["stream"] === null){
chrome.browserAction.setIcon({path: "icons/icon-offline.png"});/* <-- name your icon offline here , path */
chrome.browserAction.setTitle({title: streamerName + " - Live off"}); /* <-- mini-popup on mousehover icon */
}else{
chrome.browserAction.setIcon({path: "icons/icon-online.png"})/* <-- name your icon online here , path */
chrome.browserAction.setTitle({title: streamerName + " - Live on"}); /* <-- mini-popup on mousehover icon */
}
setTimeout(checkStream, tickRate)
}
}
xhr.send()
}
checkStream()
sorry for my bad english