[Greasemonkey] How to create a library.
lists at atrus.org
Wed Sep 7 20:24:49 EDT 2005
Jeremy Dunck wrote:
> On 9/7/05, Pedro Del Gallego <pedro.delgallego at gmail.com> wrote:
>> I need to create few scripts with similar feature. I like to reuse
>> several function, but i don't find how to call they after.
>> Has GM something like the include sentence in C?
>> It will be nice do if a could do :
>> include ( ./libraries/foo.user.js, myNameSpace)
> It doesn't.
> Feel free to add a request for an API:
Instead of a path, I'd suggest specifying the namespace and scriptname
or just a script name and assuming/requiring that it's in the same
namespace. Or, we could use the namespace as a base path. There's
nothing requiring that namespaces be URIs, much less URLs ("I hate
namespaces" is just as valid as "http://namespacehate.com/"). It seems
intuitive to support it, especially sine we use the URL to make the
default namespace and script name.
I've mentioned the m4 preprocessor. and mention it again. You'd write:
to include utils.js and then run m4 somescript.user.js and save the
output. Somthing like:
m4 someScript.user.js > someScript.dist.user.js
Still, people seem to want this in Greasemonkey itself and there was
never a decision that I recall. Implementing includes within
Greasemonkey shouldn't be hard anyway.
More information about the Greasemonkey