// ==UserScript==
// @name           Maxima.org ad remover
// @namespace      http://hackzbox.homeip.net/~pmohr/
// @description    Removes Maxima.org's ads. Main incentive was the sidebar.
// @include        http://forums.maxima.org/*
// ==/UserScript==

try {
  var xpathresult =   document.evaluate("/html/body/div[2]/div/div/table[@id='IB_Ads']/tbody/tr/td[3]",
    document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);  
  var bottomTD = xpathresult.snapshotItem(0); 
  if (bottomTD.hasAttribute("width") && bottomTD.getAttribute("width") == 160) {
    bottomTD.parentNode.removeChild(bottomTD);
  }
} catch(e) {}

try {
  var divs = document.body.getElementsByTagName("div");
  for (var i = 0; i < divs.length; i++) {
    var thisDiv = divs[i];
    if (thisDiv.getAttribute("class") == "googleAdBlock") {
      thisDiv.parentNode.removeChild(thisDiv);
    }
  }
} catch(e) {}

try {
  var scripts = document.body.getElementsByTagName("script");
  for (i = 0; i < scripts.length; i++) {
    var thisScript = scripts[i];
    if (thisScripts.getAttribute("src").indexOf("vbulletin") < 0) {
      thisScripts.setAttribute("src", "");
    }
  }
} catch(e) {}

try {
  var iframes = document.body.getElementsByTagName("iframe");
  for (i = 0; i < iframes.length; i++) {
    var thisiFrame = iframes[i];
    if (thisiFrame.getAttribute("id").indexOf("vB_Editor") < 0) {
      thisiFrame.width = 0;
      thisiFrame.height = 0;
      thisiFrame.src = "";
    }
  }
} catch(e) {}

try {
  var images = document.body.getElementsByTagName("img");
  for (i = 0; i < images.length; i++) {
    var thisImage = images[i];
    if (thisImage.getAttribute("src").indexOf("doubleclick") > 0) {
      thisImage.setAttribute("src", "");
      thisImage.setAttribute("alt", "");
      thisImage.setAttribute("title", "");
    }
  }
} catch(e) {}


