The script is located at http://www.breakbase.com/cc/conquerclubcountdown.user.js
The source code is as follows:
- Code: Select all
// ==UserScript==
// @name conquer club count down
// @namespace CC
// @include http://www.conquerclub.com/game.php?game=*
// ==/UserScript==
var game = null;
function init(elem) {
if (elem.nextSibling.nodeType != 3)
return;
var str = elem.nextSibling.nodeValue;
var h = (parseInt(str.substr(1,2),10)*3600000);
var m = (parseInt(str.substr(7,2),10)*60000);
var s = (parseInt(str.substr(13,2),10)*1000);
var e = document.createElement('div');
var now = new Date();
game = new Date(now.getTime()+(h+m+s));
e.setAttribute('id','timer');
elem.parentNode.replaceChild(e,elem.nextSibling);
update();
}
function update() {
var e = document.getElementById('timer');
var now = new Date();
if (now.getTime() < game.getTime()) {
var hours = Math.floor(Math.floor(game.getTime()-now.getTime())/3600000);
var mins = Math.floor(Math.floor(game.getTime()-now.getTime())%3600000/60000);
var sec = Math.floor(Math.floor(game.getTime()-now.getTime())%3600000%60000/1000);
e.innerHTML = doubleDigit(hours)+'hrs '+doubleDigit(mins)+'mins '+doubleDigit(sec)+'sec';
setTimeout(update, 1000);
} else
window.location.reload();
}
function doubleDigit(n) {
if (n >= 10)
return ''+n;
else
return '0'+n;
}
init(document.getElementsByTagName('h4')[0]);