In the 0.9.18 release, Greasemonkey is now checking for, and installing, updated versions of user scripts by default. This post is intended as a primer for how this new functionality works, both for users and for script authors.
The Greasemonkey Options dialog now includes these settings to control automatic update checking and installation. By default updates will be checked for every seven days, and automatically installed when found. The download location must be secure (https) by default. And it should just work!
If you know there's an update, you can open the Add-ons manager, right click on a User Script, and choose "Find Updates". This will check immediately, even if a scheduled check has happened more recently than seven days ago.*
*You may need to clear your browser cache, if an old version of the script was downloaded recently.
Script Authors
Greasemonkey supports a number of new metadata directives to support updates: @downloadURL, @updateURL and (more than before) @version.
The @updateURL will be accessed when checking for the update. This can be a ".meta.js" format like userscripts.org produces, with only the metadata. The @version defined here will be checked to the install version. It does not need to be hosted on https to be checked by default.
Sidebar: for userscripts.org, the updateURL is automatically set to the .meta.js corresponding to the script, and passed through the Coral Content Distribution Network (see why).
The @downloadURL is where the update will be downloaded from, when found. This is most useful to guarantee that updates come from a secure (https) location, so that they will be installed by default.
If @updateURL or @downloadURL are not provided, the URL that the script was downloaded from is used instead. If the @downloadURL is not provided and the install URL is not known, updates will never be applied.
Finally the @version directive controls what is considered an update. Read about the (Mozilla) toolkit version format to learn exactly what value is greater than what, and what formats are valid.
It's also worth pointing out that the recently added GM_info API can be used to check if Greasemonkey will ever try to apply updates (e.g. because the user has turned it off, or the URL is insecure).
Finally, if you want to make sure that Greasemonkey will never update your script, it can be accomplished by providing an invalid @updateURL (like "about:blank") which will never return a newer version.
Questions?
Please bring any questions or comments to us at the greasemonkey-users discussion list.
Tuesday, February 28, 2012
Subscribe to:
Post Comments (Atom)
5 comments:
Fantastic, but I'm not sure I follow exactly; will previous installations from userscripts.org now automatically update or only those scripts installed since updating Greasemonkey?
Unfortunately, it's complicated. Most scripts should start updating automatically, regardless of where they were installed from.
If you'd like to be absolutely sure, then it's definitely true that scripts installed with Greasemonkey 0.9.18 or higher will update automatically.
But the secure (by default) requirement always applies, which will stop some/many/most scripts from updating at first, until they are set up to work with that.
You can try out this script I just threw together:
http://userscripts.org/scripts/show/127520
So that newly installed scripts (after that one) will be secure, and updatable.
Thanks, I think I follow all of that.
So, with require secure updates enabled, if a script was originally installed via HTTP I can reinstall it via HTTPS to make autoupdates kick in. Correct?
I'll try out the script you linked.
I have a script which is only used in-house and stored on a network drive.
How can I make it auto-update?
Set up an HTTP server with a certificate that Firefox will accept, serving files from that drive.
Post a Comment