[Greasemonkey] Long literal strings of html

Edward Lee edilee at gmail.com
Wed Apr 20 18:59:30 EDT 2005

On 4/20/05, Aaron Boodman <zboogs at gmail.com> wrote:
> The percolation sorta ended with "this is a huge hack, and it's not a
> big need (for me)". But if you guys really really want it, submit a
> patch. As long as it doesn't break something, it can go in.

Would the "getself" version not be as much of a hack? I agree that
parsing for special comments is a big hack, but providing the script
its own code isn't really a hack in itself but allows the hacks to be
more easily implemented in user scripts.

var scriptContents = getContents(getScriptChrome(script.filename));

... runBrowserScript(...
var GM_log..
var GM_getSelf = (function(contents) { return function() { return
contents; }; }) (scriptContents.replace(/\r/g, "\\r").replace(/\n/g,
"\\n").replace(/('|")/g, '\\$1') + "\""));

I modified that from what I implemented for my own GM_getString(). Do
other things need to be escaped? Also the function stuff just puts the
contents variable somewhere instead of creating it each time getself
is called.


More information about the Greasemonkey mailing list