// ==UserScript==
// @name	  		Google + del.icio.us
// @author			Mark Husson <mhusson atte gmail dought com>
// @description		Very simple, just adds another button to the main google home search page that says "del.icio.us". It will take your search term, replace all spaces with +'s and search del.icio.us tags.
// @namespace		http://michaelhusson.com/mark/greasemonkey/
// @include	 		http://google.com/*
// @include	 		http://www.google.com/*
// @exclude	 		http://google.com/search*
// @exclude	 		http://www.google.com/search*
// ==/UserScript=

(function() {
	clickDelicious = function(){
		var tags = document.f.q.value;
		var find = " ";
		var replace = "+";
		var temp = "" + tags;
		while (temp.indexOf(find)>-1) {
			var pos= temp.indexOf(find);
			temp = "" + (temp.substring(0, pos) + replace + 
			temp.substring((pos + find.length), temp.length));
		}
		document.location.href = "http://del.icio.us/tag/"+temp;
	}
	
	var createdInput = document.createElement("input");
	createdInput.name = "delicioussearch";
	createdInput.type = "button";
	createdInput.value = "del.icio.us";
	createdInput.title = "del.icio.us Tag Search";
	createdInput.addEventListener("click",clickDelicious,false);
	var inputs = document.getElementsByTagName("input");
	for(var i=0;i<inputs.length;i++){
		if(inputs[i].value.indexOf("Feeling Lucky") != -1){
			inputs[i].parentNode.appendChild(createdInput);
		}
	}
})();




























