فهرست منبع

Merge branch 'main' of https://github.com/Anarios/return-youtube-dislike

Dmitrii Selivanov 3 سال پیش
والد
کامیت
62759efb04
1فایلهای تغییر یافته به همراه10 افزوده شده و 1 حذف شده
  1. 10 1
      Extensions/UserScript/Return Youtube Dislike.user.js

+ 10 - 1
Extensions/UserScript/Return Youtube Dislike.user.js

@@ -28,7 +28,16 @@ function doXHR(opts) {
     return GM.xmlHttpRequest(opts);
   }
 
-  console.error('Unable to detect UserScript plugin.');
+  console.warn('Unable to detect UserScript plugin, falling back to native XHR.');
+
+  const xhr = new XMLHttpRequest();
+
+  xhr.open(opts.method, opts.url, true);
+  xhr.onload = () => opts.onload({
+    response: JSON.parse(xhr.responseText),
+  });
+  xhr.onerror = err => console.error('XHR Failed', err);
+  xhr.send();
 }
 
 function getButtons() {