[Greasemonkey] Including other JS files and using "class" and
custom styles
Bill Donnelly
donnelly at snowcrest.net
Mon Aug 7 01:28:41 EDT 2006
The easiest way to do it without having to worry about any complexity and
such would be to just read the library file and insert it into the injected
script right before injection. The only "problem" with this is that the
code would have multiple instances, which is only a "memory space thing".
They would all be sandboxed, so it wouldn't matter that there were multiple
instances of the library code. (not optimal, but it would be easy, and
would work)
Alternately, I was thinking on a way to treat each library as an object,
with
each function a method of that object, with Gm being the (initial) link
between
the scripts and calls to the object methods, since there would be a
timing issue
of when the library was injected itself and available for calls.
So, initially, when you make a call to the object method, you might actually
get "caught" by Gm, which would finish the call once the library code
(object)
was available, and would then modify the calling script's object value
so that
calls to the methods would be direct after that. This may or may not work or
be viable or optimal, I was just mulling it over.
I think with anything other than my first idea, you have to be careful
because
of security concerns and the like, which makes implementation more complex.
Unless someone has already worked out something better that I don't
remember.
More information about the Greasemonkey
mailing list