[Greasemonkey] Long literal strings of html

Steve Krulewitz shooz at mm.st
Wed Apr 13 12:54:27 EDT 2005

Julien Couvreur wrote:
> Question: is there any similar trick in javascript that would allow
> putting long strings without having to care about escaping them?

One trick I used to use with Microsoft's implementation of JavaScript is 
using a function as a container for a block of text.  The block of text 
would be hidden in a comment, and when accessing the function name as a 
variable the source of the function (including comment) will be 
returned.  Something like:

function data() {
Long block
of text goes

Then by doing the proper data.substring() the text in the comment could 
be extracted.  However, this does not seem to work in mozilla -- the 
source is returned sans comments.

Maybe GM could pre-process the user scripts and find delimited blocks of 
text that could be made accessible via some GM_* methods.  However, this 
might be overkill for user scripts...


More information about the Greasemonkey mailing list