Переглянути джерело

added header for checking updates (Accept: text/x-userscript-meta), fixed #2

Gerald 11 роки тому
батько
коміт
5817388f1f
2 змінених файлів з 8 додано та 6 видалено
  1. 7 5
      background.js
  2. 1 1
      manifest.json

+ 7 - 5
background.js

@@ -266,11 +266,13 @@ function getInjected(url,src,callback) {	// for injected
 	var data={scripts:[],require:{},cache:{},values:{}},cache=[],values=[],require=[];
 	if(data.isApplied=settings.isApplied) getScripts(); else finish();
 }
-function fetchURL(url, cb, type) {
-  var req = new XMLHttpRequest();
+function fetchURL(url, cb, type, headers) {
+  var req=new XMLHttpRequest(),i;
   req.open('GET', url, true);
-  if (type) req.responseType = type;
-  if (cb) req.onloadend = cb;
+  if(type) req.responseType = type;
+	if(headers) for(i in headers)
+		req.setRequestHeader(i,headers[i]);
+  if(cb) req.onloadend = cb;
   req.send();
 }
 var _cache={},_require={};
@@ -444,7 +446,7 @@ function checkUpdateO(o) {
       } catch(e){}
       delete r.hideUpdate;
       updateItem(r);finish();
-    });
+    },null,{Accept:'text/x-userscript-meta'});
   } else finish();
 }
 function checkUpdate(id,src,callback) {

+ 1 - 1
manifest.json

@@ -1,6 +1,6 @@
 {
 	"name": "Violent monkey",
-	"version" : "2.0.0.8",
+	"version" : "2.0.1",
 	"manifest_version" : 2,
 	"description" : "__MSG_extDescription__",
 	"developer": {"name" : "Gerald", "url" : "http://geraldl.tk"},