Add native XMLHttpRequest in case all else fails

This commit is contained in:
Dave Shoreman
2021-11-21 13:20:53 +00:00
parent ddc36d8c01
commit 7d80643bfe
@@ -29,7 +29,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() {