Created
September 15, 2009 10:22
-
-
Save fearphage/187215 to your computer and use it in GitHub Desktop.
This file contains 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
(function(doc, forEach) { | |
var selectNodes = doc.selectNodes || function(xpath, resolver) { // for firefox | |
var contextNode = this.ownerDocument || this, out = [], i = 0, node | |
,nodes = contextNode.evaluate(xpath, contextNode, resolver || null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); | |
for ( ; node = nodes.snapshotItem(i); i++) { | |
out.push(node); | |
} | |
return out; | |
}, length = 0, time, count = 0; | |
function duration(secs) { | |
var days, hrs, mins; | |
if (secs > 86400) { | |
days = (seconds / 86400) >>> 0; | |
secs %= 86400 | |
} | |
if (secs > 3600) { | |
hrs = (secs / 3600) >>> 0; | |
secs %= 3600; | |
} | |
if (secs > 60) { | |
mins = (secs / 60) >>> 0; | |
secs %= 60; | |
} | |
return (days ? days + ':' : '') + [pad(hrs),pad(mins),pad(secs)].join(':'); | |
} | |
function pad(int) { | |
if (int < 10) return '0' + int; | |
} | |
forEach.call(selectNodes(doc, '//rhtable//tr/td[4]/text()'), function(node) { | |
var array = node.data.split(':'); | |
length += (array[0] *3600) + (array[1] *60) + (array[2] *1); | |
count++; | |
}); | |
time = duration(length); | |
forEach.call(selectNodes(doc, '//*[@class="tagline"]'), function(node) { | |
node.innerHTML += ': ' + time + '(' + count + ' programs)'; | |
}); | |
})(this.document, [].forEach); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment