Cleaning code and changing naming schemes
This commit is contained in:
parent
8c1f38460b
commit
fbdfe07425
|
@ -8,6 +8,7 @@ function addHttps(instances) {
|
|||
}
|
||||
|
||||
function getRandomInstance(instances) {
|
||||
console.info(instances.length * Math.random(), "=>", instances.length * Math.random())
|
||||
return instances[~~(instances.length * Math.random())];
|
||||
}
|
||||
|
||||
|
@ -19,11 +20,11 @@ function getInstances() {
|
|||
|
||||
if (request.status === 200) {
|
||||
const instances = JSON.parse(request.responseText);
|
||||
const nitterRandomPool = addHttps(filterInstances(instances.nitter)).join(',');
|
||||
const invidiousRandomPool = addHttps(filterInstances(instances.invidious)).join(',');
|
||||
const bibliogramRandomPool = addHttps(filterInstances(instances.bibliogram)).join(',');
|
||||
const wikilessRandomPool = addHttps(filterInstances(instances.wikiless)).join(',')
|
||||
const scribeRandomPool = addHttps(filterInstances(instances.scribe)).join(',')
|
||||
const nitterRandomPool = addHttps(filterInstances(instances.nitter));
|
||||
const invidiousRandomPool = addHttps(filterInstances(instances.invidious));
|
||||
const bibliogramRandomPool = addHttps(filterInstances(instances.bibliogram));
|
||||
const wikilessRandomPool = addHttps(filterInstances(instances.wikiless));
|
||||
const scribeRandomPool = addHttps(filterInstances(instances.scribe));
|
||||
browser.storage.sync.set({
|
||||
nitterRandomPool,
|
||||
invidiousRandomPool,
|
||||
|
|
|
@ -157,7 +157,7 @@ browser.storage.sync.get(
|
|||
useFreeTube = result.useFreeTube;
|
||||
invidiousRandomPool =
|
||||
result.invidiousRandomPool
|
||||
? result.invidiousRandomPool.split(",")
|
||||
? result.invidiousRandomPool
|
||||
: commonHelper.filterInstances(invidiousInstances);
|
||||
|
||||
nitterInstance = result.nitterInstance;
|
||||
|
@ -186,108 +186,107 @@ browser.storage.sync.get(
|
|||
);
|
||||
|
||||
browser.storage.onChanged.addListener((changes) => {
|
||||
if ("nitterInstance" in changes) {
|
||||
if ("nitterInstance" in changes)
|
||||
nitterInstance = changes.nitterInstance.newValue;
|
||||
}
|
||||
if ("invidiousInstance" in changes) {
|
||||
|
||||
if ("invidiousInstance" in changes)
|
||||
invidiousInstance = changes.invidiousInstance.newValue;
|
||||
}
|
||||
if ("bibliogramInstance" in changes) {
|
||||
|
||||
if ("bibliogramInstance" in changes)
|
||||
bibliogramInstance = changes.bibliogramInstance.newValue;
|
||||
}
|
||||
if ("osmInstance" in changes) {
|
||||
|
||||
if ("osmInstance" in changes)
|
||||
osmInstance = changes.osmInstance.newValue || osmDefault;
|
||||
}
|
||||
if ("simplyTranslateInstance" in changes) {
|
||||
simplyTranslateInstance =
|
||||
changes.simplyTranslateInstance.newValue || simplyTranslateDefault;
|
||||
}
|
||||
if ("wikipediaInstance" in changes) {
|
||||
|
||||
if ("simplyTranslateInstance" in changes)
|
||||
simplyTranslateInstance = changes.simplyTranslateInstance.newValue || simplyTranslateDefault;
|
||||
|
||||
if ("wikipediaInstance" in changes)
|
||||
wikipediaInstance = changes.wikipediaInstance.newValue || wikipediaDefault;
|
||||
}
|
||||
if ("redditInstance" in changes) {
|
||||
|
||||
if ("redditInstance" in changes)
|
||||
redditInstance = changes.redditInstance.newValue || redditDefault;
|
||||
}
|
||||
|
||||
if ("redditFrontend" in changes)
|
||||
redditFrontend = changes.redditFrontend.newValue
|
||||
|
||||
if ("scribeInstance" in changes) {
|
||||
if ("scribeInstance" in changes)
|
||||
scribeInstance = changes.scribeInstance.newValue || scribeDefault;
|
||||
}
|
||||
if ("searchEngineInstance" in changes) {
|
||||
|
||||
if ("searchEngineInstance" in changes)
|
||||
searchEngineInstance = changes.searchEngineInstance.newValue;
|
||||
}
|
||||
if ("disableNitter" in changes) {
|
||||
|
||||
if ("disableNitter" in changes)
|
||||
disableNitter = changes.disableNitter.newValue;
|
||||
}
|
||||
if ("disableScribe" in changes) {
|
||||
|
||||
if ("disableScribe" in changes)
|
||||
disableScribe = changes.disableScribe.newValue;
|
||||
}
|
||||
if ("disableInvidious" in changes) {
|
||||
|
||||
if ("disableInvidious" in changes)
|
||||
disableInvidious = changes.disableInvidious.newValue;
|
||||
}
|
||||
if ("disableBibliogram" in changes) {
|
||||
|
||||
if ("disableBibliogram" in changes)
|
||||
disableBibliogram = changes.disableBibliogram.newValue;
|
||||
}
|
||||
if ("disableOsm" in changes) {
|
||||
|
||||
if ("disableOsm" in changes)
|
||||
disableOsm = changes.disableOsm.newValue;
|
||||
}
|
||||
if ("disableReddit" in changes) {
|
||||
|
||||
if ("disableReddit" in changes)
|
||||
disableReddit = changes.disableReddit.newValue;
|
||||
}
|
||||
if ("disableSearchEngine" in changes) {
|
||||
|
||||
if ("disableSearchEngine" in changes)
|
||||
disableSearchEngine = changes.disableSearchEngine.newValue;
|
||||
}
|
||||
if ("disableSimplyTranslate" in changes) {
|
||||
|
||||
if ("disableSimplyTranslate" in changes)
|
||||
disableSimplyTranslate = changes.disableSimplyTranslate.newValue;
|
||||
}
|
||||
if ("disableWikipedia" in changes) {
|
||||
|
||||
if ("disableWikipedia" in changes)
|
||||
disableWikipedia = changes.disableWikipedia.newValue;
|
||||
}
|
||||
if ("alwaysProxy" in changes) {
|
||||
|
||||
if ("alwaysProxy" in changes)
|
||||
alwaysProxy = changes.alwaysProxy.newValue;
|
||||
}
|
||||
if ("onlyEmbeddedVideo" in changes) {
|
||||
|
||||
if ("onlyEmbeddedVideo" in changes)
|
||||
onlyEmbeddedVideo = changes.onlyEmbeddedVideo.newValue;
|
||||
}
|
||||
if ("videoQuality" in changes) {
|
||||
|
||||
if ("videoQuality" in changes)
|
||||
videoQuality = changes.videoQuality.newValue;
|
||||
}
|
||||
if ("invidiousDarkMode" in changes) {
|
||||
|
||||
if ("invidiousDarkMode" in changes)
|
||||
invidiousDarkMode = changes.invidiousDarkMode.newValue;
|
||||
}
|
||||
if ("invidiousVolume" in changes) {
|
||||
|
||||
if ("invidiousVolume" in changes)
|
||||
invidiousVolume = changes.invidiousVolume.newValue;
|
||||
}
|
||||
if ("invidiousPlayerStyle" in changes) {
|
||||
|
||||
if ("invidiousPlayerStyle" in changes)
|
||||
invidiousPlayerStyle = changes.invidiousPlayerStyle.newValue;
|
||||
}
|
||||
if ("invidiousSubtitles" in changes) {
|
||||
|
||||
if ("invidiousSubtitles" in changes)
|
||||
invidiousSubtitles = changes.invidiousSubtitles.newValue;
|
||||
}
|
||||
if ("invidiousAutoplay" in changes) {
|
||||
|
||||
if ("invidiousAutoplay" in changes)
|
||||
invidiousAutoplay = changes.invidiousAutoplay.newValue;
|
||||
}
|
||||
if ("useFreeTube" in changes) {
|
||||
|
||||
if ("useFreeTube" in changes)
|
||||
useFreeTube = changes.useFreeTube.newValue;
|
||||
}
|
||||
if ("nitterRandomPool" in changes) {
|
||||
nitterRandomPool = changes.nitterRandomPool.newValue.split(",");
|
||||
}
|
||||
if ("invidiousRandomPool" in changes) {
|
||||
invidiousRandomPool = changes.invidiousRandomPool.newValue.split(",");
|
||||
}
|
||||
if ("bibliogramRandomPool" in changes) {
|
||||
bibliogramRandomPool = changes.bibliogramRandomPool.newValue.split(",");
|
||||
}
|
||||
if ("scribeRandomPool" in changes) {
|
||||
scribeRandomPool = changes.scribeRandomPool.newValue.split(",");
|
||||
}
|
||||
if ("exceptions" in changes) {
|
||||
|
||||
if ("nitterRandomPool" in changes)
|
||||
nitterRandomPool = changes.nitterRandomPool.newValue;
|
||||
|
||||
if ("invidiousRandomPool" in changes)
|
||||
invidiousRandomPool = changes.invidiousRandomPool.newValue;
|
||||
|
||||
if ("bibliogramRandomPool" in changes)
|
||||
bibliogramRandomPool = changes.bibliogramRandomPool.newValue;
|
||||
|
||||
if ("scribeRandomPool" in changes)
|
||||
scribeRandomPool = changes.scribeRandomPool.newValue;
|
||||
|
||||
if ("exceptions" in changes)
|
||||
exceptions = changes.exceptions.newValue.map((e) => {
|
||||
return new RegExp(e);
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
function isException(url, initiator) {
|
||||
|
@ -524,29 +523,22 @@ function redirectReddit(url, initiator, type) {
|
|||
return null;
|
||||
|
||||
console.info(url.host);
|
||||
if (url.host === "i.redd.it") {
|
||||
if (redditFrontend == 'libreddit')
|
||||
return `${redditInstance || commonHelper.getRandomInstance(redditInstances['libreddit'])}/img${url.pathname}${url.search}`;
|
||||
if (redditFrontend == 'teddit')
|
||||
// As of 2021-04-09, redirects for teddit images are nontrivial:
|
||||
// - navigating to the image before ever navigating to its page causes
|
||||
// 404 error (probably needs fix on teddit project)
|
||||
// - some image links on teddit are very different
|
||||
// Therefore, don't support redirecting image links for teddit.
|
||||
return null;
|
||||
|
||||
return null;
|
||||
|
||||
} else if (url.host === "redd.it") {
|
||||
if (url.host === "i.redd.it")
|
||||
// As of 2021-04-09, redirects for teddit images are nontrivial:
|
||||
// - navigating to the image before ever navigating to its page causes
|
||||
// 404 error (probably needs fix on teddit project)
|
||||
// - some image links on teddit are very different
|
||||
// Therefore, don't support redirecting image links for teddit.
|
||||
return `${redditInstance || commonHelper.getRandomInstance(redditInstances['libreddit'])}/img${url.pathname}${url.search}`;
|
||||
else if (url.host === "redd.it") {
|
||||
if (redditFrontend == 'libreddit')
|
||||
return `${redditInstance || commonHelper.getRandomInstance(redditInstances['libreddit'])}${url.pathname}${url.search}`;
|
||||
if (redditFrontend == 'teddit' && !url.pathname.match(/^\/+[^\/]+\/+[^\/]/))
|
||||
// As of 2021-04-22, redirects for teddit redd.it/foo links don't work.
|
||||
// It appears that adding "/comments" as a prefix works, so manually add
|
||||
// that prefix if it is missing. Even though redd.it/comments/foo links
|
||||
// that prefix if it is missing. Even though redd.it/comments/foo links
|
||||
// don't seem to work or exist, guard against affecting those kinds of
|
||||
// paths.
|
||||
//
|
||||
// Note the difference between redd.it/comments/foo (doesn't work) and
|
||||
// teddit.net/comments/foo (works).
|
||||
return `${redditInstance || commonHelper.getRandomInstance(redditInstances['teddit'])}/comments${url.pathname}${url.search}`;
|
||||
|
@ -559,9 +551,8 @@ function redirectReddit(url, initiator, type) {
|
|||
}
|
||||
|
||||
function redirectMedium(url, initiator) {
|
||||
if (disableScribe || isException(url, initiator)) {
|
||||
if (disableScribe || isException(url, initiator))
|
||||
return null;
|
||||
}
|
||||
|
||||
if (url.pathname == "/")
|
||||
return null;
|
||||
|
@ -573,23 +564,17 @@ function redirectMedium(url, initiator) {
|
|||
scribeInstances.includes(initiator.origin) ||
|
||||
mediumDomains.includes(initiator.host))
|
||||
) {
|
||||
browser.storage.sync.set({
|
||||
redirectBypassFlag: true,
|
||||
});
|
||||
browser.storage.sync.set({ redirectBypassFlag: true });
|
||||
return null;
|
||||
}
|
||||
return `${scribeInstance || commonHelper.getRandomInstance(scribeRandomPool)
|
||||
}${url.pathname}${url.search}`;
|
||||
return `${scribeInstance || commonHelper.getRandomInstance(scribeRandomPool)}${url.pathname}${url.search}`;
|
||||
}
|
||||
|
||||
function redirectSearchEngine(url, initiator) {
|
||||
if (disableSearchEngine || isException(url, initiator)) {
|
||||
if (disableSearchEngine || isException(url, initiator))
|
||||
return null;
|
||||
}
|
||||
|
||||
const searchEngine =
|
||||
searchEngineInstance ||
|
||||
commonHelper.getRandomInstance(searchEngineInstances);
|
||||
const searchEngine = searchEngineInstance || commonHelper.getRandomInstance(searchEngineInstances);
|
||||
let search = "";
|
||||
url.search
|
||||
.slice(1)
|
||||
|
@ -601,17 +586,13 @@ function redirectSearchEngine(url, initiator) {
|
|||
}
|
||||
|
||||
function redirectGoogleTranslate(url, initiator) {
|
||||
if (disableSimplyTranslate || isException(url, initiator)) {
|
||||
return null;
|
||||
}
|
||||
if (disableSimplyTranslate || isException(url, initiator)) return null;
|
||||
|
||||
return `${simplyTranslateInstance}/${url.search}`;
|
||||
}
|
||||
|
||||
function redirectWikipedia(url, initiator) {
|
||||
if (disableWikipedia || isException(url, initiator)) {
|
||||
return null;
|
||||
}
|
||||
if (disableWikipedia || isException(url, initiator)) return null;
|
||||
let GETArguments = [];
|
||||
if (url.search.length > 0) {
|
||||
let search = url.search.substring(1); //get rid of '?'
|
||||
|
@ -631,9 +612,9 @@ function redirectWikipedia(url, initiator) {
|
|||
GETArguments.push(["mobileaction", "toggle_view_mobile"]);
|
||||
//wikiless doesn't have mobile view support yet
|
||||
}
|
||||
for (let i = 0; i < GETArguments.length; i++) {
|
||||
for (let i = 0; i < GETArguments.length; i++)
|
||||
link += (i == 0 ? "?" : "&") + GETArguments[i][0] + "=" + GETArguments[i][1];
|
||||
}
|
||||
|
||||
if (
|
||||
urlSplit[urlSplit.length - 1] == "org" &&
|
||||
urlSplit[urlSplit.length - 2] == "wikipedia"
|
||||
|
@ -647,11 +628,10 @@ browser.webRequest.onBeforeRequest.addListener(
|
|||
(details) => {
|
||||
const url = new URL(details.url);
|
||||
let initiator;
|
||||
if (details.originUrl) {
|
||||
if (details.originUrl)
|
||||
initiator = new URL(details.originUrl);
|
||||
} else if (details.initiator) {
|
||||
else if (details.initiator)
|
||||
initiator = new URL(details.initiator);
|
||||
}
|
||||
|
||||
let newUrl;
|
||||
if (youtubeDomains.includes(url.host))
|
||||
|
@ -673,24 +653,13 @@ browser.webRequest.onBeforeRequest.addListener(
|
|||
else if (url.host.match(wikipediaRegex))
|
||||
newUrl = redirectWikipedia(url, initiator);
|
||||
|
||||
let redirect;
|
||||
if (newUrl) {
|
||||
redirect = {
|
||||
redirectUrl: newUrl
|
||||
}
|
||||
console.info(
|
||||
"Redirecting",
|
||||
`"${url.href}"`,
|
||||
"=>",
|
||||
`"${redirect.redirectUrl}"`
|
||||
);
|
||||
// console.info("Details", details);
|
||||
console.info("Redirecting", url.href, "=>", newUrl);
|
||||
return { redirectUrl: newUrl };
|
||||
}
|
||||
return redirect;
|
||||
},
|
||||
{
|
||||
urls: ["<all_urls>"],
|
||||
return null;
|
||||
},
|
||||
{ urls: ["<all_urls>"], },
|
||||
["blocking"]
|
||||
);
|
||||
|
||||
|
@ -729,10 +698,14 @@ browser.pageAction.onClicked.addListener((tab) => {
|
|||
newUrl = 'https://twitter.com';
|
||||
else if (bibliogramInstances.includes(protocolHost))
|
||||
newUrl = 'https://instagram.com';
|
||||
else if (redditInstances['libreddit'].includes(protocolHost))
|
||||
newUrl = 'https://reddit.com';
|
||||
else if (redditInstances['teddit'].includes(protocolHost))
|
||||
newUrl = 'https://reddit.com';
|
||||
else if (redditInstances['libreddit'].includes(protocolHost) || redditInstances['teddit'].includes(protocolHost)) {
|
||||
if (tabUrl.pathname.startsWith('/img')) {
|
||||
newUrl = "https://i.redd.it"
|
||||
tabUrl.href = tabUrl.href.replace("/img", "")
|
||||
}
|
||||
else
|
||||
newUrl = 'https://reddit.com';
|
||||
}
|
||||
else if (searchEngineInstances.includes(protocolHost))
|
||||
newUrl = 'https://google.com';
|
||||
else if (simplyTranslateInstances.includes(protocolHost))
|
||||
|
|
|
@ -5,9 +5,9 @@ import shared from "./shared.js";
|
|||
|
||||
const bibliogramInstances = instagramHelper.redirects;
|
||||
|
||||
let bibliogramInstance = document.getElementById("bibliogram-instance");
|
||||
let disableBibliogram = document.getElementById("disable-bibliogram");
|
||||
let bibliogramRandomPool = document.getElementById("bibliogram-random-pool");
|
||||
let bibliogramInstanceElement = document.getElementById("bibliogram-instance");
|
||||
let disableBibliogramElement = document.getElementById("disable-bibliogram");
|
||||
let bibliogramRandomPoolElement = document.getElementById("bibliogram-random-pool");
|
||||
|
||||
browser.storage.sync.get(
|
||||
[
|
||||
|
@ -16,33 +16,26 @@ browser.storage.sync.get(
|
|||
"bibliogramRandomPool",
|
||||
],
|
||||
(result) => {
|
||||
bibliogramInstance.value = result.bibliogramInstance || "";
|
||||
disableBibliogram.checked = !result.disableBibliogram;
|
||||
bibliogramRandomPool.value = result.bibliogramRandomPool || commonHelper.filterInstances(bibliogramInstances);
|
||||
bibliogramInstanceElement.value = result.bibliogramInstance || "";
|
||||
disableBibliogramElement.checked = !result.disableBibliogram;
|
||||
bibliogramRandomPoolElement.value = result.bibliogramRandomPool || commonHelper.filterInstances(bibliogramInstances);
|
||||
let id = "bibliogram-instance";
|
||||
let instances = bibliogramRandomPool.value.split(',')
|
||||
let instances = bibliogramRandomPoolElement.value.split(',')
|
||||
shared.autocompletes.push({ id: id, instances: instances })
|
||||
shared.autocomplete(document.getElementById(id), instances);
|
||||
}
|
||||
)
|
||||
|
||||
const bibliogramInstanceChange = commonHelper.debounce(() => {
|
||||
if (bibliogramInstance.checkValidity()) {
|
||||
browser.storage.sync.set({
|
||||
bibliogramInstance: shared.parseURL(bibliogramInstance.value),
|
||||
});
|
||||
}
|
||||
}, 500);
|
||||
bibliogramInstance.addEventListener("input", bibliogramInstanceChange);
|
||||
bibliogramInstanceElement.addEventListener("input", commonHelper.debounce(() => {
|
||||
if (bibliogramInstanceElement.checkValidity())
|
||||
browser.storage.sync.set({ bibliogramInstance: shared.parseURL(bibliogramInstanceElement.value) });
|
||||
}, 500));
|
||||
|
||||
disableBibliogram.addEventListener("change", (event) => {
|
||||
disableBibliogramElement.addEventListener("change", (event) => {
|
||||
browser.storage.sync.set({ disableBibliogram: !event.target.checked });
|
||||
});
|
||||
|
||||
const bibliogramRandomPoolChange = commonHelper.debounce(() => {
|
||||
browser.storage.sync.set({
|
||||
bibliogramRandomPool: bibliogramRandomPool.value,
|
||||
});
|
||||
}, 500);
|
||||
bibliogramRandomPool.addEventListener("input", bibliogramRandomPoolChange);
|
||||
bibliogramRandomPoolElement.addEventListener("input", commonHelper.debounce(() => {
|
||||
browser.storage.sync.set({ bibliogramRandomPool: bibliogramRandomPoolElement.value });
|
||||
}, 500));
|
||||
|
||||
|
|
|
@ -3,8 +3,9 @@ import commonHelper from "../../assets/javascripts/helpers/common.js";
|
|||
import shared from "./shared.js";
|
||||
|
||||
const osmInstances = mapsHelper.redirects;
|
||||
let osmInstance = document.getElementById("osm-instance");
|
||||
let disableOsm = document.getElementById("disable-osm");
|
||||
|
||||
let osmInstanceElement = document.getElementById("osm-instance");
|
||||
let disableOsmElement = document.getElementById("disable-osm");
|
||||
|
||||
browser.storage.sync.get(
|
||||
[
|
||||
|
@ -12,8 +13,8 @@ browser.storage.sync.get(
|
|||
"disableOsm",
|
||||
],
|
||||
(result) => {
|
||||
osmInstance.value = result.osmInstance || "";
|
||||
disableOsm.checked = !result.disableOsm;
|
||||
osmInstanceElement.value = result.osmInstance || "";
|
||||
disableOsmElement.checked = !result.disableOsm;
|
||||
let id = "osm-instance"
|
||||
let instances = osmInstances
|
||||
shared.autocompletes.push({ id: id, instances: instances })
|
||||
|
@ -21,15 +22,11 @@ browser.storage.sync.get(
|
|||
}
|
||||
)
|
||||
|
||||
const osmInstanceChange = commonHelper.debounce(() => {
|
||||
if (osmInstance.checkValidity()) {
|
||||
browser.storage.sync.set({
|
||||
osmInstance: shared.parseURL(osmInstance.value),
|
||||
});
|
||||
}
|
||||
}, 500);
|
||||
osmInstance.addEventListener("input", osmInstanceChange);
|
||||
osmInstanceElement.addEventListener("input", commonHelper.debounce(() => {
|
||||
if (osmInstanceElement.checkValidity())
|
||||
browser.storage.sync.set({ osmInstance: shared.parseURL(osmInstanceElement.value) });
|
||||
}, 500));
|
||||
|
||||
disableOsm.addEventListener("change", (event) => {
|
||||
disableOsmElement.addEventListener("change", (event) => {
|
||||
browser.storage.sync.set({ disableOsm: !event.target.checked });
|
||||
});
|
|
@ -4,10 +4,9 @@ import shared from "./shared.js";
|
|||
|
||||
const scribeInstances = mediumHelper.redirects;
|
||||
|
||||
let scribeInstance = document.getElementById("scribe-instance");
|
||||
let disableScribe = document.getElementById("disable-scribe");
|
||||
let scribeRandomPool = document.getElementById("scribe-random-pool");
|
||||
|
||||
let scribeInstanceElement = document.getElementById("scribe-instance");
|
||||
let disableScribeElement = document.getElementById("disable-scribe");
|
||||
let scribeRandomPoolElement = document.getElementById("scribe-random-pool");
|
||||
|
||||
browser.storage.sync.get(
|
||||
[
|
||||
|
@ -16,46 +15,32 @@ browser.storage.sync.get(
|
|||
"scribeRandomPool",
|
||||
],
|
||||
(result) => {
|
||||
scribeInstance.value = result.scribeInstance || "";
|
||||
disableScribe.checked = !result.disableScribe;
|
||||
scribeRandomPool.value = result.scribeRandomPool || commonHelper.filterInstances(scribeInstances);
|
||||
scribeInstanceElement.value = result.scribeInstance || "";
|
||||
disableScribeElement.checked = !result.disableScribe;
|
||||
scribeRandomPoolElement.value = (result.scribeRandomPool || commonHelper.filterInstances(scribeInstances)).join("\n");
|
||||
let id = "scribe-instance";
|
||||
let instances = scribeRandomPool.value.split(',')
|
||||
let instances = scribeRandomPoolElement.value.split(',')
|
||||
shared.autocompletes.push({ id: id, instances: instances })
|
||||
shared.autocomplete(document.getElementById(id), instances);
|
||||
}
|
||||
)
|
||||
|
||||
disableScribe.addEventListener(
|
||||
"change",
|
||||
(event) => {
|
||||
console.info("isScibeEnabled:", event.target.checked)
|
||||
disableScribeElement.addEventListener("change", (event) => {
|
||||
console.info("isScibeEnabled:", event.target.checked)
|
||||
browser.storage.sync.set({ disableScribe: !event.target.checked });
|
||||
});
|
||||
|
||||
scribeInstanceElement.addEventListener("input", commonHelper.debounce(() => {
|
||||
if (scribeInstanceElement.checkValidity()) {
|
||||
console.info("selectedScribeInstance", scribeInstanceElement.value);
|
||||
browser.storage.sync.set({
|
||||
disableScribe: !event.target.checked
|
||||
scribeInstance: shared.parseURL(scribeInstanceElement.value)
|
||||
});
|
||||
}
|
||||
);
|
||||
}, 500));
|
||||
|
||||
const scribeInstanceChange = commonHelper.debounce(
|
||||
() => {
|
||||
if (scribeInstance.checkValidity()) {
|
||||
console.info("selectedScribeInstance", scribeInstance.value);
|
||||
browser.storage.sync.set({
|
||||
scribeInstance: shared.parseURL(scribeInstance.value)
|
||||
});
|
||||
}
|
||||
},
|
||||
500
|
||||
);
|
||||
|
||||
scribeInstance.addEventListener("input", scribeInstanceChange);
|
||||
|
||||
const scribeRandomPoolChange = commonHelper.debounce(
|
||||
() => {
|
||||
browser.storage.sync.set({
|
||||
scribeRandomPool: scribeRandomPool.value
|
||||
});
|
||||
},
|
||||
500
|
||||
);
|
||||
scribeRandomPool.addEventListener("input", scribeRandomPoolChange);
|
||||
scribeRandomPoolElement.addEventListener("input", commonHelper.debounce(() => {
|
||||
browser.storage.sync.set({
|
||||
scribeRandomPool: scribeRandomPoolElement.value.split('\n')
|
||||
});
|
||||
}, 500));
|
|
@ -101,7 +101,7 @@
|
|||
</div>
|
||||
|
||||
<section class="settings-block">
|
||||
<h4>Random Instance Pool (comma-separated)</h4>
|
||||
<h4>Random Instance Pool</h4>
|
||||
<textarea type="textarea" id="invidious-random-pool" name="invidious-random-pool" type="text"></textarea>
|
||||
</section>
|
||||
|
||||
|
@ -303,6 +303,10 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<section class="settings-block">
|
||||
<h4>Random instance pool</h4>
|
||||
<textarea id="wikiless-random-pool" type="text"></textarea>
|
||||
</section>
|
||||
|
||||
</section>
|
||||
|
||||
|
@ -321,7 +325,7 @@
|
|||
</div>
|
||||
<section class="settings-block">
|
||||
<h4>Random instance pool (comma-separated)</h4>
|
||||
<textarea id="scribe-random-pool" name="scribe-random-pool" type="text"></textarea>
|
||||
<textarea id="scribe-random-pool" type="text"></textarea>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import shared from "./shared.js";
|
|||
|
||||
const domparser = new DOMParser();
|
||||
|
||||
let theme = document.getElementById("theme");
|
||||
let themeElement = document.getElementById("theme");
|
||||
let exceptions;
|
||||
|
||||
window.browser = window.browser || window.chrome;
|
||||
|
@ -26,9 +26,7 @@ function prependExceptionsItem(item, index) {
|
|||
button.appendChild(domparser.parseFromString(svg, "image/svg+xml").documentElement);
|
||||
button.addEventListener("click", () => {
|
||||
exceptions.splice(index, 1);
|
||||
browser.storage.sync.set({
|
||||
exceptions: exceptions,
|
||||
});
|
||||
browser.storage.sync.set({ exceptions: exceptions });
|
||||
li.remove();
|
||||
});
|
||||
}
|
||||
|
@ -39,7 +37,7 @@ browser.storage.sync.get(
|
|||
"theme",
|
||||
],
|
||||
(result) => {
|
||||
theme.value = result.theme || "";
|
||||
themeElement.value = result.theme || "";
|
||||
if (result.theme) document.body.classList.add(result.theme);
|
||||
exceptions = result.exceptions || [];
|
||||
exceptions.forEach(prependExceptionsItem);
|
||||
|
@ -74,7 +72,7 @@ function addToExceptions() {
|
|||
}
|
||||
document.getElementById("add-to-exceptions").addEventListener("click", addToExceptions);
|
||||
|
||||
theme.addEventListener("change", (event) => {
|
||||
themeElement.addEventListener("change", (event) => {
|
||||
const value = event.target.options[theme.selectedIndex].value;
|
||||
switch (value) {
|
||||
case "dark-theme":
|
||||
|
@ -89,9 +87,7 @@ theme.addEventListener("change", (event) => {
|
|||
document.body.classList.remove("light-theme");
|
||||
document.body.classList.remove("dark-theme");
|
||||
}
|
||||
browser.storage.sync.set({
|
||||
theme: value,
|
||||
});
|
||||
browser.storage.sync.set({ theme: value });
|
||||
});
|
||||
|
||||
document.querySelector("#update-instances").addEventListener("click", () => {
|
||||
|
@ -100,4 +96,4 @@ document.querySelector("#update-instances").addEventListener("click", () => {
|
|||
document.querySelector("#update-instances").innerHTML = 'Done!';
|
||||
else
|
||||
document.querySelector("#update-instances").innerHTML = 'Failed Miserabely';
|
||||
});
|
||||
});
|
||||
|
|
|
@ -5,9 +5,9 @@ import shared from "./shared.js";
|
|||
|
||||
const redditInstances = redditHelper.redirects;
|
||||
|
||||
let redditInstance = document.getElementById("reddit-instance");
|
||||
let disableReddit = document.getElementById("disable-reddit");
|
||||
let redditFrontend = document.getElementById("reddit-frontend");
|
||||
let redditInstanceElement = document.getElementById("reddit-instance");
|
||||
let disableRedditElement = document.getElementById("disable-reddit");
|
||||
let redditFrontendElement = document.getElementById("reddit-frontend");
|
||||
|
||||
browser.storage.sync.get(
|
||||
[
|
||||
|
@ -16,9 +16,9 @@ browser.storage.sync.get(
|
|||
"redditFrontend"
|
||||
],
|
||||
(result) => {
|
||||
redditInstance.value = result.redditInstance || "";
|
||||
disableReddit.checked = !result.disableReddit;
|
||||
redditFrontend.value = result.redditFrontend;
|
||||
redditInstanceElement.value = result.redditInstance || "";
|
||||
disableRedditElement.checked = !result.disableReddit;
|
||||
redditFrontendElement.value = result.redditFrontend;
|
||||
let id = "reddit-instance";
|
||||
let instances = redditInstances;
|
||||
shared.autocompletes.push({ id: id, instances: instances })
|
||||
|
@ -26,27 +26,20 @@ browser.storage.sync.get(
|
|||
}
|
||||
)
|
||||
|
||||
const redditInstanceChange = commonHelper.debounce(
|
||||
() => {
|
||||
if (redditInstance.checkValidity()) {
|
||||
browser.storage.sync.set({
|
||||
redditInstance: shared.parseURL(redditInstance.value),
|
||||
});
|
||||
}
|
||||
},
|
||||
500
|
||||
);
|
||||
redditInstanceElement.addEventListener("input", commonHelper.debounce(() => {
|
||||
if (redditInstanceElement.checkValidity()) {
|
||||
browser.storage.sync.set({
|
||||
redditInstance: shared.parseURL(redditInstanceElement.value),
|
||||
});
|
||||
}
|
||||
}, 500));
|
||||
|
||||
redditInstance.addEventListener("input", redditInstanceChange);
|
||||
|
||||
disableReddit.addEventListener("change", (event) => {
|
||||
disableRedditElement.addEventListener("change", (event) => {
|
||||
browser.storage.sync.set({ disableReddit: !event.target.checked });
|
||||
});
|
||||
|
||||
redditFrontend.addEventListener("change", (event) => {
|
||||
const value = event.target.options[redditFrontend.selectedIndex].value;
|
||||
redditFrontendElement.addEventListener("change", (event) => {
|
||||
const value = event.target.options[redditFrontendElement.selectedIndex].value;
|
||||
console.info("Reddit Frontend", value)
|
||||
browser.storage.sync.set({
|
||||
redditFrontend: value,
|
||||
})
|
||||
browser.storage.sync.set({ redditFrontend: value })
|
||||
})
|
|
@ -3,8 +3,8 @@ import commonHelper from "../../assets/javascripts/helpers/common.js";
|
|||
import shared from "./shared.js";
|
||||
|
||||
const searchEngineInstances = searchHelper.redirects;
|
||||
let searchEngineInstance = document.getElementById("searchEngine-instance");
|
||||
let disableSearchEngine = document.getElementById("disable-searchEngine");
|
||||
let searchEngineInstanceElement = document.getElementById("searchEngine-instance");
|
||||
let disableSearchEngineElement = document.getElementById("disable-searchEngine");
|
||||
|
||||
browser.storage.sync.get(
|
||||
[
|
||||
|
@ -12,9 +12,9 @@ browser.storage.sync.get(
|
|||
"disableSearchEngine",
|
||||
],
|
||||
(result) => {
|
||||
searchEngineInstance.value = (result.searchEngineInstance && result.searchEngineInstance.link) || "";
|
||||
searchEngineInstanceElement.value = (result.searchEngineInstance && result.searchEngineInstance.link) || "";
|
||||
|
||||
disableSearchEngine.checked = !result.disableSearchEngine;
|
||||
disableSearchEngineElement.checked = !result.disableSearchEngine;
|
||||
|
||||
let id = "searchEngine-instance"
|
||||
let instances = searchEngineInstances.map((instance) => instance.link)
|
||||
|
@ -25,18 +25,18 @@ browser.storage.sync.get(
|
|||
|
||||
const searchEngineInstanceChange = commonHelper.debounce(() => {
|
||||
const instance = searchEngineInstances.find(
|
||||
(instance) => instance.link === searchEngineInstance.value
|
||||
(instance) => instance.link === searchEngineInstanceElement.value
|
||||
);
|
||||
if (instance || !searchEngineInstance.value) {
|
||||
if (instance || !searchEngineInstanceElement.value) {
|
||||
browser.storage.sync.set({
|
||||
searchEngineInstance: instance || searchEngineInstance.value,
|
||||
searchEngineInstance: instance || searchEngineInstanceElement.value,
|
||||
});
|
||||
} else {
|
||||
searchEngineInstance.setCustomValidity("Must be an instance from the list");
|
||||
searchEngineInstanceElement.setCustomValidity("Must be an instance from the list");
|
||||
}
|
||||
}, 500);
|
||||
searchEngineInstance.addEventListener("input", searchEngineInstanceChange);
|
||||
searchEngineInstanceElement.addEventListener("input", searchEngineInstanceChange);
|
||||
|
||||
disableSearchEngine.addEventListener("change", (event) => {
|
||||
disableSearchEngineElement.addEventListener("change", (event) => {
|
||||
browser.storage.sync.set({ disableSearchEngine: !event.target.checked });
|
||||
});
|
||||
|
|
|
@ -3,8 +3,9 @@ import commonHelper from "../../assets/javascripts/helpers/common.js";
|
|||
import shared from "./shared.js";
|
||||
|
||||
const simplyTranslateInstances = googleTranslateHelper.redirects;
|
||||
let simplyTranslateInstance = document.getElementById("simplyTranslate-instance");
|
||||
let disableSimplyTranslate = document.getElementById("disable-simplyTranslate");
|
||||
|
||||
let simplyTranslateInstanceElement = document.getElementById("simplyTranslate-instance");
|
||||
let disableSimplyTranslateElement = document.getElementById("disable-simplyTranslate");
|
||||
|
||||
|
||||
browser.storage.sync.get(
|
||||
|
@ -13,9 +14,8 @@ browser.storage.sync.get(
|
|||
"disableSimplyTranslate",
|
||||
],
|
||||
(result) => {
|
||||
|
||||
simplyTranslateInstance.value = result.simplyTranslateInstance || "";
|
||||
disableSimplyTranslate.checked = !result.disableSimplyTranslate;
|
||||
simplyTranslateInstanceElement.value = result.simplyTranslateInstance || "";
|
||||
disableSimplyTranslateElement.checked = !result.disableSimplyTranslate;
|
||||
let id = "simplyTranslate-instance"
|
||||
let instances = simplyTranslateInstances;
|
||||
shared.autocompletes.push({ id: id, instances: instances })
|
||||
|
@ -23,20 +23,16 @@ browser.storage.sync.get(
|
|||
}
|
||||
)
|
||||
|
||||
const simplyTranslateInstanceChange = commonHelper.debounce(() => {
|
||||
if (simplyTranslateInstance.checkValidity()) {
|
||||
browser.storage.sync.set({
|
||||
simplyTranslateInstance: shared.parseURL(simplyTranslateInstance.value),
|
||||
});
|
||||
}
|
||||
}, 500);
|
||||
simplyTranslateInstance.addEventListener(
|
||||
simplyTranslateInstanceElement.addEventListener(
|
||||
"input",
|
||||
simplyTranslateInstanceChange
|
||||
);
|
||||
commonHelper.debounce(() => {
|
||||
if (simplyTranslateInstanceElement.checkValidity()) {
|
||||
browser.storage.sync.set({
|
||||
simplyTranslateInstance: shared.parseURL(simplyTranslateInstanceElement.value),
|
||||
});
|
||||
}
|
||||
}, 500));
|
||||
|
||||
|
||||
|
||||
disableSimplyTranslate.addEventListener("change", (event) => {
|
||||
disableSimplyTranslateElement.addEventListener("change", (event) => {
|
||||
browser.storage.sync.set({ disableSimplyTranslate: !event.target.checked });
|
||||
});
|
|
@ -3,10 +3,11 @@ import commonHelper from "../../assets/javascripts/helpers/common.js";
|
|||
import shared from "./shared.js";
|
||||
|
||||
const nitterInstances = twitterHelper.redirects;
|
||||
let nitterInstance = document.getElementById("nitter-instance");
|
||||
let disableNitter = document.getElementById("disable-nitter");
|
||||
let nitterRandomPool = document.getElementById("nitter-random-pool");
|
||||
let removeTwitterSW = document.getElementById("remove-twitter-sw");
|
||||
|
||||
let nitterInstanceElement = document.getElementById("nitter-instance");
|
||||
let disableNitterElement = document.getElementById("disable-nitter");
|
||||
let nitterRandomPoolElement = document.getElementById("nitter-random-pool");
|
||||
let removeTwitterSWElement = document.getElementById("remove-twitter-sw");
|
||||
|
||||
browser.storage.sync.get(
|
||||
[
|
||||
|
@ -16,38 +17,33 @@ browser.storage.sync.get(
|
|||
"removeTwitterSW",
|
||||
],
|
||||
(result) => {
|
||||
nitterInstance.value = result.nitterInstance || "";
|
||||
disableNitter.checked = !result.disableNitter;
|
||||
nitterRandomPool.value = result.nitterRandomPool || commonHelper.filterInstances(nitterInstances);
|
||||
removeTwitterSW.checked = !result.removeTwitterSW;
|
||||
nitterInstanceElement.value = result.nitterInstance || "";
|
||||
disableNitterElement.checked = !result.disableNitter;
|
||||
nitterRandomPoolElement.value = result.nitterRandomPool || commonHelper.filterInstances(nitterInstances);
|
||||
removeTwitterSWElement.checked = !result.removeTwitterSW;
|
||||
let id = "nitter-instance"
|
||||
let instances = nitterRandomPool.value.split(',')
|
||||
let instances = nitterRandomPoolElement.value.split(',')
|
||||
shared.autocompletes.push({ id: id, instances: instances })
|
||||
shared.autocomplete(document.getElementById(id), instances);
|
||||
}
|
||||
)
|
||||
|
||||
const nitterInstanceChange = commonHelper.debounce(
|
||||
() => {
|
||||
if (nitterInstance.checkValidity()) {
|
||||
browser.storage.sync.set({
|
||||
nitterInstance: shared.parseURL(nitterInstance.value),
|
||||
});
|
||||
}
|
||||
},
|
||||
500)
|
||||
nitterInstance.addEventListener("input", nitterInstanceChange);
|
||||
nitterInstanceElement.addEventListener("input", commonHelper.debounce(() => {
|
||||
if (nitterInstanceElement.checkValidity()) {
|
||||
browser.storage.sync.set({
|
||||
nitterInstance: shared.parseURL(nitterInstanceElement.value),
|
||||
});
|
||||
}
|
||||
}, 500));
|
||||
|
||||
|
||||
disableNitter.addEventListener("change", (event) => {
|
||||
disableNitterElement.addEventListener("change", (event) => {
|
||||
browser.storage.sync.set({ disableNitter: !event.target.checked });
|
||||
});
|
||||
|
||||
removeTwitterSW.addEventListener("change", (event) => {
|
||||
removeTwitterSWElement.addEventListener("change", (event) => {
|
||||
browser.storage.sync.set({ removeTwitterSW: !event.target.checked });
|
||||
});
|
||||
|
||||
const nitterRandomPoolChange = commonHelper.debounce(() => {
|
||||
browser.storage.sync.set({ nitterRandomPool: nitterRandomPool.value });
|
||||
}, 500);
|
||||
nitterRandomPool.addEventListener("input", nitterRandomPoolChange);
|
||||
nitterRandomPoolElement.addEventListener("input", commonHelper.debounce(() => {
|
||||
browser.storage.sync.set({ nitterRandomPool: nitterRandomPoolElement.value });
|
||||
}, 500));
|
||||
|
|
|
@ -3,40 +3,42 @@ import commonHelper from "../../assets/javascripts/helpers/common.js";
|
|||
import shared from "./shared.js";
|
||||
|
||||
|
||||
const wikipediaInstances = wikipediaHelper.redirects;
|
||||
const wikilessInstances = wikipediaHelper.redirects;
|
||||
|
||||
let wikipediaInstance = document.getElementById("wikipedia-instance");
|
||||
|
||||
let disableWikipedia = document.getElementById("disable-wikipedia");
|
||||
let wikipediaInstanceElement = document.getElementById("wikipedia-instance");
|
||||
let disableWikipediaElement = document.getElementById("disable-wikipedia");
|
||||
let wikilessRandomPoolElement = document.getElementById("wikiless-random-pool");
|
||||
|
||||
browser.storage.sync.get(
|
||||
[
|
||||
"wikipediaInstance",
|
||||
"disableWikipedia",
|
||||
"wikilessRandomPool"
|
||||
],
|
||||
(result) => {
|
||||
wikipediaInstance.value = result.wikipediaInstance || "";
|
||||
|
||||
disableWikipedia.checked = !result.disableWikipedia;
|
||||
let id = "wikipedia-instance"
|
||||
let instances = wikipediaInstances
|
||||
wikipediaInstanceElement.value = result.wikipediaInstance || "";
|
||||
disableWikipediaElement.checked = !result.disableWikipedia;
|
||||
wikilessRandomPoolElement.value = (result.wikilessRandomPool || commonHelper.filterInstances(wikilessInstances)).join("\n")
|
||||
let id = "wikipedia-instance";
|
||||
let instances = wikilessInstances;
|
||||
shared.autocompletes.push({ id: id, instances: instances })
|
||||
shared.autocomplete(document.getElementById(id), instances);
|
||||
}
|
||||
)
|
||||
|
||||
const wikipediaInstanceChange = commonHelper.debounce(() => {
|
||||
if (wikipediaInstance.checkValidity()) {
|
||||
wikipediaInstanceElement.addEventListener("input", commonHelper.debounce(() => {
|
||||
if (wikipediaInstanceElement.checkValidity()) {
|
||||
browser.storage.sync.set({
|
||||
wikipediaInstance: shared.parseURL(wikipediaInstance.value),
|
||||
wikipediaInstance: shared.parseURL(wikipediaInstanceElement.value),
|
||||
});
|
||||
}
|
||||
}, 500);
|
||||
wikipediaInstance.addEventListener(
|
||||
"input",
|
||||
wikipediaInstanceChange
|
||||
);
|
||||
}, 500));
|
||||
|
||||
disableWikipedia.addEventListener("change", (event) => {
|
||||
disableWikipediaElement.addEventListener("change", (event) => {
|
||||
browser.storage.sync.set({ disableWikipedia: !event.target.checked });
|
||||
});
|
||||
});
|
||||
|
||||
browser.storage.onChanged.addListener((changes) => {
|
||||
if ("wikilessRandomPool" in changes)
|
||||
wikilessRandomPoolElement.value = changes.wikilessRandomPool.newValue.join("\n");
|
||||
})
|
|
@ -4,19 +4,19 @@ import shared from "./shared.js";
|
|||
|
||||
const invidiousInstances = youtubeHelper.redirects;
|
||||
|
||||
let invidiousInstance = document.getElementById("invidious-instance");
|
||||
let disableInvidious = document.getElementById("disable-invidious");
|
||||
let invidiousDarkMode = document.getElementById("invidious-dark-mode");
|
||||
let persistInvidiousPrefs = document.getElementById("persist-invidious-prefs");
|
||||
let invidiousVolume = document.getElementById("invidious-volume");
|
||||
let invidiousPlayerStyle = document.getElementById("invidious-player-style");
|
||||
let invidiousSubtitles = document.getElementById("invidious-subtitles");
|
||||
let invidiousAutoplay = document.getElementById("invidious-autoplay");
|
||||
let invidiousRandomPool = document.getElementById("invidious-random-pool");
|
||||
let useFreeTube = document.getElementById("use-freetube");
|
||||
let alwaysProxy = document.getElementById("always-proxy");
|
||||
let onlyEmbeddedVideo = document.getElementById("only-embed");
|
||||
let videoQuality = document.getElementById("video-quality");
|
||||
let invidiousInstanceElement = document.getElementById("invidious-instance");
|
||||
let disableInvidiousElement = document.getElementById("disable-invidious");
|
||||
let invidiousDarkModeElement = document.getElementById("invidious-dark-mode");
|
||||
let persistInvidiousPrefsElement = document.getElementById("persist-invidious-prefs");
|
||||
let invidiousVolumeElement = document.getElementById("invidious-volume");
|
||||
let invidiousPlayerStyleElement = document.getElementById("invidious-player-style");
|
||||
let invidiousSubtitlesElement = document.getElementById("invidious-subtitles");
|
||||
let invidiousAutoplayElement = document.getElementById("invidious-autoplay");
|
||||
let invidiousRandomPoolElement = document.getElementById("invidious-random-pool");
|
||||
let useFreeTubeElement = document.getElementById("use-freetube");
|
||||
let alwaysProxyElement = document.getElementById("always-proxy");
|
||||
let onlyEmbeddedVideoElement = document.getElementById("only-embed");
|
||||
let videoQualityElement = document.getElementById("video-quality");
|
||||
|
||||
browser.storage.sync.get(
|
||||
[
|
||||
|
@ -35,116 +35,94 @@ browser.storage.sync.get(
|
|||
"videoQuality",
|
||||
],
|
||||
(result) => {
|
||||
invidiousInstance.value = result.invidiousInstance || "";
|
||||
disableInvidious.checked = !result.disableInvidious;
|
||||
invidiousDarkMode.checked = result.invidiousDarkMode;
|
||||
persistInvidiousPrefs.checked = result.persistInvidiousPrefs;
|
||||
invidiousVolume.value = result.invidiousVolume;
|
||||
invidiousInstanceElement.value = result.invidiousInstance || "";
|
||||
disableInvidiousElement.checked = !result.disableInvidious;
|
||||
invidiousDarkModeElement.checked = result.invidiousDarkMode;
|
||||
persistInvidiousPrefsElement.checked = result.persistInvidiousPrefs;
|
||||
invidiousVolumeElement.value = result.invidiousVolume;
|
||||
document.querySelector("#volume-value").textContent = result.invidiousVolume ? `${result.invidiousVolume}%` : " - ";
|
||||
invidiousPlayerStyle.value = result.invidiousPlayerStyle || "";
|
||||
invidiousSubtitles.value = result.invidiousSubtitles || "";
|
||||
invidiousAutoplay.checked = result.invidiousAutoplay;
|
||||
invidiousRandomPool.value = result.invidiousRandomPool || commonHelper.filterInstances(invidiousInstances);
|
||||
useFreeTube.checked = result.useFreeTube;
|
||||
onlyEmbeddedVideo.checked = result.onlyEmbeddedVideo;
|
||||
alwaysProxy.checked = result.alwaysProxy;
|
||||
videoQuality.value = result.videoQuality || "";
|
||||
invidiousPlayerStyleElement.value = result.invidiousPlayerStyle || "";
|
||||
invidiousSubtitlesElement.value = result.invidiousSubtitles || "";
|
||||
invidiousAutoplayElement.checked = result.invidiousAutoplay;
|
||||
invidiousRandomPoolElement.value = (result.invidiousRandomPool || commonHelper.filterInstances(invidiousInstances)).join("\n");
|
||||
useFreeTubeElement.checked = result.useFreeTube;
|
||||
onlyEmbeddedVideoElement.checked = result.onlyEmbeddedVideo;
|
||||
alwaysProxyElement.checked = result.alwaysProxy;
|
||||
videoQualityElement.value = result.videoQuality || "";
|
||||
let id = "invidious-instance"
|
||||
let instances = invidiousRandomPool.value.split(',');
|
||||
let instances = invidiousRandomPoolElement.value.split('\n');
|
||||
shared.autocompletes.push({ id: id, instances: instances });
|
||||
shared.autocomplete(document.getElementById(id), instances);
|
||||
}
|
||||
)
|
||||
|
||||
const invidiousInstanceChange = commonHelper.debounce(
|
||||
() => {
|
||||
if (invidiousInstance.checkValidity())
|
||||
browser.storage.sync.set({
|
||||
invidiousInstance: shared.parseURL(invidiousInstance.value),
|
||||
});
|
||||
},
|
||||
500
|
||||
);
|
||||
invidiousInstance.addEventListener("input", invidiousInstanceChange);
|
||||
|
||||
disableInvidious.addEventListener(
|
||||
"change",
|
||||
(event) => {
|
||||
browser.storage.sync.set({ disableInvidious: !event.target.checked });
|
||||
}
|
||||
invidiousInstanceElement.addEventListener("input",
|
||||
commonHelper.debounce(() => {
|
||||
if (invidiousInstanceElement.checkValidity())
|
||||
browser.storage.sync.set({ invidiousInstance: shared.parseURL(invidiousInstanceElement.value) });
|
||||
}, 500)
|
||||
);
|
||||
|
||||
invidiousDarkMode.addEventListener(
|
||||
"change",
|
||||
(event) => {
|
||||
console.info("InvidiousDarkMode", event.target.checked);
|
||||
browser.storage.sync.set({ invidiousDarkMode: event.target.checked });
|
||||
}
|
||||
disableInvidiousElement.addEventListener("change", (event) => {
|
||||
browser.storage.sync.set({ disableInvidious: !event.target.checked });
|
||||
});
|
||||
|
||||
invidiousDarkModeElement.addEventListener("change", (event) => {
|
||||
console.info("InvidiousDarkMode", event.target.checked);
|
||||
browser.storage.sync.set({ invidiousDarkMode: event.target.checked });
|
||||
});
|
||||
|
||||
persistInvidiousPrefsElement.addEventListener("change", (event) => {
|
||||
console.info("Persist preferences (as cookie)", event.target.checked);
|
||||
browser.storage.sync.set({ persistInvidiousPrefs: event.target.checked });
|
||||
});
|
||||
|
||||
invidiousVolumeElement.addEventListener("input",
|
||||
commonHelper.debounce(() => {
|
||||
document.querySelector("#volume-value").textContent = `${invidiousVolumeElement.value}%`;
|
||||
browser.storage.sync.set({ invidiousVolume: invidiousVolumeElement.value });
|
||||
}, 1)
|
||||
);
|
||||
|
||||
persistInvidiousPrefs.addEventListener(
|
||||
"change",
|
||||
(event) => {
|
||||
console.info("Persist preferences (as cookie)", event.target.checked);
|
||||
browser.storage.sync.set({ persistInvidiousPrefs: event.target.checked });
|
||||
}
|
||||
);
|
||||
|
||||
const invidiousVolumeChange = commonHelper.debounce(
|
||||
() => {
|
||||
document.querySelector("#volume-value").textContent = `${invidiousVolume.value}%`;
|
||||
browser.storage.sync.set({
|
||||
invidiousVolume: invidiousVolume.value,
|
||||
});
|
||||
},
|
||||
1
|
||||
);
|
||||
invidiousVolume.addEventListener("input", invidiousVolumeChange);
|
||||
|
||||
invidiousPlayerStyle.addEventListener("change", (event) => {
|
||||
invidiousPlayerStyleElement.addEventListener("change", (event) => {
|
||||
browser.storage.sync.set({
|
||||
invidiousPlayerStyle: event.target.options[invidiousPlayerStyle.selectedIndex].value,
|
||||
invidiousPlayerStyle: event.target.options[invidiousPlayerStyleElement.selectedIndex].value,
|
||||
});
|
||||
});
|
||||
|
||||
const invidiousSubtitlesChange = commonHelper.debounce(
|
||||
() => {
|
||||
browser.storage.sync.set({ invidiousSubtitles: invidiousSubtitles.value });
|
||||
},
|
||||
500
|
||||
);
|
||||
invidiousSubtitles.addEventListener("input", invidiousSubtitlesChange);
|
||||
|
||||
invidiousAutoplay.addEventListener(
|
||||
"change",
|
||||
(event) => {
|
||||
browser.storage.sync.set({ invidiousAutoplay: event.target.checked });
|
||||
}
|
||||
invidiousSubtitlesElement.addEventListener("input",
|
||||
commonHelper.debounce(() => {
|
||||
browser.storage.sync.set({ invidiousSubtitles: invidiousSubtitlesElement.value });
|
||||
}, 500)
|
||||
);
|
||||
|
||||
const invidiousRandomPoolChange = commonHelper.debounce(
|
||||
() => {
|
||||
browser.storage.sync.set({ invidiousRandomPool: invidiousRandomPool.value });
|
||||
},
|
||||
500
|
||||
invidiousAutoplayElement.addEventListener("change", (event) => {
|
||||
browser.storage.sync.set({ invidiousAutoplay: event.target.checked });
|
||||
});
|
||||
|
||||
invidiousRandomPool.addEventListener("input",
|
||||
commonHelper.debounce(() => {
|
||||
browser.storage.sync.set({ invidiousRandomPool: invidiousRandomPool.value.split("\n") });
|
||||
}, 500)
|
||||
);
|
||||
invidiousRandomPool.addEventListener("input", invidiousRandomPoolChange);
|
||||
|
||||
|
||||
useFreeTube.addEventListener("change", (event) => {
|
||||
useFreeTubeElement.addEventListener("change", (event) => {
|
||||
browser.storage.sync.set({ useFreeTube: event.target.checked });
|
||||
});
|
||||
|
||||
alwaysProxy.addEventListener("change", (event) => {
|
||||
alwaysProxyElement.addEventListener("change", (event) => {
|
||||
browser.storage.sync.set({ alwaysProxy: event.target.checked });
|
||||
});
|
||||
|
||||
onlyEmbeddedVideo.addEventListener("change", (event) => {
|
||||
onlyEmbeddedVideoElement.addEventListener("change", (event) => {
|
||||
browser.storage.sync.set({ onlyEmbeddedVideo: event.target.checked });
|
||||
});
|
||||
|
||||
videoQuality.addEventListener("change", (event) => {
|
||||
browser.storage.sync.set({
|
||||
videoQuality: event.target.options[videoQuality.selectedIndex].value,
|
||||
});
|
||||
});
|
||||
videoQualityElement.addEventListener("change", (event) => {
|
||||
browser.storage.sync.set({ videoQuality: event.target.options[videoQualityElement.selectedIndex].value });
|
||||
});
|
||||
|
||||
browser.storage.onChanged.addListener((changes) => {
|
||||
if ("invidiousRandomPool" in changes)
|
||||
invidiousRandomPool.value = changes.invidiousRandomPool.newValue;
|
||||
})
|
Loading…
Reference in New Issue