[Greasemonkey] Example user script GUI

Julien Couvreur julien.couvreur at gmail.com
Wed Apr 20 15:00:17 EDT 2005


On 4/20/05, Mark Pilgrim <pilgrim at gmail.com> wrote:
> You'll need to set document.body.innerHTML
> = 'FULL_HTML_BODY', document.title = 'NEW_TITLE', (...)
> Of course, the server will be registering 404s
> on that page (...)

Assuming GM goes ahead to support literal strings, here's a really
simple (and simpler) solution:
1) Put your help page in a literal string (called "HelpPage").
2) Write the link to the help page, but set the onclick for the link
to open a "data:" url. That url would encode the whole page, contained
in the literal string.
3) Here's the onclick code (assuming GM_getLiteralString existed):
onclick='document.location.href =
"data:text/javascript;charset=utf-8," +
encodeURI(GM_getLiteralString("HelpPage"));'

Voila!
No 404, little javascript (see code above), little mess
The url for the Help page will look weird, like any data: url. One way
around that is to use an about:something url (like Prakash mentions).

Cheers,
Julien


More information about the Greasemonkey mailing list