[Greasemonkey] Re: Including External Scripts.
Andre
gm at andrecgn.de
Tue Feb 21 09:44:35 EST 2006
The code snippet referenced below points out the important difference.
If you add the script tag to the DOM, it will be in a different name
space than where GM is running. You will have to reference it via
"unsafeWindow".
Or you 'eval' the source of the script tag after it loaded, which will
add it to the GM sandbox.
BTW the load event is not needed and not even used in the code snippet:
window.addEventListener('load', loadProto(), false);
"loadProto" should be used without parenthesis.
When a GM injected script runs, the DOM is there and to add an element
you don't need to wait for the load event.
Gavri Fernandez wrote:
> On 2/21/06, Christopher E. Granade <cgranade at greens.org> wrote:
>> Thanks for the help. I tried to use the DOM-hack, and it doesn't seem to
>> be running the code. I attached a script that I'm working on. Any
>> suggestions on why it doesn't work?
>> --Chris
>
> You need to wait for the library to be loaded
> http://manalang.com/archives/2006/01/04/loading-external-javascript-libraries-in-greasemonkey/
>
> Also, there's a mismatch in the case of the variable "myRules"
>
> --
> gavri
> http://ga-woo.livejournal.com/
More information about the Greasemonkey
mailing list