// ==UserScript==
// @name Flickrballs
// @description Removes the spaceball from Flickr images.
// @namespace	http://adamv.com/greases/
// @include	http://flickr.com/*
// ==/UserScript==

function foreach(stuff, f){
	if (stuff == null) return;
	
	if ((typeof(stuff)=="string") || (stuff.length == null)) {
		f(stuff);
		return;
	}
	
	for(var i=0; i < stuff.length; i++)
		if (f(stuff[i])) return;
}

function xpath(selector, rootElement, f_each, firstOnly){
	var results = document.evaluate(
		selector, rootElement || document, null,
		XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null);

	var nodes = null;

	if (firstOnly){ 
		nodes =  results.iterateNext(); 
	} else {
		nodes = new Array();var result = null;
		while(result = results.iterateNext()) nodes.push(result);	
	}
		
	// If we have a callback function, run it on the results
	if (f_each != null && nodes != null)
		foreach(nodes, f_each);
	else
		return nodes;
}

xpath("//img[@src='/images/spaceball.gif']", null, function(img){img.parentNode.removeChild(img);});

