// ==UserScript==
// @name           Disable Google Realtime Search
// @namespace      http://w-shadow.com/
// @description    Removes the "Latest results" box from Google Search results
// @version	       1.0.0
//
// @copyright      2009+, Janis Elsts (http://w-shadow.com/)
// @homepage       http://w-shadow.com/blog/2009/12/10/disable-google-realtime-search/
//
// @include        http://www.google.*/search*
// @include        http://google.*/search*
// ==/UserScript==

//Find the box that displays realtime results
var rtr = document.getElementById('rtr');

if ( rtr ){

	//Get the corresponding search result (a LI element) and hide it.
	var latestResults = rtr.parentNode.parentNode;
	latestResults.style.display = "none";
	
	//Click the "Pause" button to suspend the AJAX updates and 
	//prevent Google from wasting the user's bandwidth.
	var pauseButton = document.getElementById('rth').childNodes[0];
	var waitCount = 0; 
	//We'll need to use unsafeWindow to access the actual window object in FF/GM.
	var win = window.unsafeWindow ? unsafeWindow : window; 
	function clickPauseButton(){
		//The google.rt object isnt't initialized right away,
		//so we wait until it's available and call the pause()
		//function then.
		if ( win['google.rt'] ) {
			win.google.x(pauseButton, win.google.rt.pause);
		} else if (waitCount < 100) { //sanity check
			waitCount++;
			setTimeout( clickPauseButton, 500 );
		}
	}
	
	clickPauseButton();
}



