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