[Greasemonkey] Why does this script make the google footer appear twice?

Jan Swartling jan at swartling.net
Thu Apr 21 12:37:07 EDT 2005


Hi!

Why does this script make the google footer appear twice?

// ==UserScript==
// @name            HalloWorld
// @include         http://www.google.com/search*
// ==/UserScript==
(function() {
	window.addEventListener("load", function(e) {
	    var header = document.evaluate("//table[@bgcolor='#e5ecf9']", document, null, 
XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
     	if (!header) { return; }
	    var other = document.createElement("div");
     	other.innerHTML = "hallo world";
	    header.parentNode.insertBefore(other, header.nextSibling);
	}, false);
})();

I would like to inject the text "hallo world" _before_ onload occurs. _Not_ using 
window.addEventListener("load", function(e){}, false); Is that possible?

Jan



More information about the Greasemonkey mailing list