Google Filter

Some web sites really annoy me when they get into google's search results. The recent one that pissed me off is expertsexechange.com (with a dash in there somewhere!)

It annoyed me enough to write a greasemonkey script to remove it from google's search results.

// ==UserScript==
// @name           Google Filter
// @namespace      nickthecoder
// @description    Removes annoying sites from google's search results
// @include        http://www.google.co.uk/search*
// ==/UserScript==

// Please change the version number before each modification.
var version = "0.1";

// ADD YOUR OWN FILTERS HERE (Its an array of regular expressions)
filters = [
/.*experts-exchange.com.*/,
/http:\/\/www.bing.com.*/,
];


// Add stubs for logging if firebug isn't enabled on this browser
if ( ! console ) {
  console = new Object();
  var doNothing = function() {};
  console.debug = console.info = console.log = doNothing;
}
console.debug( "begin greasemonkey script google_filter" );


// Now lets do the biz...
var links = document.getElementsByTagName( "a" );

for ( var i = 0; i < links.length; i ++ ) {
  var link = links[ i ];
  if ( link.className == "l" ) {

    for ( var f = 0; f < filters.length; f ++ ) {
      filter = filters[ f ];

      if ( filter.test( link.href ) ) {

        console.debug( "Found annoying site : " + link.href );
        link.href="http://nickthecoder.co.uk/pinkwino/view/Google+Filter"
        link.parentNode.parentNode.style.opacity = 0.2;;
        var why = document.createElement("div");
        var html = '<div style="float: right;"><a title="about this greasemonkey addition (version ' + version + ' )" href="http://nickthecoder.co.uk/pinkwino/view/Google+Filter">ntc</a></div>';
        why.innerHTML = html;
        
        link.parentNode.insertBefore( why, link );
      }

    }
  }
}

console.debug( "end greasemonkey script google_filter" );

Version History

0.1

Initial version