[Greasemonkey] "Invalid document, could not get global object" error?

Michael Kraft mjk4984 at yahoo.com
Sun Aug 28 15:17:38 EDT 2005


--- Aaron Boodman <zboogs at gmail.com> wrote:
> Hah! You're right. I think that I was listening to onStateChange at
> one point, then changed it to onProgressChange but forgot to change
> the parameter list. Luckily, I don't use anything except the first
> two, which are the same for both methods.
> 
> Thanks. It should definitely be onProgressChange though.
> 

Ok I think I found a fix for the problem I'm having based on the parameters
being passed in.  From my experiments with logging the the fourth parameter
(PRInt32 maxSelfProgress) in the onProgessChange callback in GM_DocHandler I
found that it is always -1.  The only time I've found it to be not -1 is when I
hit that error (it was 622) which seems to occur if the page hasn't unloaded. 
This seems to make sense since the maxSelfProgress wouldn't be known unless the
page has already finished loading (-1 means unknown). 

I added a check to make sure the maxSelfProgress is -1 when it checks to see if
the DomWindow is the unsafeContentWin at the top of the function.  I then
logged the maxSelfProgress and the url to see what happened when it wasn't -1. 
Well it showed up as 622 a couple of times and then went to -1 and the script
worked as normal.

I haven't played with it long enough to see if it won't break anything else,
but as far as I can tell it won't.  In fact it might fix some pages that are
slow to load.


More information about the Greasemonkey mailing list