// Yubnub Google Integration
//
// Copyright (c) Leandro Ardissone 2005
// Released under the GPL license
// http://www.gnu.org/copyleft/gpl.html
// ------------------------------------------------------
// Website: http://www.ardissone.org/
// ------------------------------------------------------
// ==UserScript==
// @name Yubnub Google Integration
// @description Adds a Yubnub button to integrate with Google search
// @include http://www.google.com/ig
// @include http://www.google.com/
// ==/UserScript==

window.yubnub = function() {
	inputs = document.getElementsByTagName("input");
	for (var i=0; i<inputs.length; i++) if (inputs[i].name == "q") break;
	inputs[i].name = "command";
	
	el = document.getElementsByTagName("form");
	el[0].action = "http://yubnub.org/parser/parse";
	el[0].onsubmit = "";
	el[0].submit();
	
}

window.addEventListener("load", function(e) {
  tds = document.getElementsByTagName("td");
  for (var i=0; i<tds.length; i++) if (tds[i].align == "center") break;
  
  tds[i].innerHTML += "<input name='yubnub' id='yubnub' type='button' value='Yubnub Search' accesskey='y' onclick='window.yubnub();'>";
}, false);

