mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-07 03:57:09 +03:00
Change the way server address defaults are handled.
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
import * as CompileConfig from "../config.json";
|
||||||
|
|
||||||
interface SBConfig {
|
interface SBConfig {
|
||||||
userID: string,
|
userID: string,
|
||||||
sponsorTimes: SBMap<string, any>,
|
sponsorTimes: SBMap<string, any>,
|
||||||
@@ -20,7 +22,7 @@ interface SBConfig {
|
|||||||
invidiousUpdateInfoShowCount: number,
|
invidiousUpdateInfoShowCount: number,
|
||||||
autoUpvote: boolean,
|
autoUpvote: boolean,
|
||||||
supportInvidious: false,
|
supportInvidious: false,
|
||||||
customServerAddress: string,
|
serverAddress: string,
|
||||||
minDuration: number
|
minDuration: number
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,7 +116,7 @@ var Config: SBObject = {
|
|||||||
invidiousUpdateInfoShowCount: 0,
|
invidiousUpdateInfoShowCount: 0,
|
||||||
autoUpvote: true,
|
autoUpvote: true,
|
||||||
supportInvidious: false,
|
supportInvidious: false,
|
||||||
customServerAddress: null,
|
serverAddress: CompileConfig.serverAddress,
|
||||||
minDuration: 0
|
minDuration: 0
|
||||||
},
|
},
|
||||||
localConfig: null,
|
localConfig: null,
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import Config from "./config";
|
import Config from "./config";
|
||||||
import * as CompileConfig from "../config.json";
|
|
||||||
|
|
||||||
import Utils from "./utils";
|
import Utils from "./utils";
|
||||||
var utils = new Utils();
|
var utils = new Utils();
|
||||||
@@ -73,11 +72,6 @@ async function init() {
|
|||||||
let saveButton = <HTMLElement> optionsElements[i].querySelector(".option-button");
|
let saveButton = <HTMLElement> optionsElements[i].querySelector(".option-button");
|
||||||
|
|
||||||
stringInput.value = Config.config[stringChangeOption];
|
stringInput.value = Config.config[stringChangeOption];
|
||||||
// Devs can use config.json to set server address
|
|
||||||
if (stringChangeOption === "customServerAddress") {
|
|
||||||
stringInput.value = (Config.config.customServerAddress) ? Config.config.customServerAddress : CompileConfig.serverAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
saveButton.addEventListener("click", () => {
|
saveButton.addEventListener("click", () => {
|
||||||
setStringConfigOption(stringInput.value, stringChangeOption);
|
setStringConfigOption(stringInput.value, stringChangeOption);
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import * as CompileConfig from "../config.json";
|
|
||||||
import Config from "./config";
|
import Config from "./config";
|
||||||
|
|
||||||
class Utils {
|
class Utils {
|
||||||
@@ -240,9 +239,7 @@ class Utils {
|
|||||||
sendRequestToServer(type: string, address: string, callback?: (xmlhttp: XMLHttpRequest, err: boolean) => any) {
|
sendRequestToServer(type: string, address: string, callback?: (xmlhttp: XMLHttpRequest, err: boolean) => any) {
|
||||||
let xmlhttp = new XMLHttpRequest();
|
let xmlhttp = new XMLHttpRequest();
|
||||||
|
|
||||||
let serverAddress = (Config.config.customServerAddress) ? Config.config.customServerAddress : CompileConfig.serverAddress;
|
xmlhttp.open(type, Config.config.serverAddress + address, true);
|
||||||
|
|
||||||
xmlhttp.open(type, serverAddress + address, true);
|
|
||||||
|
|
||||||
if (callback != undefined) {
|
if (callback != undefined) {
|
||||||
xmlhttp.onreadystatechange = function () {
|
xmlhttp.onreadystatechange = function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user