mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2026-01-28 05:10:50 +03:00
Moved server code to utils
This commit is contained in:
20
src/utils.ts
20
src/utils.ts
@@ -1,3 +1,4 @@
|
||||
import * as CompileConfig from "../config.json";
|
||||
import SB from "./SB";
|
||||
|
||||
class Utils {
|
||||
@@ -268,6 +269,25 @@ class Utils {
|
||||
return errorMessage;
|
||||
}
|
||||
|
||||
static sendRequestToServer(type, address, callback) {
|
||||
let xmlhttp = new XMLHttpRequest();
|
||||
|
||||
xmlhttp.open(type, CompileConfig.serverAddress + address, true);
|
||||
|
||||
if (callback != undefined) {
|
||||
xmlhttp.onreadystatechange = function () {
|
||||
callback(xmlhttp, false);
|
||||
};
|
||||
|
||||
xmlhttp.onerror = function(ev) {
|
||||
callback(xmlhttp, true);
|
||||
};
|
||||
}
|
||||
|
||||
//submit this request
|
||||
xmlhttp.send();
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this Firefox (web-extensions)
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user