Skip to content

Instantly share code, notes, and snippets.

@bkralik
Created August 26, 2018 12:27
Show Gist options
  • Select an option

  • Save bkralik/30c11c81c143e60855749e3abe4605bd to your computer and use it in GitHub Desktop.

Select an option

Save bkralik/30c11c81c143e60855749e3abe4605bd to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name UserDB pinger
// @version 2
// @match http://userdb.hkfree.org/*
// @match https://userdb.hkfree.org/*
// @grant GM.xmlHttpRequest
// @run-at document-idle
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// ==/UserScript==
$(".grid-cell-IPAdresa span").each(function(index) {
ips = $( this ).attr('title');
if(ips) {
ips = ips.replace(/ /g, "");
GM.xmlHttpRequest({
method: "GET",
url: "http://sojka.hkfree.org/pinger/?rq=ping&ips="+ips,
onload: function(response) {
f = parseFloat(response.responseText);
if(f > 0.95) {
$(this).css("background-color", "LightGreen");
} else if(f > 0.1) {
$(this).css("background-color", "yellow");
} else {
$(this).css("background-color", "LightPink");
}
}.bind(this)
});
}
});
$("tr[id^=highlightable-ip] td a[href^='/userdb/subnet']").each(function(index) {
ips = $(this).text();
if(ips) {
ips = ips.replace(/ /g, "");
GM.xmlHttpRequest({
method: "GET",
url: "http://sojka.hkfree.org/pinger/?rq=ping&ips="+ips,
onload: function(response) {
f = parseFloat(response.responseText);
if(f > 0.95) {
$(this).css("background-color", "LightGreen");
} else if(f > 0.1) {
$(this).css("background-color", "yellow");
} else {
$(this).css("background-color", "LightPink");
}
}.bind(this)
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment