[Greasemonkey] Long literal strings of html

Steve Krulewitz shooz at mm.st
Wed Apr 20 18:27:00 EDT 2005


> So it's just a matter of deciding:
> - if we want this kind of support for literal string in GM,

+1

> - what specific format to use (do we want to offer an escape sequence
> for /* and */ in the literal strings?).

So far we've seen two versions of this.  Edward's:

/*= <varname>
...
...
=*/

This implementation had one literal string per comment surrounded block.

The one I've been tinkering with:

/*
==String:<varname>==
...
...
==/String==

==String:<varname2>==
...
...
==/String==
*/

This allows for multiple literal strings per comment since the actual
delimiter here is the "==String:<varname==" stuff and not the comment
itself (although the delimiter should only be valid from within the
comment block).  I also tried to create something that followed the
existing "==UserScript==" token.

Any other ideas?

Whatever we chose, care will have to be taken to allow for the embedding
of the literal string delimiters as well as JavaScript comment tokens in
the text block.

Another possibility that we haven't talked about yet is using this to
embed images or other binary data.  We could allow for MIME encoding,
and perhaps make a gm_GetLiteralStringAsDataUrl(name) method?  It might
look like:

/*
==String:box_gradient2.gif==
Content-Type: image/gif; name="box_gradient2.gif"
Content-Transfer-Encoding: base64

R0lGODlhAQAmALMAAA97Dw5+Dg97EhJ2FxB4Eg+CDBGADhCFChCLBxGOBhKJCRKRBROXARST
AxSVAxKZACwAAAAAAQAmAEAEFHAc9x5I9RGjVq6EEBQHkjTMpz4RADs=
==/String==
*/

But this might be going a step too far...

-steve


More information about the Greasemonkey mailing list