predict wss url

master
and94x 2 years ago
parent 721324c697
commit 04948e24f9

@ -55,7 +55,7 @@ function save() {
// Restores select box and checkbox state using the preferences // Restores select box and checkbox state using the preferences
// stored in chrome.storage. // stored in chrome.storage.
function load() { function load(){
if (chrome && chrome.storage && chrome.storage.local) { if (chrome && chrome.storage && chrome.storage.local) {
chrome.storage.local.get({ chrome.storage.local.get({
baseURL: getMessage("settingsFormInputRequired"), baseURL: getMessage("settingsFormInputRequired"),
@ -69,5 +69,23 @@ function load() {
} }
} }
document.addEventListener('DOMContentLoaded', load); function autofillWSSURL() {
saveButton.addEventListener('click', validateAndSave); 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();
}
Loading…
Cancel
Save