predict wss url

This commit is contained in:
and94x 2022-08-17 20:50:55 +02:00
parent 721324c697
commit 04948e24f9

View File

@ -55,7 +55,7 @@ function save() {
// Restores select box and checkbox state using the preferences
// stored in chrome.storage.
function load() {
function load(){
if (chrome && chrome.storage && chrome.storage.local) {
chrome.storage.local.get({
baseURL: getMessage("settingsFormInputRequired"),
@ -69,5 +69,23 @@ function load() {
}
}
document.addEventListener('DOMContentLoaded', load);
saveButton.addEventListener('click', validateAndSave);
function autofillWSSURL() {
console.log('here am i');
if (stammTVBaseUrl.value.startsWith('http')) {
let predictedWSSURL = stammTVBaseUrl.value.replace('https', 'wss').replace('http', 'wss');
if (predictedWSSURL.endsWith('/')) {
predictedWSSURL += 'wss'
} else {
predictedWSSURL += '/wss'
}
stammTVWSSUrl.value = predictedWSSURL;
}
}
document.addEventListener('DOMContentLoaded', init);
function init() {
stammTVBaseUrl.onchange = autofillWSSURL;
saveButton.addEventListener('click', validateAndSave);
load();
}