Guest User

Untitled

a guest
Apr 16th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. (function(doc, forEach) {
  2. var selectNodes = doc.selectNodes || function(xpath, resolver) { // for firefox
  3. var contextNode = this.ownerDocument || this, out = [], i = 0, node
  4. ,nodes = contextNode.evaluate(xpath, contextNode, resolver || null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5. for ( ; node = nodes.snapshotItem(i); i++) {
  6. out.push(node);
  7. }
  8. return out;
  9. }, length = 0, time, count = 0;
  10. function duration(secs) {
  11. var days, hrs, mins;
  12. if (secs > 86400) {
  13. days = (seconds / 86400) >>> 0;
  14. secs %= 86400
  15. }
  16. if (secs > 3600) {
  17. hrs = (secs / 3600) >>> 0;
  18. secs %= 3600;
  19. }
  20. if (secs > 60) {
  21. mins = (secs / 60) >>> 0;
  22. secs %= 60;
  23. }
  24. return (days ? days + ':' : '') + [pad(hrs),pad(mins),pad(secs)].join(':');
  25. }
  26. function pad(int) {
  27. if (int < 10) return '0' + int;
  28. }
  29. forEach.call(selectNodes(doc, '//rhtable//tr/td[4]/text()'), function(node) {
  30. var array = node.data.split(':');
  31. length += (array[0] *3600) + (array[1] *60) + (array[2] *1);
  32. count++;
  33. });
  34. time = duration(length);
  35. forEach.call(selectNodes(doc, '//*[@class="tagline"]'), function(node) {
  36. node.innerHTML += ': ' + time + '(' + count + ' programs)';
  37. });
  38. })(this.document, [].forEach);
Add Comment
Please, Sign In to add comment