Created
May 29, 2012 14:14
-
-
Save Kha/2828677 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // ==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