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

Jan Swartling jan at swartling.net
Thu Apr 21 12:44:39 EDT 2005


Sorry, this is the code that make the google footer appear twice:

// ==UserScript==
// @name            HalloWorld
// @include         http://www.google.com/search*
// ==/UserScript==
(function() {
     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);
})();


Jan Swartling wrote:
> 
> 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
> 
> _______________________________________________
> Greasemonkey mailing list
> Greasemonkey at mozdev.org
> http://mozdev.org/mailman/listinfo/greasemonkey
> 
> 



More information about the Greasemonkey mailing list