[Greasemonkey] Script scoping

Paul Roub paul at roub.net
Wed May 4 12:29:33 EDT 2005


Matt Labrum wrote:
>     Has anyone "requested" that the scripts be loaded in a
>     specific order? That probably being the order they show
> 
> I suggested using either some sort of meta data to specify when the 
> script loads  or a function call our  scripts could call (Dont think 
> that one would be much use because the script is already loaded if it 
> can call a function)
> 

An inside-out approach to that might be a GM event you could subscribe 
to -- e.g.

	GM_notifyOnLoad('otherscriptname', myfunction);

When the other script is loaded (or if it's already been loaded), GM 
calls 'myfunction', and you do your startup dance.

myfunction() would probably take the other-script-name as a parameter; 
in case you need to wait on more than one external script, you can keep 
track of which ones you're still waiting for.

-paul


More information about the Greasemonkey mailing list