Mouseover Ad Remover

From Chickenfoot Script Repository

// ==UserScript==
// @name Mouseover Ad Remover
// @when Pages Match
// @description remove mouseover balloon ads
// @include *
// ==/UserScript==
/*
  Mouseover Ad Remover, v0.1, 2007-06-06
  - Baron Lam (baronlam@gmail.com)
  Hate those ad programs that create those annoying balloon ads when you
  mouseover certain keywords on a page? Well, this script removes those stupid
  things! The following ad programs are currently supported and removed:
   - ContentLink (http://www.kontera.com)
   - IntelliTXT (http://intellitxt.com)
  Those are the two that I've happened to have seen. I'm sure more programs
  can be added (and removed!) later on... Just install this script as a
  trigger for all sites and you're good to go!
  Enjoy!
*/
sleep(5);	// Waiting 5 seconds seems to be enough time for the evil
		// ad javascript to kick in and be ready to be removed.
		// Change this value as necessary.
removeContentLinks();
removeIntelliTXT();
function removeContentLinks() {
        // ContentLink adds code in the form:
	//   <a ... class="kLink"><font ...><span ...>word1</span>
	//      <span ...>word2</span></font></a>
	var allLinks = document.evaluate("//a[@class='kLink']",
		document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
	var thisLink, spans, text;
	for (var i = 0; i < allLinks.snapshotLength; i++) {
		text = "";
		thisLink = allLinks.snapshotItem(i);
		// get the text and replace
		spans = thisLink.getElementsByTagName("span");
		for(var j = 0; j < spans.length; j++) {
			text += spans[j].innerHTML;
			if(j != 0) { text += " "; }
		}
		replace(thisLink, text);
		output("Removed ContentLink: " + text);
	}
  }
function removeIntelliTXT() {
	// IntelliTXT adds code in the form:
	//   <a ... itxtdid="xxx">text</a>
	var allLinks = document.evaluate("//a[@itxtdid]",
		document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
	var thisLink, text;
	for (var i = 0; i < allLinks.snapshotLength; i++) {
		thisLink = allLinks.snapshotItem(i);
		// get the text and replace
		text = thisLink.innerHTML;
		replace(thisLink, text);
		output("Removed IntelliTXT link: " + text);
	}
  }