deviantART Junk Killer

By Stephan Sokolow Last update Feb 17, 2006 — Installed 4,065 times. Daily Installs: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0
// ==UserScript==
// @name          deviantART Junk Killer
// @description	  Remove the deviantART adbox, the "deviantART Notice" box, the "Sponsored Links" sidebar, and the embedded adboxes.
// @include       *.deviantart.com*
// @namespace http://www.ssokolow.com/
// ==/UserScript==

adMatchExpr = "//iframe[contains(@src,'ads.deviantart.com')]/../..[contains(@class,'output-primary')]" +
    " | //div/h2[contains(text(),'deviantART Notice')]/.." +
    " | //div/h2[contains(text(),'Sponsored Links')]/.." +
    " | //iframe[contains(@src,'ads.deviantart.com')]";

function removeIfMatch(xpathExpr) {
    if (results = document.evaluate(xpathExpr, document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null)) {
        for (var i = 0; i < results.snapshotLength; i++) {
            target = results.snapshotItem(i);
            target.parentNode.removeChild(target);
        }
    }
}

(function() 
{
    try {
        removeIfMatch(adMatchExpr);
    } catch (e) {
        alert("UserScript exception: " + e);
    }
} 
)();