Skip to content

Instantly share code, notes, and snippets.

@CodeBrauer
Created April 28, 2016 16:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CodeBrauer/c254d06a29e8d11bb41894f6d2b9cbc1 to your computer and use it in GitHub Desktop.
Save CodeBrauer/c254d06a29e8d11bb41894f6d2b9cbc1 to your computer and use it in GitHub Desktop.
kf2.webadmin.user.js - better players info
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