Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (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);
Add Comment
Please, Sign In to add comment