deviantART Remove Advertisements

By DavidJCobb Last update Sep 6, 2009 — Installed 1,815 times. Daily Installs: 6, 1, 1, 4, 3, 5, 5, 6, 8, 5, 8, 4, 6, 6, 6, 5, 6, 13, 3, 6, 13, 12, 7, 10, 5, 11, 9, 7, 9, 4, 13, 13

There are 6 previous versions of this script.

// ==UserScript==
// @name           deviantART Remove Advertisements
// @namespace      http://davidjcobb.deviantart.com/
// @description    Removes advertisements from deviantART.
// @include        http://*.deviantart.com
// @include        http://*.deviantart.com/
// @include        http://*.deviantart.com/*
// ==/UserScript==

(function(){

function $CSSget(a,b) {
   b=b||a;
   a=b!=a?a:document
   var I,T,C,E,M=[],l,p=b.match(/^([^#\.]*)?(#[^\.]*)?(\.[^#]*)?(#[^\.]*)?/);
   T=(p[1]||"*").toUpperCase();
   I=(p[2]||p[4]||"#").substring(1);
   l=(C=(p[3]||".").substring(1).split(".")).length;
   if(I)E=[a.getElementById(I)];
   else E=a.getElementsByTagName(T);
   Array.forEach(E,
      function(e,i,a) {
         var b=0,CN=" "+e.className.split(".").join(" ")+" ";
         if(T!="*"&&e.tagName!=T)return;
         if(l)
            for(;b<l;b++)
               if(CN.indexOf(" "+C[b]+" ")<0)
                  return;
         M.push(e)
      }
   );
   return M
}

var a,$BA$,dANDIVs,i=0,
   

NU="|a|about|adcast|backend|browse|chat|comments|e|forum|help|i|my|news|prints|s|services|shop|stinkbutt|store|today|www|",
   $=function(){return document.getElementById.apply(document,arguments)},
   X=function(){};

   if(unsafeWindow.da_minish_messages)
      unsafeWindow.da_minish_messages.has_ads=false;

   if(document.body.className.indexOf("withad")!=-1){
      if(a=$("ad-blocking-makes-fella-sad"))
        a.parentNode.removeChild(a);
      while(a=$CSSget("div.ad-blocking-makes-fella-confused")[0]||false)
         a.parentNode.removeChild(a);
      document.body.className=document.body.className.replace(/withad/,"noad")
   }

   if(a=$("browse2-stream")){
      if($CSSget(a,"div.squareBrowsead").length)
         a=($CSSget(a,"div.squareBrowsead")[0]).parentNode.removeChild(a);
      $BA$=unsafeWindow.deviantART.browser.advert;
      unsafeWindow.deviantART.browser.advert=(
         {
            addAd:X,
            constructor:X,
            fetchAd:X,
            onload:X,
            reinsert:X,
            removeAd:X,
            reposition:X,
            catpath:$BA$.catpath,
            container:$BA$.container,
            enabled:true,
            iframeref:document.createElement("iframe"),
            lastcall:$BA$.lastcall,
            resize_listener_active:false
         }
      )
   }

   if(window.location.pathname.indexOf("/gallery")===0||window.location.pathname.indexOf("/favourites")===0){
      try{
         (a=document.getElementsByTagName("iframe")[0]).style.visibility="hidden";
         a.style.display="none";
         a.parentNode.removeChild(a)
      }catch(e){}
      if(a=$("gallery-admaster"))
         a.parentNode.removeChild(a);
      a=document.createElement("style");
      a.innerHTML="iframe.hidoframe{width:0px!important;height:0px!important;display:none!important}";
      document.documentElement.appendChild(a)
   }

   if(window.location.pathname.indexOf("/messages")===0) {
      GM_log("path is /messages");
      (a=$CSSget($("messages"),"table.messages")[0].rows[0]);
      a.cells[2].innerHTML="";
      a.removeChild(a.cells[2]);
      unsafeWindow.da_minish_messages["adzone messages side"]={__noSuchMethod__:X};
      unsafeWindow.da_minish_messages["adzone messages top"]={__noSuchMethod__:X};
      unsafeWindow.da_minish_messages.has_ads=false;
   }

   if(window.location.pathname.indexOf("/art/")===0||window.location.pathname.indexOf("/deviation/")===0){
      (a=$("adso-magnifico").parentNode).parentNode.removeChild(a);
      

(document.documentElement.appendChild(document.createElement("style"))).innerHTML='div.catbar>a[href="http://shop.deviantart.

com/?utm_source=deviantart&utm_medium=deviationpage&utm_campaign=shopbutton"]{display:none}'
   }
   

if(window.location.hostname.indexOf("forum.")===0&&(window.location.pathname.substring(0,window.location.pathname.length-1)).

replace(/[^\b\/]*(\/)[^\b\/]*/gi,"$1").length==3){
      (a=$("google_ads_div_right_wr_forum_atf").parentNode).style.visibility="hidden";
      a.innerHTML=""
   }
   // Following code used to get rid of Journal ads. I haven't seen them -- have they been removed?
   /* if(window.location.pathname.indexOf("/journal")===0){
      (a=$("google_ads_div_right_wr_journal_atf").parentNode).style.visibility="hidden";
      a.innerHTML="";(a=$("google_ads_div_left_wr_journal_atf").parentNode).style.visibility="hidden";
      a.innerHTML=""
   } */

})()