There are 9 previous versions of this script.
/*//////////////////////////////////////////////////////////////////////////
// ==UserScript===
// @name XOL DOG UT NickNamer
// @author Jerone UserScript Productions
// @namespace http://userscripts.org/users/31497
// @homepage http://userscripts.org/scripts/show/33341
// @description Looks for your nickname on XOL DOG UT rankings.
// @description InHolland TimeTables v1.4 Beta
// @copyright 2007 - 2008 Jerone
// @version v1.4 Beta
// @versiontext Updated framework.
// @browser FF3
// @include http://www.rork.nl/ut/*
// ==/UserScript==
////////////////////////////////////////////////////////////////////////////
// ToC:
// - Copyrights
// - History
// - Todo
// - Note
// - Framework Check
// - User Settings
// - User Script
// - Statistics
////////////////////////////////////////////////////////////////////////////
THIS SCRIPT IS PROVIDED BY THE AUTHOR `AS IS' AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SCRIPT, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
////////////////////////////////////////////////////////////////////////////
// History:
// [+] = added; [-] = removed; [/] = fixed; [*] = updated;
// - 08-09-2008 10:00 [v1 Alpha]:
// [+] initial release;
// - 08-09-2008 17:00 [v1.1 Beta]:
// [/] fixed bug in condition;
// [+] added option hide right bar;
// - 12-09-2008 22:30 [v1.2 Beta]:
// [*] used site hide option for right bar;
// [+] added fix for site hider;
// [+] added link for your own stats;
// [*] updated search method;
// [+] whole line now colored;
// - 12-09-2008 22:45 [v1.2.1 Beta]:
// [*] cleaned up code;
// - 15-09-2008 01:15 [v1.2.2 Beta]:
// [+] added option to auto refresh every 5 minutes passed the hour;
// - 01-10-2008 23:00 [v1.3 Alpha]:
// [+] added previous stats;
// [*] removed global load event;
// - 03-10-2008 01:00 [v1.3.1 Alpha]:
// [/] fixed small bug with calculating minutes;
// - 21-11-2008 21:00 [v1.3.2 Beta];
// [/] fixed small bug in framework check;
// - 10-01-2009 19:30 [v1.4 Beta]:
// [*] updated framework;
////////////////////////////////////////////////////////////////////////////
// Todo:
// - options window;
////////////////////////////////////////////////////////////////////////////
// Note:
// - This script does NOT work with it's framework:
// - US Framework => http://userscripts.org/scripts/show/39678
// - US Functions => http://userscripts.org/scripts/show/16142
// - US Language => http://userscripts.org/scripts/show/16143
// - US Options => http://userscripts.org/scripts/show/31458
// - US Update => http://userscripts.org/scripts/show/16144
/*//////////////////////////////////////////////////////////////////////////
//*** FRAMEWORK CHECK ***//
if(!window.US||!window.US.Framework){if(window.US!==null&&confirm("Something went wrong with the US Framework. \nMake sure it is installed correctly or reinstall the script. \n\nDo you want to go to the scripts homepage?"))GM_openInTab("http://userscripts.org/scripts/show/39678");window.US=null;return;}else if(!window.US.Framework())return;
new US.Language({langMod:"browser"});
new US.Update({check4Update:true,updateTime:1*60*60*1000,language:"browser",title:"XOL DOG UT NickNamer",thisVersion:'v1.4 Beta',versionUrl:33341,updateUrl:33341});
eval(US.Functions.prototype({Number:[],String:["trim"],Array:[],Object:[]}));
//*** USER SETTINGS ***//
const nickName = "My NickName"; // [String] your nickname;
const hideRightBar = true; // [Boolean] hide right bar;
const hourRefresh = true; // [Boolean] auto refresh every 5 minutes passed the hour;
//*** USER SCRIPT ***//
var XDUNN={
init: function(){
this.fillSearch();
this.highLightName();
this.hideRightB();
this.addMyStats();
this.hourRefresh();
this.calcNewRank();
},
fillSearch: function(){
if((temp=$xs("//table[1]/tbody/tr/td[2]/form/input[2]"))){
temp.value = nickName;
} },
highLightName: function(){
if((temp=$x('//table[@class="bordercolor"]/tbody/tr/td[2][@class="windowbg2"]'))){
temp.forEach(function(node){
if(node.textContent.indexOf(nickName)!=-1){
node.innerHTML=node.innerHTML.replace(nickName,"<strong>"+nickName+"</strong>");
$sa(node,"style","background-color:#EFEFEF !important;");
Array.forEach(node.parentNode.childNodes,function(td){
if(td.nodeType==1 && td.textContent!="\n"){ // FF bug/feature;
$sa(td,"style","background-color:#EFEFEF !important;");
} }); } }); } },
hideRightB: function(){
if(hideRightBar && typeof(unsafeWindow.shrinkHeaderRightbar)=="function"){
window.setTimeout(function(){
unsafeWindow.shrinkHeaderRightbar(true)
$sa($gi("rightbarHeader"),"style","width: 240px; text-align: left; padding-top: 5px; display: none;");
},1);
} },
addMyStats: function(){
if((temp=$xs("//table/tbody/tr[1]/td/div/div[1]/table[1]/tbody/tr/td[1]"))){
$ac(temp,$ct(" :: "));
var link=$ce("A");
$sa(link,"href","index.php?page=7&nick="+nickName);
$sa(link,"target","_parent");
$ih(link,"My stats ("+nickName+")");
$ac(temp,link);
} },
hourRefresh: function(){
if(hourRefresh){
var timer=(new Date().setHours((new Date().getHours()),11,0,0)-new Date().getTime());
window.setTimeout(function(){
XDUNN.updateStats();
},timer>0?timer:timer+60*60*1000); // ##:05
} },
rank:{
thisMonth:[],
overAll:[],
curPage:[],
},
calcNewRank: function(){
function calcTime(time){
var timeHour,timeMinute=0;
if(time>(60*60)){
timeHour=Math.floor(time/(60*60));
timeMinute=(time-((60*60)*timeHour))/60;
if(timeMinute<10){
timeMinute="0"+timeMinute.toString();
}
return timeHour.toString()+":"+timeMinute.toString();
}
else{
time=time/60;
if(time<10){
return "0:0"+time.toString();
}
else{
return "0:"+time.toString();
} } };
// Montly stats & Total stats;
if(location.search=="?page=6" || location.search=="?page=11"){
if(location.search=="?page=6"){
this.rank.curPage=typeof(eval(GM_getValue("XDUNN.rank.thisMonth",[].toSource())))!="undefined"?eval(GM_getValue("XDUNN.rank.thisMonth",[].toSource())):[];
}
else if(location.search=="?page=11"){
this.rank.curPage=typeof(eval(GM_getValue("XDUNN.rank.overAll",[].toSource())))!="undefined"?eval(GM_getValue("XDUNN.rank.overAll",[].toSource())):[];
}
if((score=$x('//table[@class="bordercolor"]/tbody/tr/td[2][@class="windowbg2"]'))){
score.forEach(function(node){
if(node.textContent.indexOf(nickName)!=-1){
// Rank;
var oldRank=(typeof(this.rank.curPage[0])=="undefined"?0:Number(this.rank.curPage[0]));
var newRank=(typeof(node.parentNode.childNodes[0])=="undefined"?0:Number(node.parentNode.childNodes[0].textContent));
if(newRank>oldRank){
var differ=$af(node.parentNode.childNodes[0],$ce("SPAN"));
$sa(differ,"style","color:red;");
$ih(differ," (+"+(newRank-oldRank)+") ");
}
else if(newRank<oldRank){
var differ=$af(node.parentNode.childNodes[0],$ce("SPAN"));
$sa(differ,"style","color:green;");
$ih(differ," (-"+(oldRank-newRank)+") ");
}
// Score;
var oldScore=(typeof(this.rank.curPage[1])=="undefined"?0:Number(this.rank.curPage[1]));
var newScore=(typeof(node.parentNode.childNodes[4])=="undefined"?0:Number(node.parentNode.childNodes[4].textContent));
if(newScore>oldScore){
var differ=$af(node.parentNode.childNodes[4],$ce("SPAN"));
$sa(differ,"style","color:green;");
$ih(differ," (+"+(newScore-oldScore)+") ");
}
else if(newScore<oldScore){
var differ=$af(node.parentNode.childNodes[4],$ce("SPAN"));
$sa(differ,"style","color:red;");
$ih(differ," (-"+(oldScore-newScore)+") ");
}
// Time;
var oldTime=(function(){
if(typeof(XDUNN.rank.curPage[3])!="undefined"){
var temp=XDUNN.rank.curPage[3];
if(/h/.test(temp)){ // h:m
return Number(temp.split(/h/)[0])*60*60 + Number(temp.split(/h/)[1])*60;
}
else if(/m/.test(temp)){ // m:s
return Number(temp.split(/m/)[0])*60;
} }
else return 0;
})();
var newTime=(typeof(node.parentNode.childNodes[6])=="undefined"?0:
Number(node.parentNode.childNodes[6].textContent.split(/:/)[0])*60*60 +
Number(node.parentNode.childNodes[6].textContent.split(/:/)[1])*60);
if(newTime>oldTime){
var differ=$af(node.parentNode.childNodes[6],$ce("SPAN"));
$sa(differ,"style","color:green;");
$ih(differ," (+"+calcTime(newTime-oldTime)+") ");
}
else if(newTime<oldTime){
var differ=$af(node.parentNode.childNodes[6],$ce("SPAN"));
$sa(differ,"style","color:red;");
$ih(differ," (-"+calcTime(oldTime-newTime)+") ");
} } },XDUNN); } }
// Player statistics;
else if(location.search=="?page=7&nick="+nickName){
this.rank.thisMonth=typeof(eval(GM_getValue("XDUNN.rank.thisMonth",[].toSource())))!="undefined"?eval(GM_getValue("XDUNN.rank.thisMonth",[].toSource())):[];
this.rank.overAll=typeof(eval(GM_getValue("XDUNN.rank.overAll",[].toSource())))!="undefined"?eval(GM_getValue("XDUNN.rank.overAll",[].toSource())):[];
var titles = document.evaluate(".//table[2]/tbody/tr[1]/td[1]/table[2]/tbody/tr", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
for(var i=1; i<titles.snapshotLength; i++){
// This Month;
var oldNrMonth=(typeof(this.rank.thisMonth[i-1])=="undefined"?0:Number(this.rank.thisMonth[i-1]));
var newNrMonth=(typeof(titles.snapshotItem(i).childNodes[1])=="undefined"?0:Number(titles.snapshotItem(i).childNodes[1].textContent));
if(i==4){
oldNrMonth=(function(){
if(typeof(XDUNN.rank.thisMonth[3])!="undefined"){
var temp=XDUNN.rank.thisMonth[3];
if(/h/.test(temp)){
return Number(temp.split(/h/)[0])*60*60 + Number(temp.split(/h/)[1])*60;
}
else if(/m/.test(temp)){
return Number(temp.split(/m/)[0])*60;
} }
else return 0;
})();
newNrMonth=(function(){
if(typeof(titles.snapshotItem(i).childNodes[1])!="undefined"){
var temp=titles.snapshotItem(i).childNodes[1].textContent;
if(/h/.test(temp)){ // h:m
return Number(temp.split(/h/)[0])*60*60 + Number(temp.split(/h/)[1])*60;
}
else if(/m/.test(temp)){ // m:s
return Number(temp.split(/m/)[0])*60;
} }
else return 0;
})();
}
if(newNrMonth>oldNrMonth){
var differ=$af(titles.snapshotItem(i).childNodes[1],$ce("SPAN"));
$sa(differ,"style",((i==1||i==12||i==13||i==16)?"color:red;":"color:green;"));
$ih(differ," (+"+((i==4)?calcTime(newNrMonth-oldNrMonth):(newNrMonth-oldNrMonth))+") ");
}
else if(newNrMonth<oldNrMonth){
var differ=$af(titles.snapshotItem(i).childNodes[1],$ce("SPAN"));
$sa(differ,"style",((i==1||i==12||i==13||i==16)?"color:green;":"color:red;"));
$ih(differ," (-"+((i==4)?calcTime(oldNrMonth-newNrMonth):(oldNrMonth-newNrMonth))+") ");
}
// Overall;
var oldNrOverall=(typeof(this.rank.overAll[i-1])=="undefined"?0:Number(this.rank.overAll[i-1]));
var newNrOverall=(typeof(titles.snapshotItem(i).childNodes[2])=="undefined"?0:Number(titles.snapshotItem(i).childNodes[2].textContent));
if(i==4){
oldNrOverall=(function(){
if(typeof(XDUNN.rank.overAll[3])!="undefined"){
var temp=XDUNN.rank.overAll[3];
if(/h/.test(temp)){
return Number(temp.split(/h/)[0])*60*60 + Number(temp.split(/h/)[1])*60;
}
else if(/m/.test(temp)){
return Number(temp.split(/m/)[0])*60;
} }
else return 0;
})();
newNrOverall=(function(){
if(typeof(titles.snapshotItem(i).childNodes[2])!="undefined"){
var temp=titles.snapshotItem(i).childNodes[2].textContent;
if(/h/.test(temp)){ // h:m
return Number(temp.split(/h/)[0])*60*60 + Number(temp.split(/h/)[1])*60;
}
else if(/m/.test(temp)){ // m:s
return Number(temp.split(/m/)[0])*60;
} }
else return 0;
})();
}
if(newNrOverall>oldNrOverall){
var differ=$af(titles.snapshotItem(i).childNodes[2],$ce("SPAN"));
$sa(differ,"style",((i==1||i==12||i==13||i==16)?"color:red;":"color:green;"));
$ih(differ," (+"+((i==4)?calcTime(newNrOverall-oldNrOverall):(newNrOverall-oldNrOverall))+") ");
}
else if(newNrOverall<oldNrOverall){
var differ=$af(titles.snapshotItem(i).childNodes[2],$ce("SPAN"));
$sa(differ,"style",((i==1||i==12||i==13||i==16)?"color:green;":"color:red;"));
$ih(differ," (-"+((i==4)?calcTime(oldNrOverall-newNrOverall):(oldNrOverall-newNrOverall))+") ");
} } }
if(!hourRefresh){
this.updateStats();
} },
updateStats: function(sit){
window.setTimeout(function(){
var beenHereB4=false; // fix for double run when o.readyState==1;
GM_xmlhttpRequest({
headers: {"User-agent":"Mozilla/4.0(compatible) Greasemonkey"},
method: "GET",
url: "http://www.rork.nl/ut/index.php?page=7&nick="+nickName,
onreadystatechange: function(o){
if(o.readyState==1 && beenHereB4!=true){ // loading...
beenHereB4=true;
}
if(o.readyState==4){
var hidenFrame = $ac(document.body,$ce("DIV"));
$hs(hidenFrame,0);
$ih(hidenFrame,o.responseText);
var titles = document.evaluate(".//table[2]/tbody/tr[1]/td[1]/table[2]/tbody/tr", hidenFrame, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
if(titles.snapshotLength>0){
for(var i=1; i<titles.snapshotLength; i++){
XDUNN.rank.thisMonth[i-1]=titles.snapshotItem(i).childNodes[1].textContent.trim();
XDUNN.rank.overAll[i-1]=titles.snapshotItem(i).childNodes[2].textContent.trim();
}
GM_setValue("XDUNN.rank.thisMonth",XDUNN.rank.thisMonth.toSource());
GM_setValue("XDUNN.rank.overAll",XDUNN.rank.overAll.toSource());
if(hourRefresh){
window.location.reload();
} } } } });},0);} }
XDUNN.init(); // execute;
//*** STATISTICS ***//
// Chars (exclude spaces): 12.553
// Chars (include spaces): 14.528
// Chars (Chinese): 0
// Words: 975
// Lines: 351
