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

Bob Herrmann bob at jadn.com
Thu Apr 21 09:52:43 EDT 2005


Not exactly sure why that happens, but I noticed when I change my script 
to tie into load event, the problem went away...

(function () {
       // mess with page and you get two footers
})

(function () {
  window.addEventListener("load", function(e) {
    // mess with page and everything is fine
  }
})

-bob

Jan Swartling wrote:

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




More information about the Greasemonkey mailing list