Browse Source

optimized auto-update mechanism, fixed #8

Gerald 11 years ago
parent
commit
3101f2d501
2 changed files with 7 additions and 5 deletions
  1. 4 4
      background.js
  2. 3 1
      options.js

+ 4 - 4
background.js

@@ -420,10 +420,9 @@ function checkUpdateO(o) {
 	function finish(){delete _update[o.id];}
   var r={id:o.id,updating:1,status:2};
   function update() {
-    var u=o.custom.downloadURL||o.meta.downloadURL;
-    if(u) {
+    if(du) {
       r.message=_('msgUpdating');
-      fetchURL(u,function(){
+      fetchURL(du,function(){
         parseScript({
 					id: o.id,
           status: this.status,
@@ -433,7 +432,8 @@ function checkUpdateO(o) {
     } else r.message='<span class=new>'+_('msgNewVersion')+'</span>';
     updateItem(r);finish();
   }
-  var u=o.custom.updateURL||o.meta.updateURL;
+	var du=o.custom.downloadURL||o.meta.downloadURL,
+			u=o.custom.updateURL||o.meta.updateURL||du;
   if(u) {
     r.message=_('msgCheckingForUpdate');updateItem(r);
     fetchURL(u,function() {

+ 3 - 1
options.js

@@ -8,7 +8,9 @@ function getName(d,n,def){
 }
 
 // Main options
-function allowUpdate(n){return n.update&&(n.custom.updateURL||n.meta.updateURL);}
+function allowUpdate(n){
+	return n.update&&(n.custom.updateURL||n.meta.updateURL||n.custom.downloadURL||n.meta.downloadURL);
+}
 function setIcon(n,d){
 	d.src=cache[n.meta.icon]||'images/icon48.png';
 }