See Thumbnails for WOT pixel images. See SVG for SVG images

Scorecard Mock-Up

WOT Home
Client WOT non officiel pour Opera

Note globale: 100%

Fiabilité générale

Fiabilité commerciale


Contenu explicite

Check for UpdateCheck for Update Rate évaluer

Updater problem, some thoughts

Live example. Click "reload" between 10 and 50 times ;)

How about creating a variable, that contains the creation Time of the UserJS + some days in milliseconds since 01.01.1970, 0:00:00 UTC.

<script type="text/javascript">/* <![CDATA[ */
	var wotscriptexpires = Date.parse("Fri, 29 Jan 2010 00:01:00 GMT");

The result is:

Then you parse the actual Time when the script runs.

	var actualwot = new Date();
	actualwot = Date.parse(Date());

The result is:

Now you can subtract both numbers, and if the result is greater than 0 (Zero), check for updates, but only when a modulo of the result is smaller than a specific number. A little added random can keep the load per hour small enough, but I think the average server should be able to handle 10000 requests/minute ;)

	var check = actualwot - wotscriptexpires;
	if (check > 0) {
		/* = Seconds ;) */
		check = check / 1000; 
		/* Returns periodic 0 to 10 and adds a random number from 0 to 29 ;)  */
		check = (check % 10) + Math.floor(Math.random()*30); 
		if (check < 4) { 
			alert('update'); /* here goes the updater code */
/* ]]> */</script>

This way, the script checks periodically during small periods after the expiration. The random number avoids that all users check at the same time.

You can set a higher number for % 10 or 30 to check less frequently and a higher number for 4 to check more often ;)