|
Script Summary:
Include the code in your user scripts so they check for updates automatically Version: 1.1.9 |
this script has 10 topics, 82 posts |
this script has 4 reviews |
||||||||||||||||||||||||||||
What does it do?
This script does nothing but keep itself up-to-date. You must include this code in any script that you want to auto update. Just modify the first couple lines according to your script. The code is self-contained so there should be no conflict with the variable names used by your script.Update: My updater can now be used as an @require. Instructions can be found here.
How to use?
- Surround your Userscript meta header like this:
scr_meta=<><![CDATA[ // Make sure to copy this line right above the script metadata // ==UserScript== // @name Another Auto Update Script // @namespace sizzlemctwizzle // @description Include the code in your user scripts so they check for updates automatically // @version 1.1.7 // @include * // ==/UserScript== ]]></>.toString(); // Make sure to copy this line right below
- Somewhere in your script(probably at the bottom) paste this code:
CheckScriptForUpdate = { // Config values, change these to match your script id: '38017', // Script id on Userscripts.org days: 2, // Days to wait between update checks - Change the id value to the id of your script on Userscripts.org
- Either keep the days value to check for updates every two days or change it to something else.
- Paste the following code right beneath the previous:
// Don't edit after this line, unless you know what you're doing ;-) name: /\/\/\s*@name\s+(.*)\s*\n/i.exec(scr_meta)[1], version: /\/\/\s*@version\s+(.*)\s*\n/i.exec(scr_meta)[1].replace(/\./g, ''), time: new Date().getTime(), call: function(response) { GM_xmlhttpRequest({ method: 'GET', url: 'https://userscripts.org/scripts/source/'+this.id+'.meta.js', onload: function(xpr) {AnotherAutoUpdater.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("the page you requested doesn't exist")) || (this.xname[1] != this.name) ) GM_setValue('updated_'+this.id, 'off'); return false; } if ( (+this.xversion > +this.version) && (confirm('A new version of the '+this.xname+' user script is available. Do you want to update?')) ) { GM_setValue('updated_'+this.id, this.time+''); top.location.href = 'https://userscripts.org/scripts/source/'+this.id+'.user.js'; } else if ( (this.xversion) && (+this.xversion > +this.version) ) { if(confirm('Do you want to turn off auto updating for this script?')) { GM_setValue('updated_'+this.id, 'off'); GM_registerMenuCommand("Auto Update "+this.name, function(){GM_setValue('updated_'+this.id, new Date().getTime()+''); AnotherAutoUpdater.call(true);}); alert('Automatic updates can be re-enabled for this script from the User Script Commands submenu.'); } else { GM_setValue('updated_'+this.id, this.time+''); } } else { if(response) alert('No updates available for '+this.name); GM_setValue('updated_'+this.id, this.time+''); } }, check: function() { if (GM_getValue('updated_'+this.id, 0) == 0) GM_setValue('updated_'+this.id, this.time+''); if ( (GM_getValue('updated_'+this.id, 0) != 'off') && (+this.time > (+GM_getValue('updated_'+this.id, 0) + (1000*60*60*24*this.days))) ) { this.call(); } else if (GM_getValue('updated_'+this.id, 0) == 'off') { GM_registerMenuCommand("Enable "+this.name+" updates", function(){GM_setValue('updated_'+this.id, new Date().getTime()+'');AnotherAutoUpdater.call(true);}); } else { GM_registerMenuCommand("Check "+this.name+" for updates", function(){GM_setValue('updated_'+this.id, new Date().getTime()+'');AnotherAutoUpdater.call(true);}); } } }; if (self.location == top.location && typeof GM_xmlhttpRequest != 'undefined') AnotherAutoUpdater.check(); - Install this script so you can be notified of when I make a change to the auto-update code.
Make a Donation via Paypal
I'm a college student, so that equates to not having much time or money, but I still find the time to work on my user scripts. I put a lot of time and effort into my scripts so if you find this script useful, please consider making a donation.





