View difference between Paste ID: pyZuz3Sn and w3hs9dJk
SHOW: | | - or go back to the newest paste.
1
// ==UserScript==
2
// @name       Anti-Greener for TOMB
3
// @namespace  http://www.johnharvest.net/
4-
// @version    0.2
4+
// @version    0.3
5
// @description  enter something useful
6
// @match      http://messageboard.tapeop.com/*
7
// @copyright  2012+, John Harvest
8
// ==/UserScript==
9
10
function fetchParent(childNode, recursionLevel) {
11
    var parentNode = childNode.parentNode;
12
    for (var i=1; i<recursionLevel; i++) {
13
        var parentNode = parentNode.parentNode;
14
    }
15
    return parentNode;
16
}
17
18
function removeSiblings(offendingNode, numberOfSiblings) {
19
    var offendingParentNode = offendingNode.parentNode;
20
    for (var i=0; i<numberOfSiblings; i++) {
21
        offendingParentNode.removeChild(offendingNode.nextElementSibling);
22
    }
23
    offendingParentNode.removeChild(offendingNode);
24
}
25
26
//remove posts from topics
27-
for (var i=0; i<hrefs.length; i++) {
27+
matchUrl = "http://messageboard.tapeop.com/viewtopic.php?";
28-
    if (hrefs[i].href == "http://messageboard.tapeop.com/profile.php?mode=viewprofile&u=19456") {
28+
if (document.URL.substring(0, matchUrl.length) == matchUrl) {
29-
        var twoParentsUp = fetchParent(hrefs[i], 2);
29+
    var hrefs = document.getElementsByTagName('a');
30-
        if (twoParentsUp.className == "name") {
30+
    for (var i=0; i<hrefs.length; i++) {
31-
            var fourParentsUp = fetchParent(hrefs[i], 4);
31+
        if (hrefs[i].href == "http://messageboard.tapeop.com/profile.php?mode=viewprofile&u=19456") {
32-
            removeSiblings(fourParentsUp, 2);
32+
            var twoParentsUp = fetchParent(hrefs[i], 2);
33-
            i--;
33+
            if (twoParentsUp.className == "name") {
34
                var fourParentsUp = fetchParent(hrefs[i], 4);
35
                removeSiblings(fourParentsUp, 2);
36
                i--;
37
            }
38
        }
39
    }
40
}
41
42
//remove threads from forum view
43
matchUrl1 = "http://messageboard.tapeop.com/megaboard.php";
44
matchUrl2 = "http://messageboard.tapeop.com/viewforum.php?";
45
if (document.URL.substring(0, matchUrl1.length) == matchUrl1 || document.URL.substring(0, matchUrl2.length) == matchUrl2) {
46
var hrefs = document.getElementsByTagName('a');
47
    for (var i=0; i<hrefs.length; i++) {
48
        if (hrefs[i].href == "http://messageboard.tapeop.com/profile.php?mode=viewprofile&u=19456") {
49
            var oneParentsUp = fetchParent(hrefs[i], 1);
50
            if (oneParentsUp.className == "name") {
51
                var threeParentsUp = fetchParent(hrefs[i], 3);
52
                removeSiblings(threeParentsUp, 0);
53
                i--;
54
            }
55
        }
56
    }
57
}