Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name ronpaul-downvote
- // @namespace http://reddit.com
- // @description remove AND downvote ron paul stories from reddit
- // @include http://reddit.com/
- // @include http://*.reddit.com/
- // ==/UserScript==
- var rows = document.evaluate("//*[@class='titlerow']", document, null,
- XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
- var regex = /(\W|^)(Ron|Paul)(\W|$)/i;
- var count = 0;
- for (var i = 0; i < rows.snapshotLength; i++) {
- var row = rows.snapshotItem(i);
- var text = row.childNodes[0].innerHTML;
- if (regex.exec(text)) {
- var rowNode = row.parentNode.parentNode.parentNode;
- var parentNode = rowNode.parentNode;
- if (text == "Install this Firefox add-on to automatically downvote any Reddit article with Ron or Paul in the headline") {
- var upArrowNode = rowNode.childNodes[1].childNodes[0];
- if (upArrowNode.getAttribute("class") != "arrow upmod")
- window.location = upArrowNode.getAttribute("onclick");
- } else {
- var downArrowNode = rowNode.childNodes[1].childNodes[1];
- if (downArrowNode.getAttribute("class") != "arrow downmod")
- window.location = downArrowNode.getAttribute("onclick");
- parentNode.removeChild(rowNode);
- count++;
- }
- }
- }
- if (count > 0) {
- var stats = document.createElement("div");
- stats.setAttribute("style", "position: absolute; width: auto; height: 20px; top: 2px; left: 2px; background-color: white; border: 1px dashed black");
- stats.innerHTML = "Downvoted " + count + " Ron Paul articles! Yay!";
- document.body.appendChild(stats);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement