[Greasemonkey] How to create a library.
Aaron Boodman
zboogs at gmail.com
Wed Sep 7 20:00:25 EDT 2005
Interesting. I wonder which is more natural to scripters. What I was
considering was more like the global approach: I intended to add a new
pass to the evaluation loop before the current one.
The second could be implemented in 0.6 using the ever-useful __proto__
property. Right now, we create a sandbox, and set it's __proto__ to
window.
Instead, we create one sandbox and eval all the libs onto it. Then we
set it's __proto__ to window. Then we create a new sandbox for each
script and set it's proto to the library sandbox.
I feel like if I do @library, I mean that exactly one instance of the
code should exist for all scripts -- like your global approach.
I feel like include( ) is more runtimey -- and that it should be a new
copy each time it is called.
On 9/7/05, John Plsek <gm at plsek.id.au> wrote:
> Aaron Boodman wrote:
>
> >On 9/7/05, John Plsek <gm at plsek.id.au> wrote:
> >
> >
> >> * @library (use in place of @name) to indicate that a script is a
> >>library. All scripts can access variables and methods defined in a library.
> >>
> >>
> >
> >It seems pretty simple to do this, for 0.6.x at least. We could do
> >this, GM_import, or both.
> >_______________________________________________
> >Greasemonkey mailing list
> >Greasemonkey at mozdev.org
> >http://mozdev.org/mailman/listinfo/greasemonkey
> >
> >
> >
> I was tinkerring with this in the now defunct GM 0.4x. The code I used
> would be totally useless for GM0.5+, though.
>
> I actually had two types of library/import ... a simple include of the
> library code, and what I called a global include
>
> the difference was, if two (or more) scripts used the "global" include,
> they, in effect, could communicate with each other through variables in
> the library code.
>
> sorry for my lack of correct terminology, I'm sure I could make it
> clearer by using words like "scope", but I'm still a javaScript babe in
> the woods
>
> John
> _______________________________________________
> Greasemonkey mailing list
> Greasemonkey at mozdev.org
> http://mozdev.org/mailman/listinfo/greasemonkey
>
More information about the Greasemonkey
mailing list