[Greasemonkey] Replacing the head element

esquifit esquifit at googlemail.com
Tue Jun 6 02:10:30 EDT 2006


mmm... may be the XPCNativeWrapper thingy is responsible for this difference
in behavior?

I don't quite understand the meaning of it; I did a little investigation,
and I found the following :

1) XPCNWs objects may be recognised through their  'wrappedJSObject'
property.  Example:
alert(unsafeWindow); // [object Window]
alert(window.wrappedJSObject); // [object Window]
alert(unsafeWindow.wrappedJSObject); // undefined

2) 'document.location' and 'location' are XPCNWs:
alert(document.location.wrappedJSObject); // http://www. ....
alert(location.wrappedJSObject); // http://www. ....

3b) and they are XPCNWs around the same object:
alert(document.location.wrappedJSObject === location.wrappedJSObject);
//true

3b) but they're not the same objects:
alert(document.location === location); // false

4a) May be because of 3b, we get:
alert(document.location.reload === location.reload);  //false

4b) but surprisingly:
alert(document.location.href   === location.href  ); // true

Unfortunately, I don't know what the meaning of all this could be.

2006/6/2, Lenny Domnitser <ldrhcp at gmail.com>:
>
> On 6/2/06, esquifit <esquifit at googlemail.com> wrote:
> > Sorry for the silly question: where does the difference lie between your
> > proposal
> >
> > setTimeout(function() {
> >  location.reload();
> > }, 30000);
> >
> > and Anthony's
> >
> > setTimeout(document.location.reload, 30000);
> >
> > What's the purpose of  wrapping the actual function we are interested in
> > into an anonymous one?
>
> It doesn't work without the wrapper. I tried it Anthony's way first,
> but, for reasons I don't understand, it didn't work.
>
>


More information about the Greasemonkey mailing list