Advertisement
Guest User

tlrobinson

a guest
Dec 3rd, 2007
947
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name           ronpaul-downvote
  3. // @namespace      http://reddit.com
  4. // @description    remove AND downvote ron paul stories from reddit
  5. // @include        http://reddit.com/
  6. // @include        http://*.reddit.com/
  7. // ==/UserScript==
  8.  
  9. var rows = document.evaluate("//*[@class='titlerow']", document, null,
  10.                            XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
  11. var regex = /(\W|^)(Ron|Paul)(\W|$)/i;
  12. var count = 0;
  13. for (var i = 0; i < rows.snapshotLength; i++) {
  14.     var row = rows.snapshotItem(i);
  15.     var text = row.childNodes[0].innerHTML;
  16.     if (regex.exec(text)) {
  17.         var rowNode = row.parentNode.parentNode.parentNode;
  18.         var parentNode = rowNode.parentNode;
  19.         if (text == "Install this Firefox add-on to automatically downvote any Reddit article with Ron or Paul in the headline") {
  20.             var upArrowNode = rowNode.childNodes[1].childNodes[0];
  21.             if (upArrowNode.getAttribute("class") != "arrow upmod")
  22.                 window.location = upArrowNode.getAttribute("onclick");
  23.         } else {
  24.             var downArrowNode = rowNode.childNodes[1].childNodes[1];
  25.             if (downArrowNode.getAttribute("class") != "arrow downmod")
  26.                 window.location = downArrowNode.getAttribute("onclick");
  27.             parentNode.removeChild(rowNode);
  28.             count++;
  29.         }
  30.     }
  31. }
  32. if (count > 0) {
  33.     var stats = document.createElement("div");
  34.     stats.setAttribute("style", "position: absolute; width: auto; height: 20px; top: 2px; left: 2px; background-color: white; border: 1px dashed black");
  35.     stats.innerHTML = "Downvoted " + count + " Ron Paul articles! Yay!";
  36.     document.body.appendChild(stats);
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement