var config_defaults = { serverurl:"http://localhost:42010", apikey:"BlackPinkInYourArea" } document.addEventListener("DOMContentLoaded",function() { document.getElementById("serverurl").addEventListener("change",checkServer); document.getElementById("apikey").addEventListener("change",checkServer); document.getElementById("serverurl").addEventListener("focusout",checkServer); document.getElementById("apikey").addEventListener("focusout",checkServer); document.getElementById("serverurl").addEventListener("input",saveConfig); document.getElementById("apikey").addEventListener("input",saveConfig); chrome.runtime.onMessage.addListener(onInternalMessage); chrome.storage.local.get(config_defaults,function(result){ for (var key in result) { document.getElementById(key).value = result[key]; } checkServer(); }) chrome.runtime.sendMessage({"type":"query"}) }); function onInternalMessage(request,sender) { if (request.type == "response") { players = request.content html = ""; for (var i=0;i= 200) && (this.status < 300)) { //document.getElementById("checkmark_url").innerHTML = "✔️" //document.getElementById("checkmark_key").innerHTML = "✔️" document.getElementById("serverurl").style.backgroundColor = "lawngreen" document.getElementById("apikey").style.backgroundColor = "lawngreen" } else if (this.status == 403) { //document.getElementById("checkmark_url").innerHTML = "✔️" //document.getElementById("checkmark_key").innerHTML = "❌" document.getElementById("serverurl").style.backgroundColor = "lawngreen" document.getElementById("apikey").style.backgroundColor = "red" } else { //document.getElementById("checkmark_url").innerHTML = "❌" //document.getElementById("checkmark_key").innerHTML = "❌" document.getElementById("serverurl").style.backgroundColor = "red" document.getElementById("apikey").style.backgroundColor = "red" } } }