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.