Skip to content

Instantly share code, notes, and snippets.

@Kha
Created May 29, 2012 14:14
Show Gist options
  • Select an option

  • Save Kha/2828677 to your computer and use it in GitHub Desktop.

Select an option

Save Kha/2828677 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name DomJudge IP
// @namespace http://nullrich.de
// @include http://domjudge.iti.uni-karlsruhe.de/*/submissions.php*
// @require https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// ==/UserScript==
function deserialize(name, def) {
return eval(GM_getValue(name, (def || '({})')));
}
function serialize(name, val) {
GM_setValue(name, uneval(val));
}
var cache = deserialize('ip-cache');
$('#refresh').append('<input type="button" value="Clear IP cache">').click(function() {
GM_log("bwaaaa");
cache = {};
serialize('ip-cache', cache);
});
$('th:nth-child(3)').after('<th scope="col">ip</th>');
$('td:nth-child(3)').each(function(index) {
var name = $(this).attr('title').split(':')[0];
var tr = $(this).after('<tr/>');
if (cache[name] !== undefined)
tr.after($('<tr/>').html(cache[name]));
else
jQuery.get('team.php?id=' + name, function(data) {
var ip = /i08ppc([0-9]{2}).atis-stud.uni-karlsruhe.de/.exec(data);
if (ip) ip = parseInt(ip[1]);
cache[name] = ip;
serialize('ip-cache', cache);
tr.after($('<tr/>').html(ip));
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment