Script Summary: CheckForUpdate function. This script doesn't do anything except keep itself updated.
Version: 2.0.3.0
Copyright: w35l3y 2008
License: GNU GPL
This script was discontinued!
New version : http://userscripts.org/scripts/show/87942
* Tested in Firefox 3.0.5 with Greasemonkey 0.8.20080609.0 *
Understanding
Firstly, you should understand the CFU headers:
@cfu:url (required) -> url that should be opened when there is a new update Examples: // @cfu:url http://userscripts.org/scripts/source/38788.user.js // @cfu:url http://userscripts.org/scripts/source/@cfu:id.user.js // @cfu:url http://gm.wesley.eti.br/includes/checkforupdate.user.js
@cfu:version (required *) -> current version or the header that contains that value Examples: // @cfu:version 1.0.0 // @cfu:version uso:version (@uso:version should be set, otherwise "uso:version" will be considered the current version)
@cfu:timestamp (required *) -> last updated time or the header that contains that value Examples: // @cfu:timestamp 20:10 12/16/2008 (this will be parsed with Date.parse(...)) // @cfu:timestamp uso:timestamp (@uso:timestamp should be set, otherwise "uso:timestamp" will be considered the last updated time)
@cfu:meta (optional **/***) - default = @cfu:url -> url that contains the metadata of the script Examples: // @cfu:meta http://userscripts.org/scripts/source/38788.meta.js (metadata) // @cfu:meta http://userscripts.org/scripts/source/@cfu:id.meta.js (metadata) // @cfu:meta http://userscripts.org/scripts/review/@cfu:id?format=text (full source)
@cfu:id (optional) -> id of the script or the header that contains that value Examples: // @cfu:id 38788 // @cfu:id shortName // @cfu:id uso:script (@uso:script should be set, otherwise "uso:script" will be considered the id of the script)
@cfu:interval (optional) - default = 1 week -> interval for checking new updates Examples: // @cfu:interval 4 days // @cfu:interval 2 weeks 1 hour
@cfu:changelog (optional ***)
-> name or implementation of the function that parses the changelog
Examples:
// @cfu:changelog (function(o, n, t){return n['versiontext'].join('\n');})
// @cfu:changelog changeLog
function changeLog(o, n, t)
{
return t.match(/(Change Log:[^]+?)(?:\n{2}|<\/>)/)[1];
}
---
* only one of them is required.
** if you don't specify any @cfu:meta, @cfu:url will be used.
*** if you are using @cfu:changelog, you shouldn't use @cfu:meta. unless you are using it to retrieve the full source of the script.
"@cfu:id" can be used in the urls (@cfu:url or @cfu:meta)
Implementing
Secondly, you need to choose between adding the header:
// @require http://userscripts.org/scripts/source/38788.user.js
OR
copying and pasting the CheckForUpdate into your script.
Be careful that you MUST NOT copy the entire code.
Full examples
"Minimum"CheckForUpdate.init(<> // ==UserScript== // @name Test : Example // @namespace http://gm.wesley.eti.br/test // @description This is just a test // @include nowhere // @require http://userscripts.org/scripts/source/38788.user.js // @cfu:url http://userscripts.org/scripts/source/yyyyy.user.js // @cfu:version 3.0.17.152 // ==/UserScript== </>); // ... your script goes here"Maximum"
// the code of the CheckForUpdate goes here (BEFORE THE GM HEADER)
CheckForUpdate.init(<>
// ==UserScript==
// @name Test : Example
// @namespace http://gm.wesley.eti.br/test
// @description This is just a test
// @include nowhere
// @cfu:meta http://userscripts.org/scripts/review/@cfu:id.meta.js
// @cfu:meta http://userscripts.org/scripts/review/@cfu:id?format=text
// @cfu:url http://userscripts.org/scripts/source/@cfu:id.user.js
// @cfu:id uso:script
// @cfu:version uso:version
// @cfu:interval 1 week
// @cfu:changelog (function(o, n, t){return n['versiontext'].join('\n');})
// @versiontext This is the change log 1
// @versiontext This is the change log 2
// @versiontext This is the change log 3
// @uso:script yyyyy
// @uso:version 3.0.17.152
// ==/UserScript==
</>);
// ... your script goes here


