mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-08 12:37:05 +03:00
add custom server address
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import Config from "./config";
|
||||
import * as CompileConfig from "../config.json";
|
||||
|
||||
import Utils from "./utils";
|
||||
var utils = new Utils();
|
||||
@@ -65,6 +66,23 @@ async function init() {
|
||||
invidiousInstanceAddInit(<HTMLElement> optionsElements[i], textChangeOption);
|
||||
}
|
||||
|
||||
break;
|
||||
case "string-change":
|
||||
let stringChangeOption = optionsElements[i].getAttribute("sync-option");
|
||||
let stringInput = <HTMLInputElement> optionsElements[i].querySelector(".string-container").querySelector(".option-text-box");
|
||||
let saveButton = <HTMLElement> optionsElements[i].querySelector(".option-button");
|
||||
|
||||
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", () => {
|
||||
setStringConfigOption(stringInput.value, stringChangeOption);
|
||||
});
|
||||
|
||||
break;
|
||||
case "keybind-change":
|
||||
let keybindButton = optionsElements[i].querySelector(".trigger-button");
|
||||
@@ -80,6 +98,18 @@ async function init() {
|
||||
optionsContainer.classList.add("animated");
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value in the string input the the defined config option
|
||||
*
|
||||
* @param element
|
||||
* @param option
|
||||
*/
|
||||
function setStringConfigOption(value: string, option: string) {
|
||||
console.log(value);
|
||||
console.log(option);
|
||||
Config.config[option] = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the config is updated
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user