May 132010
 

This Javascript Greasemonkey script will highlight a domain name in google results pages in both image search and standard search. This is of course freeware.

Greasemonkey Google Highlighter

// ==UserScript==
// @name           Google Highlighter
// @namespace      dodgy_gr
// @version        0.0.1
// @description    Google Highlighter
// @include        http://www.google.*/search?*
// @include        http://www.google.*/images?*
// @history        First Release. Modify domainSearch to the url your interested in.
// ==/UserScript==

//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//MODIFY THIS LINE TO YOUR DOMAIN

var domainSearch = /somedodgywebsite/;

//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

//getElementsByCLassName by Stephen Chapman, http://javascript.about.com/library/bldom08.htm
document.getElementsByClassName = function(cl) {
	var retnode = [];
	var myclass = new RegExp('\\b'+cl+'\\b');
	var elem = this.getElementsByTagName('*');
	for (var i = 0; i < elem.length; i++) {
		var classes = elem[i].className;
		if (myclass.test(classes)) retnode.push(elem[i]);
	}
	return retnode;
};

function highlightClass(className) {
	var cites = document.getElementsByClassName(className);
	for (var i=0;i < cites.length;i++) {
		if (cites[i].firstChild && domainSearch.test(cites[i].firstChild.innerHTML)) {
			cites[i].style.backgroundColor = 'pink';
		}
	}
}

if (location.pathname=='/images') highlightClass('a');
if (location.pathname=='/search') highlightClass('f');
Share

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>