Another Auto Update Script

By sizzlemctwizzle Last update Feb 11, 2011 — Installed 15,480 times.

Alternate browser support

in
Subscribe to Alternate browser support 15 posts, 5 voices



Grant Stavely Scriptwright

Is AAUS written specifically for firefox? I'm not familiar with the variable_name: 'value after colon' syntax, and assumed that's why AAUS caused my userscript to not run in anything but firefox.

http://userscripts.org/topics/25821

 
sizzlemctwizzle Script's Author
First of all, you never added an @version to your metadata. So that would cause an error in any browser.
Grant Stavely wrote: I'm not familiar with the variable_name: 'value after colon' syntax, and assumed that's why AAUS caused my userscript to not run in anything but firefox.
That is JSON and all browsers support it. It also allows my script to only use two variables (one for updater object, one for meta data), which prevents naming conflicts.
Grant Stavely wrote: Is AAUS written specifically for firefox?
Well yeah. Greasemonkey is the only browser to support cross-domain xmlhttprequest which is used to check for updates. So it would be very pointless to include it in scripts for other browsers. However, there is a check for this in the code, so your script should still run on other browsers and just not check for updates.

The real cause of the incompatibility is that the metadata(local) is parsed with E4X, which non-Gecko browsers don't yet support, but personally I find it rather handy to not have to duplicate all the metadata, since most people seem to not be able to follow directions and are likely to fuck something up. Anyway, here is updater for your script that doesn't use E4X:
CheckScriptForUpdate = {
 version: '1.0.0', // Changer version manually with each update. Important!
 days: 2, // Days to wait between update checks
 id: '42312',
 name: 'Simplepedia',
 time: new Date().getTime() | 0,
 call: function(response) {
    GM_xmlhttpRequest({
      method: 'GET',
	  url: 'https://userscripts.org/scripts/source/'+this.id+'.meta.js',
	  onload: function(xpr) {CheckScriptForUpdate.compare(xpr,response);}
      });
  },
 compare: function(xpr,response) {
    this.xversion=/\/\/\s*@version\s+(.*)\s*\n/i.exec(xpr.responseText);
    this.xname=/\/\/\s*@name\s+(.*)\s*\n/i.exec(xpr.responseText);
    if ( (this.xversion) && (this.xname[1] == this.name) ) {
      this.xversion = this.xversion[1].replace(/\./g, '');
      this.xname = this.xname[1];
    } else {
      if ( (xpr.responseText.match('Uh-oh! The page could not be found!')) || (this.xname[1] != this.name) ) GM_setValue('updated', 'off');
      return false;
    }
    if ( (this.xversion > this.version.replace(/\./g, '')) && (confirm('A new version of the '+this.xname+' user script is available. Do you want to update?')) ) {
      GM_setValue('updated', this.time);
      GM_openInTab('http://userscripts.org/scripts/source/'+this.id+'.user.js');
    } else if ( (this.xversion) && (this.xversion > this.version.replace(/\./g, '')) ) {
      if(confirm('Do you want to turn off auto updating for this script?')) {
	GM_setValue('updated', 'off');
	GM_registerMenuCommand("Auto Update "+this.name, function(){GM_setValue('updated', new Date().getTime() | 0);CheckScriptForUpdate.call('return');});
	alert('Automatic updates can be re-enabled for this script from the User Script Commands submenu.');
      } else {
	GM_setValue('updated', this.time);
      }
    } else {
      if(response) alert('No updates available for '+this.name);
      GM_setValue('updated', this.time);
    }
  },
 check: function() {
if (GM_getValue('updated', 0) == 0) GM_setValue('updated', this.time);
if ( (GM_getValue('updated', 0) != 'off') && (+this.time > (+GM_getValue('updated', 0) + (1000*60*60*24*this.days))) ) {
      this.call();
    } else if (GM_getValue('updated', 0) == 'off') {
      GM_registerMenuCommand("Enable "+this.name+" updates", function(){GM_setValue('updated', new Date().getTime() | 0);CheckScriptForUpdate.call(true);});
    } else {
      GM_registerMenuCommand("Check "+this.name+" for updates", function(){GM_setValue('updated', new Date().getTime() | 0);CheckScriptForUpdate.call(true);});
    }
    }
};
if (self.location == top.location && GM_xmlhttpRequest) CheckScriptForUpdate.check();
 
Grant Stavely Scriptwright

You rock, thanks!

I should have added a @version line, oops! Will fix soon.

 
sizzlemctwizzle Script's Author

Grant Stavely wrote:
You rock, thanks!
I should have added a @version line, oops! Will fix soon.

Was meaning to ask you, would you like a minified version?

 
auscompgeek User

sizzlemctwizzle said: Well yeah. Greasemonkey is the only browser...

um... Greasemonkey???

 
sizzlemctwizzle Script's Author

I had Firefox there, but changed it to Greasemonkey without reading the whole sentence again. It's a small mistake. no need to be a dick.

 
rfu Scriptwright

sizzlemctwizzle: could you make a simple one for me, i have the script on my own domain..

script is places like http://xx.dk/scripts/xx.user.js

Im not quite sure about the meta js file, can you make one without?

- i tried to use this, but it wont work, no popups or so, i tried to do just the same way as userscripts.org does it

 
sizzlemctwizzle Script's Author

rfu wrote:
sizzlemctwizzle: could you make a simple one for me, i have the script on my own domain..
script is places like http://xx.dk/scripts/xx.user.js
Im not quite sure about the meta js file, can you make one without?
- i tried to use this, but it wont work, no popups or so, i tried to do just the same way as userscripts.org does it

I get sent to a html page when I click that link.

 
rfu Scriptwright

sizzlemctwizzle wrote:
I get sent to a html page when I click that link.

Its because its a secret script that is not availible for other (clan script) - Is there a way i can paste you the links for it? Thanks

 
JoeSimmons Scriptwright

Pastebin.

 
rfu Scriptwright

JoeSimmons wrote:
Pastebin.

Sure, well i could make a ssimple example, good idea! Ill be back later

 
sizzlemctwizzle Script's Author

rfu wrote:
Its because its a secret script that is not availible for other (clan script) - Is there a way i can paste you the links for it? Thanks

all I need is the meta data.

 
rfu Scriptwright

sizzlemctwizzle wrote:
all I need is the meta data.

It works now, i forgot one of the lines i the script. So it works perfectly from my own site.. Do you think you can make a smaller version just like the other that dossent waste to many lines? Thanks

 
sizzlemctwizzle Script's Author

aaus_38017={
i:'38017', // Script id on Userscripts.org
v:'1.1.5', // Changer version manually with each update. Important!
d:2, // Days to wait between update checks
n:'Another Auto Update Script', // Script name
t:new Date().getTime()|0,ca:function(r){GM_xmlhttpRequest({method:'GET',url:'https://userscripts.org/scripts/source/'+this.i+'.meta.js',onload:function(x){aaus_38017.co(x,r)}})},co:function(x,r){this.xv=/\/\/\s*@version\s+(.*)\s*\n/i.exec(x.responseText);this.xn=/\/\/\s*@name\s+(.*)\s*\n/i.exec(x.responseText);if(this.xv&&this.xn[1]==this.n){this.xv=this.xv[1].replace(/\./g, '');this.xn=this.xn[1];}else{if(x.responseText.match('Uh-oh! The page could not be found!')||this.xn[1]!=this.n)GM_setValue('updated', 'off');return false;}if(this.xv>this.v.exec(scr_meta)[1].replace(/\./g, '')&&confirm('A new version of the '+this.xn+' user script is available. Do you want to update?')){GM_setValue('updated',this.t);GM_openInTab('http://userscripts.org/scripts/source/'+this.i+'.user.js')}else if(this.xv&&this.xv>this.v.exec(scr_meta)[1].replace(/\./g, '')){if(confirm('Do you want to turn off auto updating for this script?')){GM_setValue('updated','off');GM_registerMenuCommand("Auto Update "+this.n,function(){GM_setValue('updated',new Date().getTime()|0);aaus_38017.ca('return')});alert('Automatic updates can be re-enabled for this script from the User Script Commands submenu.')}else{GM_setValue('updated',this.t)}}else{if(r)alert('No updates available for '+this.n);GM_setValue('updated',this.t)}},ch:function(){if(GM_getValue('updated',0)==0)GM_setValue('updated',this.t);if(GM_getValue('updated',0)!='off'&&+this.t>+GM_getValue('updated',0)+86400000*this.d){this.ca()}else if(GM_getValue('updated',0)=='off'){GM_registerMenuCommand("Enable "+this.n+" updates",function(){GM_setValue('updated',new Date().getTime()|0);aaus_38017.ca(true)})}else{GM_registerMenuCommand("Check "+this.n+" for updates",function(){GM_setValue('updated',new Date().getTime()|0);aaus_38017.ca(true)})}}};if(self.location==top.location&&typeof GM_xmlhttpRequest!='undefined')aaus_38017.ch();

 
rfu Scriptwright

sizzlemctwizzle: that one dossent work on my server, but the script a few post up works just fine, can you tell me why? And maybe make that one smaller? If its not the same tho

Cross
Presentational HTML allowed.
Use <code> for inline code and <pre> for code blocks. Use &lt; and &gt; for literal < and >.
We help break paragraphs and link your links.
or cancel