9 points

@require updater for User Scripts: USO Updater.

Last update Nov 6, 2009
This is a work in progress... This notice will be removed when it has reached a certain standard.

Contents

1A - Welcome + Preface
1B - Why use @require?
2A - Documentation
2B - Some quick info
3A - @require URL API
3B - URL API: 'api'

1A - Welcome + Preface

Before I go any further, if you are up to it (it's a long topic), read this: http://userscripts.org/topics/29195

If you are a script developer here at Userscripts.org, you have probably come across the issue of updating, or the lack of it. Updating is probably one of the most important aspects of maintaining a Userscript, to make sure your users are always experiencing your work at its best. Unfortunately over all this time, Greasemonkey still hasn't integrated a solution into its own core to solve this problem, which leaves this task up to one of two people:
* The script developer
* Or the end user

The best method is letting the end user deal with it, with this Userscript ( Userscripts Updater ) in particular. But due to human nature itself, you are 99% guaranteed that your script users will not have a system in place to do this.

This means that currently the best method is in the hands of the script developer. There are many different snippets of code out there to help you achieve this, but I will focus on one me and others have recently developed. Which makes use of @require meta data.

1B - Why use @require?
Because it impacts your script the least, while providing the greatest amount of flexibility and maintaining a small footprint. For example:

// ==UserScript==
// @name           Download YouTube Captions
// @namespace      http://userscripts.org/users/tim
// @include        http://www.youtube.com/watch*
// @include        http://youtube.com/watch*
// @include        https://www.youtube.com/watch*
// @include        https://youtube.com/watch*
// @require        http://updater.usotools.co.cc/50003.js
// ==/UserScript==
The above is all you would need to do, to make sure the script with an id of 50003 was kept up-to-date amongst all your user base.

2A - Documentation

If the above example wasn't enough for you, then you probably will want to know some of the API's that exist in this updater, some example usage, where the source code lives and how to collaborate on this project. First we will start with a couple bulletpoints.

2B - Some quick info

  • Source code lives on Github. Check it out (hehe) at http://github.com/Tim-Smart/USO-Updater . Please do make a fork.
  • It can be run on any server with PHP5+ and MySQL.
  • Currently only compatible with the Greasemonkey Extension. Other platforms may be supported later...
  • Has both a API for the updater URL (String Query Parameters), and for Javascript. More info below.
  • Was made with the help of many friends. See section {insert section here} for known collaborators, and the Github project page for anyone I have missed http://github.com/Tim-Smart/USO-Updater

3A - @require URL API

Right, so the URL parameters that you pass to the PHP script, changes the output Javascript depending on the values. Simply put, the stuff after the ? at the end of the URL. E.g.

?api=true&interval=7
Will pass the variable api as true and so on.

1B - URL API: 'api'
Example Usage:

?api=true
http://domain.com/path/to/12345.js?api=true
Default:
?api=false
I.e. disabled

Description:
This URL Parameter (SQP or String-Query-Parameter) specifies whether the Javascript API will be enabled or disabled in the output Javascript Source.

To enable the Javascript API, you can specify the api parameter as 1 or true. Any other value, or leaving it unset, will use the default value.

Scripts mentioned in guide