mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-09 13:07:05 +03:00
add custom server address
This commit is contained in:
@@ -213,6 +213,15 @@
|
|||||||
"whatDeleteButton": {
|
"whatDeleteButton": {
|
||||||
"message": "This is the button that allows you to clear all sponsors on the YouTube player."
|
"message": "This is the button that allows you to clear all sponsors on the YouTube player."
|
||||||
},
|
},
|
||||||
|
"customServerAddress": {
|
||||||
|
"message": "SponsorBlock Server Address"
|
||||||
|
},
|
||||||
|
"customServerAddressDescription": {
|
||||||
|
"message": "The address SponsorBlock uses to make calls to the server.\nIt must be formatted https://domain with no trailing forward slash (/).\nUnless you have your own server instance this should not be changed."
|
||||||
|
},
|
||||||
|
"saveCustomServerAddress": {
|
||||||
|
"message": "Save"
|
||||||
|
},
|
||||||
"disableViewTracking": {
|
"disableViewTracking": {
|
||||||
"message": "Disable Sponsor Skip Count Tracking"
|
"message": "Disable Sponsor Skip Count Tracking"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -76,6 +76,11 @@ body {
|
|||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.string-container {
|
||||||
|
font-size: 14px;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
.switch {
|
.switch {
|
||||||
position: relative;
|
position: relative;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
|||||||
@@ -94,6 +94,25 @@
|
|||||||
<br/>
|
<br/>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
|
<div option-type="string-change" sync-option="customServerAddress">
|
||||||
|
<label class="string-container">
|
||||||
|
<div>__MSG_customServerAddress__</div>
|
||||||
|
<input class="option-text-box" type="text">
|
||||||
|
</label>
|
||||||
|
<div class="option-button custom-server-address-button inline">
|
||||||
|
__MSG_saveCustomServerAddress__
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
<div class="small-description">__MSG_customServerAddressDescription__</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
|
||||||
<div option-type="keybind-change" sync-option="startSponsorKeybind">
|
<div option-type="keybind-change" sync-option="startSponsorKeybind">
|
||||||
<div class="option-button trigger-button">
|
<div class="option-button trigger-button">
|
||||||
__MSG_setStartSponsorShortcut__
|
__MSG_setStartSponsorShortcut__
|
||||||
|
|||||||
@@ -19,7 +19,8 @@ interface SBConfig {
|
|||||||
invidiousInstances: string[],
|
invidiousInstances: string[],
|
||||||
invidiousUpdateInfoShowCount: number,
|
invidiousUpdateInfoShowCount: number,
|
||||||
autoUpvote: boolean,
|
autoUpvote: boolean,
|
||||||
supportInvidious: false
|
supportInvidious: false,
|
||||||
|
customServerAddress: string
|
||||||
}
|
}
|
||||||
|
|
||||||
interface SBObject {
|
interface SBObject {
|
||||||
@@ -111,7 +112,8 @@ var Config: SBObject = {
|
|||||||
invidiousInstances: ["invidio.us", "invidiou.sh", "invidious.snopyta.org"],
|
invidiousInstances: ["invidio.us", "invidiou.sh", "invidious.snopyta.org"],
|
||||||
invidiousUpdateInfoShowCount: 0,
|
invidiousUpdateInfoShowCount: 0,
|
||||||
autoUpvote: true,
|
autoUpvote: true,
|
||||||
supportInvidious: false
|
supportInvidious: false,
|
||||||
|
customServerAddress: null
|
||||||
},
|
},
|
||||||
localConfig: null,
|
localConfig: null,
|
||||||
config: null
|
config: null
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
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();
|
||||||
@@ -65,6 +66,23 @@ async function init() {
|
|||||||
invidiousInstanceAddInit(<HTMLElement> optionsElements[i], textChangeOption);
|
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;
|
break;
|
||||||
case "keybind-change":
|
case "keybind-change":
|
||||||
let keybindButton = optionsElements[i].querySelector(".trigger-button");
|
let keybindButton = optionsElements[i].querySelector(".trigger-button");
|
||||||
@@ -80,6 +98,18 @@ async function init() {
|
|||||||
optionsContainer.classList.add("animated");
|
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
|
* Called when the config is updated
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -240,7 +240,9 @@ 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();
|
||||||
|
|
||||||
xmlhttp.open(type, CompileConfig.serverAddress + address, true);
|
let serverAddress = (Config.config.customServerAddress) ? Config.config.customServerAddress : CompileConfig.serverAddress;
|
||||||
|
|
||||||
|
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