Created
April 28, 2016 16:58
-
-
Save CodeBrauer/c254d06a29e8d11bb41894f6d2b9cbc1 to your computer and use it in GitHub Desktop.
kf2.webadmin.user.js - better players info
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function callAjax(url, callback) { | |
var xmlhttp; | |
xmlhttp = new XMLHttpRequest(); | |
xmlhttp.onreadystatechange = function () { | |
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { | |
callback(JSON.parse(xmlhttp.responseText)); | |
} | |
} | |
xmlhttp.open('GET', url, true); | |
xmlhttp.send(); | |
} | |
var playersIPs = document.querySelectorAll('#players td:nth-child(4)'); | |
var playersSteamIDs = document.querySelectorAll('#players td:nth-child(6)'); | |
[].forEach.call(playersIPs, function (ip) { | |
callAjax('http://ipinfo.io/'+ip.innerHTML+'/json', function(ipinfo) { | |
ip.innerHTML += "<br>[" + ipinfo.country + "] (" + ipinfo.region + ")"; | |
}); | |
}); | |
[].forEach.call(playersSteamIDs, function (steamid) { | |
steamid.innerHTML = '<a href="https://steamcommunity.com/profiles/'+ steamid.innerHTML +'">'+steamid.innerHTML+'</a>'; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment