On Thu, Oct 8, 2009 at 3:11 PM, Anthony Lieuallen <[email protected]>wrote:

>
> On 10/07/09 18:11, clemenss wrote:
> > ... If I download the file, edit it, remove some lines and then
> > launch it, I have some hotkeys enabled.
>
> Greasemonkey can neither download nor edit the contents of a file.
>

I am using a little trick to achieve this kind of thing. I have a script
that adds auto-update functionality to userscripts hosted at userscripts.org.
What the script does is the following:

1) It removes the href attribute of the link, and it prevents the default
action (following the link)
2) It adds an onclick listener
3) When the user clicks on the link, the listener is called. It downloads
the script via XmlHttpRequest.
4) In the handler, I am modifying the script code to add the auto-update
functionality (it is actually a check for updates, not an autoupdate)
5) Finally, also from within the handler, I launch a new tab (or change
location.href) with the modified code by using a data: pseudo-protocol.

This kind of thing works because the installation dialogue is triggered by
the file extension ".user.js" and not by a content type.  However, if I
recall correctly, you can also cheat with the content type in the "data:"
url to some extent (I wrotea tiny script time ago to force streaming of
certain music files instead of the default dowload action; the trick was to
put the content type in a data url, but I don't remember the details right
now)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"greasemonkey-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/greasemonkey-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to