2020-07-16 01:59:14 +02:00
|
|
|
"use strict";
|
2019-10-07 13:59:31 +02:00
|
|
|
|
2020-07-12 03:26:48 +02:00
|
|
|
const nitterInstances = [
|
2020-07-16 01:59:14 +02:00
|
|
|
"https://nitter.net",
|
|
|
|
"https://nitter.snopyta.org",
|
|
|
|
"https://nitter.42l.fr",
|
|
|
|
"https://nitter.nixnet.services",
|
|
|
|
"https://nitter.13ad.de",
|
|
|
|
"https://nitter.pussthecat.org",
|
|
|
|
"https://nitter.mastodont.cat",
|
|
|
|
"https://nitter.dark.fail",
|
|
|
|
"https://nitter.tedomum.net",
|
2020-11-08 11:07:03 +01:00
|
|
|
"https://nitter.cattube.org",
|
|
|
|
"https://nitter.fdn.fr",
|
|
|
|
"https://nitter.1d4.us",
|
|
|
|
"https://nitter.kavin.rocks",
|
|
|
|
"https://tweet.lambda.dance",
|
|
|
|
"https://nitter.cc",
|
|
|
|
"https://nitter.weaponizedhumiliation.com",
|
|
|
|
"https://nitter.vxempire.xyz",
|
2020-07-16 01:59:14 +02:00
|
|
|
"http://3nzoldnxplag42gqjs23xvghtzf6t6yzssrtytnntc6ppc7xxuoneoad.onion",
|
|
|
|
"http://nitter.l4qlywnpwqsluw65ts7md3khrivpirse744un3x7mlskqauz5pyuzgqd.onion",
|
2020-11-08 11:07:03 +01:00
|
|
|
"http://nitterlgj3n5fgwesu3vxc5h67ruku33nqaoeoocae2mvlzhsu6k7fqd.onion",
|
|
|
|
"http://npf37k3mtzwxreiw52ccs5ay4e6qt2fkcs2ndieurdyn2cuzzsfyfvid.onion",
|
2020-07-12 03:26:48 +02:00
|
|
|
];
|
|
|
|
const invidiousInstances = [
|
2020-07-16 01:59:14 +02:00
|
|
|
"https://invidious.snopyta.org",
|
2020-08-27 07:22:46 +02:00
|
|
|
"https://invidious.xyz",
|
2020-11-08 11:07:03 +01:00
|
|
|
"https://invidious.kavin.rocks",
|
|
|
|
"https://tube.connect.cafe",
|
|
|
|
"https://invidious.zapashcanon.fr",
|
2020-08-27 07:22:46 +02:00
|
|
|
"https://invidiou.site",
|
2020-11-08 11:07:03 +01:00
|
|
|
"https://vid.mint.lgbt",
|
|
|
|
"https://invidious.site",
|
2020-07-16 01:59:14 +02:00
|
|
|
"http://fz253lmuao3strwbfbmx46yu7acac2jz27iwtorgmbqlkurlclmancad.onion",
|
|
|
|
"http://qklhadlycap4cnod.onion",
|
|
|
|
"http://c7hqkpkpemu6e7emz5b4vyz7idjgdvgaaa3dyimmeojqbgpea3xqjoid.onion",
|
2020-11-08 11:07:03 +01:00
|
|
|
"http://w6ijuptxiku4xpnnaetxvnkc5vqcdu7mgns2u77qefoixi63vbvnpnqd.onion",
|
2020-07-12 03:26:48 +02:00
|
|
|
];
|
|
|
|
const bibliogramInstances = [
|
2020-07-16 01:59:14 +02:00
|
|
|
"https://bibliogram.art",
|
|
|
|
"https://bibliogram.snopyta.org",
|
|
|
|
"https://bibliogram.pussthecat.org",
|
|
|
|
"https://bibliogram.nixnet.services",
|
2020-11-08 11:07:03 +01:00
|
|
|
"https://bg.endl.site",
|
|
|
|
"https://bibliogram.13ad.de",
|
|
|
|
"https://bibliogram.pixelfed.uno",
|
|
|
|
"https://bibliogram.ethibox.fr",
|
2020-07-16 01:59:14 +02:00
|
|
|
"https://bibliogram.hamster.dance",
|
2020-11-08 11:07:03 +01:00
|
|
|
"https://bibliogram.kavin.rocks",
|
2020-07-16 01:59:14 +02:00
|
|
|
"https://bibliogram.ggc-project.de",
|
2020-07-12 03:26:48 +02:00
|
|
|
];
|
2020-07-16 01:59:14 +02:00
|
|
|
const osmInstances = ["https://openstreetmap.org"];
|
2020-11-08 11:07:03 +01:00
|
|
|
const oldRedditViews = ["https://old.reddit.com", "https://i.reddit.com"];
|
2020-07-12 03:26:48 +02:00
|
|
|
const autocompletes = [
|
2020-07-16 01:59:14 +02:00
|
|
|
{ id: "nitter-instance", instances: nitterInstances },
|
|
|
|
{ id: "invidious-instance", instances: invidiousInstances },
|
|
|
|
{ id: "bibliogram-instance", instances: bibliogramInstances },
|
|
|
|
{ id: "osm-instance", instances: osmInstances },
|
2020-09-06 07:21:41 +02:00
|
|
|
{ id: "old-reddit-view", instances: oldRedditViews },
|
2020-07-12 03:26:48 +02:00
|
|
|
];
|
|
|
|
|
2020-07-16 01:59:14 +02:00
|
|
|
let nitterInstance = document.getElementById("nitter-instance");
|
|
|
|
let invidiousInstance = document.getElementById("invidious-instance");
|
|
|
|
let bibliogramInstance = document.getElementById("bibliogram-instance");
|
|
|
|
let osmInstance = document.getElementById("osm-instance");
|
2020-09-06 07:21:41 +02:00
|
|
|
let oldRedditView = document.getElementById("old-reddit-view");
|
2020-07-16 01:59:14 +02:00
|
|
|
let disableNitter = document.getElementById("disable-nitter");
|
|
|
|
let disableInvidious = document.getElementById("disable-invidious");
|
|
|
|
let disableBibliogram = document.getElementById("disable-bibliogram");
|
|
|
|
let disableOsm = document.getElementById("disable-osm");
|
2020-09-06 07:21:41 +02:00
|
|
|
let disableOldReddit = document.getElementById("disable-old-reddit");
|
2020-11-08 16:03:45 +01:00
|
|
|
let disableSearchEngine = document.getElementById("disable-searchEngine");
|
2020-07-16 01:59:14 +02:00
|
|
|
let alwaysProxy = document.getElementById("always-proxy");
|
|
|
|
let onlyEmbeddedVideo = document.getElementById("only-embed");
|
|
|
|
let videoQuality = document.getElementById("video-quality");
|
|
|
|
let removeTwitterSW = document.getElementById("remove-twitter-sw");
|
|
|
|
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 theme = document.getElementById("theme");
|
2020-11-08 11:07:03 +01:00
|
|
|
let useFreeTube = document.getElementById("use-freetube");
|
|
|
|
let nitterRandomPool = document.getElementById("nitter-random-pool");
|
|
|
|
let invidiousRandomPool = document.getElementById("invidious-random-pool");
|
|
|
|
let bibliogramRandomPool = document.getElementById("bibliogram-random-pool");
|
2020-07-12 03:26:48 +02:00
|
|
|
let exceptions;
|
2019-10-07 13:59:31 +02:00
|
|
|
|
2020-02-24 04:19:56 +01:00
|
|
|
window.browser = window.browser || window.chrome;
|
|
|
|
|
2020-07-12 03:26:48 +02:00
|
|
|
function prependExceptionsItem(item, index) {
|
2020-07-16 01:59:14 +02:00
|
|
|
const li = document.createElement("li");
|
2020-04-25 16:43:43 +02:00
|
|
|
li.appendChild(document.createTextNode(item.toString()));
|
2020-07-16 01:59:14 +02:00
|
|
|
const button = document.createElement("button");
|
2020-07-12 03:26:48 +02:00
|
|
|
li.appendChild(button);
|
2020-07-16 01:59:14 +02:00
|
|
|
document.getElementById("exceptions-items").prepend(li);
|
|
|
|
const svg = `<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 512 512'>
|
2020-07-12 03:26:48 +02:00
|
|
|
<line x1='368' y1='368' x2='144' y2='144'
|
|
|
|
style='fill:none;stroke:#FFF;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px' />
|
|
|
|
<line x1='368' y1='144' x2='144' y2='368'
|
|
|
|
style='fill:none;stroke:#FFF;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px' />
|
|
|
|
</svg>`;
|
|
|
|
button.innerHTML = svg;
|
2020-07-16 01:59:14 +02:00
|
|
|
button.addEventListener("click", () => {
|
2020-07-12 03:26:48 +02:00
|
|
|
exceptions.splice(index, 1);
|
2020-04-25 16:43:43 +02:00
|
|
|
browser.storage.sync.set({
|
2020-07-16 01:59:14 +02:00
|
|
|
exceptions: exceptions,
|
2020-04-25 16:43:43 +02:00
|
|
|
});
|
2020-07-12 03:26:48 +02:00
|
|
|
li.remove();
|
2020-04-25 16:43:43 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-11-08 11:07:03 +01:00
|
|
|
function filterInstances(instances) {
|
|
|
|
return instances.filter((instance) => !instance.includes(".onion")).join();
|
|
|
|
}
|
|
|
|
|
2020-02-24 04:19:56 +01:00
|
|
|
browser.storage.sync.get(
|
2020-02-01 04:17:51 +01:00
|
|
|
[
|
2020-07-16 01:59:14 +02:00
|
|
|
"nitterInstance",
|
|
|
|
"invidiousInstance",
|
|
|
|
"bibliogramInstance",
|
|
|
|
"osmInstance",
|
2020-09-06 07:21:41 +02:00
|
|
|
"oldRedditView",
|
2020-07-16 01:59:14 +02:00
|
|
|
"disableNitter",
|
|
|
|
"disableInvidious",
|
|
|
|
"disableBibliogram",
|
|
|
|
"disableOsm",
|
2020-09-06 07:21:41 +02:00
|
|
|
"disableOldReddit",
|
2020-11-08 16:03:45 +01:00
|
|
|
"disableSearchEngine",
|
2020-07-16 01:59:14 +02:00
|
|
|
"alwaysProxy",
|
|
|
|
"onlyEmbeddedVideo",
|
|
|
|
"videoQuality",
|
|
|
|
"removeTwitterSW",
|
|
|
|
"invidiousDarkMode",
|
|
|
|
"persistInvidiousPrefs",
|
|
|
|
"invidiousVolume",
|
|
|
|
"invidiousPlayerStyle",
|
|
|
|
"invidiousSubtitles",
|
|
|
|
"invidiousAutoplay",
|
|
|
|
"exceptions",
|
|
|
|
"theme",
|
2020-11-04 11:55:42 +01:00
|
|
|
"useFreeTube",
|
2020-11-08 11:07:03 +01:00
|
|
|
"nitterRandomPool",
|
|
|
|
"invidiousRandomPool",
|
|
|
|
"bibliogramRandomPool",
|
2020-02-01 04:17:51 +01:00
|
|
|
],
|
2020-07-16 01:59:14 +02:00
|
|
|
(result) => {
|
|
|
|
theme.value = result.theme || "";
|
|
|
|
if (result.theme) document.body.classList.add(result.theme);
|
|
|
|
nitterInstance.value = result.nitterInstance || "";
|
|
|
|
invidiousInstance.value = result.invidiousInstance || "";
|
|
|
|
bibliogramInstance.value = result.bibliogramInstance || "";
|
|
|
|
osmInstance.value = result.osmInstance || "";
|
2020-09-06 07:21:41 +02:00
|
|
|
oldRedditView.value = result.oldRedditView || "";
|
2020-02-01 04:17:51 +01:00
|
|
|
disableNitter.checked = !result.disableNitter;
|
|
|
|
disableInvidious.checked = !result.disableInvidious;
|
|
|
|
disableBibliogram.checked = !result.disableBibliogram;
|
2020-02-27 02:18:50 +01:00
|
|
|
disableOsm.checked = !result.disableOsm;
|
2020-09-06 07:21:41 +02:00
|
|
|
disableOldReddit.checked = !result.disableOldReddit;
|
2020-11-08 16:03:45 +01:00
|
|
|
disableSearchEngine.checked = !result.disableSearchEngine;
|
2020-03-10 06:03:28 +01:00
|
|
|
alwaysProxy.checked = result.alwaysProxy;
|
2020-03-21 10:34:32 +01:00
|
|
|
onlyEmbeddedVideo.checked = result.onlyEmbeddedVideo;
|
2020-07-16 01:59:14 +02:00
|
|
|
videoQuality.value = result.videoQuality || "";
|
2020-03-29 01:34:46 +01:00
|
|
|
removeTwitterSW.checked = !result.removeTwitterSW;
|
2020-05-08 14:40:07 +02:00
|
|
|
invidiousDarkMode.checked = result.invidiousDarkMode;
|
|
|
|
persistInvidiousPrefs.checked = result.persistInvidiousPrefs;
|
2020-07-12 03:26:48 +02:00
|
|
|
exceptions = result.exceptions || [];
|
|
|
|
exceptions.forEach(prependExceptionsItem);
|
|
|
|
invidiousVolume.value = result.invidiousVolume;
|
2020-09-01 09:26:23 +02:00
|
|
|
document.querySelector("#volume-value").textContent = result.invidiousVolume
|
|
|
|
? `${result.invidiousVolume}%`
|
|
|
|
: " - ";
|
2020-07-16 01:59:14 +02:00
|
|
|
invidiousPlayerStyle.value = result.invidiousPlayerStyle || "";
|
|
|
|
invidiousSubtitles.value = result.invidiousSubtitles || "";
|
2020-08-28 01:17:36 +02:00
|
|
|
invidiousAutoplay.checked = result.invidiousAutoplay;
|
2020-11-04 11:55:42 +01:00
|
|
|
useFreeTube.checked = result.useFreeTube;
|
2020-11-08 11:07:03 +01:00
|
|
|
nitterRandomPool.value =
|
|
|
|
result.nitterRandomPool || filterInstances(nitterInstances);
|
|
|
|
invidiousRandomPool.value =
|
|
|
|
result.invidiousRandomPool || filterInstances(invidiousInstances);
|
|
|
|
bibliogramRandomPool.value =
|
|
|
|
result.bibliogramRandomPool || filterInstances(bibliogramInstances);
|
2019-10-07 13:59:31 +02:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2020-04-25 10:31:27 +02:00
|
|
|
function openTab(tab, event) {
|
|
|
|
let i, tabcontent, tablinks;
|
2020-07-16 01:59:14 +02:00
|
|
|
tabcontent = document.getElementsByClassName("tabcontent");
|
2020-04-25 10:31:27 +02:00
|
|
|
for (i = 0; i < tabcontent.length; i++) {
|
2020-07-16 01:59:14 +02:00
|
|
|
tabcontent[i].style.display = "none";
|
2020-04-25 10:31:27 +02:00
|
|
|
}
|
2020-07-16 01:59:14 +02:00
|
|
|
tablinks = document.getElementsByClassName("tablinks");
|
2020-04-25 10:31:27 +02:00
|
|
|
for (i = 0; i < tablinks.length; i++) {
|
2020-07-16 01:59:14 +02:00
|
|
|
tablinks[i].className = tablinks[i].className.replace(" active", "");
|
2020-04-25 10:31:27 +02:00
|
|
|
}
|
2020-07-16 01:59:14 +02:00
|
|
|
document.getElementById(tab).style.display = "block";
|
|
|
|
event.currentTarget.className += " active";
|
2020-04-25 10:31:27 +02:00
|
|
|
}
|
|
|
|
|
2020-07-16 01:59:14 +02:00
|
|
|
document
|
|
|
|
.getElementById("general-tab")
|
|
|
|
.addEventListener("click", openTab.bind(null, "general"));
|
|
|
|
document
|
|
|
|
.getElementById("advanced-tab")
|
|
|
|
.addEventListener("click", openTab.bind(null, "advanced"));
|
|
|
|
document
|
|
|
|
.getElementById("exceptions-tab")
|
|
|
|
.addEventListener("click", openTab.bind(null, "exceptions"));
|
2020-04-25 10:31:27 +02:00
|
|
|
|
2020-07-16 01:59:14 +02:00
|
|
|
document.getElementById("general-tab").click();
|
2020-04-25 16:43:43 +02:00
|
|
|
|
2020-07-12 03:26:48 +02:00
|
|
|
function addToExceptions() {
|
2020-07-16 01:59:14 +02:00
|
|
|
const input = document.getElementById("new-exceptions-item");
|
2020-07-12 03:26:48 +02:00
|
|
|
const type = document.querySelector('input[name="type"]:checked').value;
|
2020-04-25 16:43:43 +02:00
|
|
|
if (input.value) {
|
|
|
|
try {
|
2020-07-12 03:26:48 +02:00
|
|
|
let value = input.value;
|
2020-04-25 16:43:43 +02:00
|
|
|
new RegExp(input.value);
|
2020-07-16 01:59:14 +02:00
|
|
|
if (type === "URL") {
|
|
|
|
value = value.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&");
|
2020-07-12 03:26:48 +02:00
|
|
|
}
|
|
|
|
exceptions.push(value);
|
2020-04-25 16:43:43 +02:00
|
|
|
browser.storage.sync.set({
|
2020-07-16 01:59:14 +02:00
|
|
|
exceptions: exceptions,
|
2020-04-25 16:43:43 +02:00
|
|
|
});
|
2020-07-12 03:26:48 +02:00
|
|
|
prependExceptionsItem(value, exceptions.indexOf(value));
|
2020-07-16 01:59:14 +02:00
|
|
|
input.value = "";
|
2020-04-25 16:43:43 +02:00
|
|
|
} catch (error) {
|
2020-07-16 01:59:14 +02:00
|
|
|
input.setCustomValidity("Invalid RegExp");
|
2020-04-25 16:43:43 +02:00
|
|
|
}
|
|
|
|
} else {
|
2020-07-16 01:59:14 +02:00
|
|
|
input.setCustomValidity("Invalid RegExp");
|
2020-04-25 16:43:43 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-16 01:59:14 +02:00
|
|
|
document
|
|
|
|
.getElementById("add-to-exceptions")
|
|
|
|
.addEventListener("click", addToExceptions);
|
2020-04-25 10:31:27 +02:00
|
|
|
|
2020-03-21 10:34:32 +01:00
|
|
|
function debounce(func, wait, immediate) {
|
|
|
|
let timeout;
|
|
|
|
return () => {
|
2020-07-16 01:59:14 +02:00
|
|
|
let context = this,
|
|
|
|
args = arguments;
|
2020-03-21 10:34:32 +01:00
|
|
|
let later = () => {
|
|
|
|
timeout = null;
|
|
|
|
if (!immediate) func.apply(context, args);
|
|
|
|
};
|
|
|
|
let callNow = immediate && !timeout;
|
|
|
|
clearTimeout(timeout);
|
|
|
|
timeout = setTimeout(later, wait);
|
|
|
|
if (callNow) func.apply(context, args);
|
|
|
|
};
|
2020-07-16 01:59:14 +02:00
|
|
|
}
|
2020-03-21 10:34:32 +01:00
|
|
|
|
2020-05-15 01:46:01 +02:00
|
|
|
function parseURL(urlString) {
|
|
|
|
if (urlString) {
|
|
|
|
try {
|
|
|
|
const url = new URL(urlString);
|
|
|
|
if (url.username && url.password) {
|
2020-07-16 01:59:14 +02:00
|
|
|
return `${url.protocol}//${url.username}:${url.password}@${url.host}`;
|
2020-05-15 01:46:01 +02:00
|
|
|
} else {
|
|
|
|
return url.origin;
|
|
|
|
}
|
|
|
|
} catch (error) {
|
|
|
|
console.log(error);
|
2020-07-16 01:59:14 +02:00
|
|
|
return "";
|
2020-05-15 01:46:01 +02:00
|
|
|
}
|
|
|
|
} else {
|
2020-07-16 01:59:14 +02:00
|
|
|
return "";
|
2020-05-15 01:46:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-21 10:34:32 +01:00
|
|
|
let nitterInstanceChange = debounce(() => {
|
|
|
|
if (nitterInstance.checkValidity()) {
|
|
|
|
browser.storage.sync.set({
|
2020-07-16 01:59:14 +02:00
|
|
|
nitterInstance: parseURL(nitterInstance.value),
|
2020-03-21 10:34:32 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}, 500);
|
2020-07-16 01:59:14 +02:00
|
|
|
nitterInstance.addEventListener("input", nitterInstanceChange);
|
2020-03-21 10:34:32 +01:00
|
|
|
|
|
|
|
let invidiousInstanceChange = debounce(() => {
|
|
|
|
if (invidiousInstance.checkValidity()) {
|
|
|
|
browser.storage.sync.set({
|
2020-07-16 01:59:14 +02:00
|
|
|
invidiousInstance: parseURL(invidiousInstance.value),
|
2020-03-21 10:34:32 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}, 500);
|
2020-07-16 01:59:14 +02:00
|
|
|
invidiousInstance.addEventListener("input", invidiousInstanceChange);
|
2020-03-21 10:34:32 +01:00
|
|
|
|
|
|
|
let bibliogramInstanceChange = debounce(() => {
|
|
|
|
if (bibliogramInstance.checkValidity()) {
|
|
|
|
browser.storage.sync.set({
|
2020-07-16 01:59:14 +02:00
|
|
|
bibliogramInstance: parseURL(bibliogramInstance.value),
|
2020-03-21 10:34:32 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}, 500);
|
2020-07-16 01:59:14 +02:00
|
|
|
bibliogramInstance.addEventListener("input", bibliogramInstanceChange);
|
2020-03-21 10:34:32 +01:00
|
|
|
|
|
|
|
let osmInstanceChange = debounce(() => {
|
|
|
|
if (osmInstance.checkValidity()) {
|
|
|
|
browser.storage.sync.set({
|
2020-07-16 01:59:14 +02:00
|
|
|
osmInstance: parseURL(osmInstance.value),
|
2020-03-21 10:34:32 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}, 500);
|
2020-07-16 01:59:14 +02:00
|
|
|
osmInstance.addEventListener("input", osmInstanceChange);
|
2020-03-21 10:34:32 +01:00
|
|
|
|
2020-09-06 07:21:41 +02:00
|
|
|
let oldRedditViewChange = debounce(() => {
|
|
|
|
if (oldRedditView.checkValidity()) {
|
2020-09-06 04:50:59 +02:00
|
|
|
browser.storage.sync.set({
|
2020-09-06 07:21:41 +02:00
|
|
|
oldRedditView: parseURL(oldRedditView.value),
|
2020-09-06 04:50:59 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}, 500);
|
2020-09-06 07:21:41 +02:00
|
|
|
oldRedditView.addEventListener("input", oldRedditViewChange);
|
2020-09-06 04:50:59 +02:00
|
|
|
|
2020-07-16 01:59:14 +02:00
|
|
|
disableNitter.addEventListener("change", (event) => {
|
2020-03-21 10:34:32 +01:00
|
|
|
browser.storage.sync.set({ disableNitter: !event.target.checked });
|
|
|
|
});
|
|
|
|
|
2020-07-16 01:59:14 +02:00
|
|
|
disableInvidious.addEventListener("change", (event) => {
|
2020-03-21 10:34:32 +01:00
|
|
|
browser.storage.sync.set({ disableInvidious: !event.target.checked });
|
|
|
|
});
|
|
|
|
|
2020-07-16 01:59:14 +02:00
|
|
|
disableBibliogram.addEventListener("change", (event) => {
|
2020-03-21 10:34:32 +01:00
|
|
|
browser.storage.sync.set({ disableBibliogram: !event.target.checked });
|
|
|
|
});
|
|
|
|
|
2020-07-16 01:59:14 +02:00
|
|
|
disableOsm.addEventListener("change", (event) => {
|
2020-03-21 10:34:32 +01:00
|
|
|
browser.storage.sync.set({ disableOsm: !event.target.checked });
|
|
|
|
});
|
|
|
|
|
2020-09-06 07:21:41 +02:00
|
|
|
disableOldReddit.addEventListener("change", (event) => {
|
|
|
|
browser.storage.sync.set({ disableOldReddit: !event.target.checked });
|
2020-09-06 04:50:59 +02:00
|
|
|
});
|
|
|
|
|
2020-11-08 16:03:45 +01:00
|
|
|
disableSearchEngine.addEventListener("change", (event) => {
|
|
|
|
browser.storage.sync.set({ disableSearchEngine: !event.target.checked });
|
|
|
|
});
|
|
|
|
|
2020-07-16 01:59:14 +02:00
|
|
|
alwaysProxy.addEventListener("change", (event) => {
|
2020-03-21 10:34:32 +01:00
|
|
|
browser.storage.sync.set({ alwaysProxy: event.target.checked });
|
|
|
|
});
|
|
|
|
|
2020-07-16 01:59:14 +02:00
|
|
|
onlyEmbeddedVideo.addEventListener("change", (event) => {
|
2020-03-21 10:34:32 +01:00
|
|
|
browser.storage.sync.set({ onlyEmbeddedVideo: event.target.checked });
|
|
|
|
});
|
|
|
|
|
2020-07-16 01:59:14 +02:00
|
|
|
videoQuality.addEventListener("change", (event) => {
|
2020-02-24 04:19:56 +01:00
|
|
|
browser.storage.sync.set({
|
2020-07-16 01:59:14 +02:00
|
|
|
videoQuality: event.target.options[videoQuality.selectedIndex].value,
|
2019-10-07 13:59:31 +02:00
|
|
|
});
|
2020-03-21 10:34:32 +01:00
|
|
|
});
|
2020-03-29 01:34:46 +01:00
|
|
|
|
2020-07-16 01:59:14 +02:00
|
|
|
removeTwitterSW.addEventListener("change", (event) => {
|
2020-03-29 01:34:46 +01:00
|
|
|
browser.storage.sync.set({ removeTwitterSW: !event.target.checked });
|
|
|
|
});
|
2020-05-08 14:40:07 +02:00
|
|
|
|
2020-07-16 01:59:14 +02:00
|
|
|
invidiousDarkMode.addEventListener("change", (event) => {
|
2020-05-08 14:40:07 +02:00
|
|
|
browser.storage.sync.set({ invidiousDarkMode: event.target.checked });
|
|
|
|
});
|
|
|
|
|
2020-07-16 01:59:14 +02:00
|
|
|
persistInvidiousPrefs.addEventListener("change", (event) => {
|
2020-05-08 14:40:07 +02:00
|
|
|
browser.storage.sync.set({ persistInvidiousPrefs: event.target.checked });
|
|
|
|
});
|
2020-07-12 03:26:48 +02:00
|
|
|
|
2020-11-04 11:55:42 +01:00
|
|
|
useFreeTube.addEventListener("change", (event) => {
|
|
|
|
browser.storage.sync.set({ useFreeTube: event.target.checked });
|
|
|
|
});
|
|
|
|
|
2020-07-12 03:26:48 +02:00
|
|
|
let invidiousVolumeChange = debounce(() => {
|
2020-09-01 09:26:23 +02:00
|
|
|
document.querySelector(
|
|
|
|
"#volume-value"
|
|
|
|
).textContent = `${invidiousVolume.value}%`;
|
|
|
|
browser.storage.sync.set({
|
|
|
|
invidiousVolume: invidiousVolume.value,
|
|
|
|
});
|
2020-07-12 03:26:48 +02:00
|
|
|
}, 500);
|
2020-07-16 01:59:14 +02:00
|
|
|
invidiousVolume.addEventListener("input", invidiousVolumeChange);
|
2020-07-12 03:26:48 +02:00
|
|
|
|
2020-07-16 01:59:14 +02:00
|
|
|
invidiousPlayerStyle.addEventListener("change", (event) => {
|
2020-07-12 03:26:48 +02:00
|
|
|
browser.storage.sync.set({
|
2020-07-16 01:59:14 +02:00
|
|
|
invidiousPlayerStyle:
|
|
|
|
event.target.options[invidiousPlayerStyle.selectedIndex].value,
|
2020-07-12 03:26:48 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
let invidiousSubtitlesChange = debounce(() => {
|
2020-11-08 11:07:03 +01:00
|
|
|
browser.storage.sync.set({ invidiousSubtitles: invidiousSubtitles.value });
|
2020-07-12 03:26:48 +02:00
|
|
|
}, 500);
|
2020-07-16 01:59:14 +02:00
|
|
|
invidiousSubtitles.addEventListener("input", invidiousSubtitlesChange);
|
2020-07-12 03:26:48 +02:00
|
|
|
|
2020-07-16 01:59:14 +02:00
|
|
|
invidiousAutoplay.addEventListener("change", (event) => {
|
2020-08-28 01:17:36 +02:00
|
|
|
browser.storage.sync.set({ invidiousAutoplay: event.target.checked });
|
2020-07-12 03:26:48 +02:00
|
|
|
});
|
|
|
|
|
2020-11-08 11:07:03 +01:00
|
|
|
let nitterRandomPoolChange = debounce(() => {
|
|
|
|
browser.storage.sync.set({ nitterRandomPool: nitterRandomPool.value });
|
|
|
|
}, 500);
|
|
|
|
nitterRandomPool.addEventListener("input", nitterRandomPoolChange);
|
|
|
|
|
|
|
|
let invidiousRandomPoolChange = debounce(() => {
|
|
|
|
browser.storage.sync.set({ invidiousRandomPool: invidiousRandomPool.value });
|
|
|
|
}, 500);
|
|
|
|
invidiousRandomPool.addEventListener("input", invidiousRandomPoolChange);
|
|
|
|
|
|
|
|
let bibliogramRandomPoolChange = debounce(() => {
|
|
|
|
browser.storage.sync.set({
|
|
|
|
bibliogramRandomPool: bibliogramRandomPool.value,
|
|
|
|
});
|
|
|
|
}, 500);
|
|
|
|
bibliogramRandomPool.addEventListener("input", bibliogramRandomPoolChange);
|
|
|
|
|
2020-07-16 01:59:14 +02:00
|
|
|
theme.addEventListener("change", (event) => {
|
|
|
|
const value = event.target.options[theme.selectedIndex].value;
|
|
|
|
switch (value) {
|
|
|
|
case "dark-theme":
|
|
|
|
document.body.classList.add("dark-theme");
|
|
|
|
document.body.classList.remove("light-theme");
|
|
|
|
break;
|
|
|
|
case "light-theme":
|
|
|
|
document.body.classList.add("light-theme");
|
|
|
|
document.body.classList.remove("dark-theme");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
document.body.classList.remove("light-theme");
|
|
|
|
document.body.classList.remove("dark-theme");
|
|
|
|
}
|
|
|
|
browser.storage.sync.set({
|
|
|
|
theme: value,
|
|
|
|
});
|
|
|
|
});
|
2020-07-12 03:26:48 +02:00
|
|
|
|
|
|
|
function autocomplete(input, list) {
|
|
|
|
let currentFocus;
|
|
|
|
input.addEventListener("focus", (e) => {
|
2020-08-28 01:17:36 +02:00
|
|
|
showOptions(e, true);
|
2020-07-12 03:26:48 +02:00
|
|
|
});
|
|
|
|
input.addEventListener("input", (e) => {
|
|
|
|
const val = e.target.value;
|
2020-07-16 01:59:14 +02:00
|
|
|
if (!val) {
|
|
|
|
return false;
|
|
|
|
}
|
2020-07-12 03:26:48 +02:00
|
|
|
currentFocus = -1;
|
|
|
|
showOptions(e);
|
|
|
|
});
|
|
|
|
input.addEventListener("keydown", function (e) {
|
|
|
|
let x = document.getElementById(this.id + "autocomplete-list");
|
|
|
|
if (x) x = x.getElementsByTagName("div");
|
|
|
|
if (e.keyCode == 40) {
|
|
|
|
currentFocus++;
|
|
|
|
addActive(x);
|
|
|
|
} else if (e.keyCode == 38) {
|
|
|
|
currentFocus--;
|
|
|
|
addActive(x);
|
|
|
|
} else if (e.keyCode == 13) {
|
|
|
|
e.preventDefault();
|
|
|
|
if (currentFocus > -1) {
|
|
|
|
if (x) x[currentFocus].click();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2020-08-28 01:17:36 +02:00
|
|
|
function showOptions(event, showAll = false) {
|
|
|
|
let div,
|
2020-07-16 01:59:14 +02:00
|
|
|
i,
|
2020-08-28 01:17:36 +02:00
|
|
|
val = event.target.value;
|
2020-07-12 03:26:48 +02:00
|
|
|
closeAllLists();
|
2020-08-28 01:17:36 +02:00
|
|
|
div = document.createElement("div");
|
|
|
|
div.setAttribute("id", event.target.id + "autocomplete-list");
|
|
|
|
div.setAttribute("class", "autocomplete-items");
|
|
|
|
event.target.parentNode.appendChild(div);
|
2020-07-12 03:26:48 +02:00
|
|
|
for (i = 0; i < list.length; i++) {
|
|
|
|
if (list[i].toLowerCase().indexOf(val.toLowerCase()) > -1) {
|
2020-08-28 01:17:36 +02:00
|
|
|
div.appendChild(getItem(list[i], val));
|
|
|
|
} else if (showAll) {
|
|
|
|
div.appendChild(getItem(list[i], val));
|
2020-07-12 03:26:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-08-28 01:17:36 +02:00
|
|
|
function getItem(item, val) {
|
|
|
|
let div = document.createElement("div");
|
|
|
|
div.innerHTML = "<strong>" + item.substr(0, val.length) + "</strong>";
|
|
|
|
div.innerHTML += item.substr(val.length);
|
|
|
|
div.innerHTML += "<input type='hidden' value='" + item + "'>";
|
|
|
|
div.addEventListener("click", function (e) {
|
|
|
|
input.value = e.target.getElementsByTagName("input")[0].value;
|
|
|
|
input.dispatchEvent(new Event("input"));
|
|
|
|
closeAllLists();
|
|
|
|
});
|
|
|
|
return div;
|
|
|
|
}
|
2020-07-12 03:26:48 +02:00
|
|
|
function addActive(x) {
|
|
|
|
if (!x) return false;
|
|
|
|
removeActive(x);
|
|
|
|
if (currentFocus >= x.length) currentFocus = 0;
|
2020-07-16 01:59:14 +02:00
|
|
|
if (currentFocus < 0) currentFocus = x.length - 1;
|
2020-07-12 03:26:48 +02:00
|
|
|
x[currentFocus].classList.add("autocomplete-active");
|
|
|
|
}
|
|
|
|
function removeActive(x) {
|
|
|
|
for (let i = 0; i < x.length; i++) {
|
|
|
|
x[i].classList.remove("autocomplete-active");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function closeAllLists(elmnt) {
|
|
|
|
let x = document.getElementsByClassName("autocomplete-items");
|
|
|
|
for (let i = 0; i < x.length; i++) {
|
|
|
|
if (elmnt != x[i] && elmnt != input) {
|
|
|
|
x[i].parentNode.removeChild(x[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
document.addEventListener("click", (e) => {
|
2020-07-16 01:59:14 +02:00
|
|
|
if (!autocompletes.find((element) => element.id === e.target.id)) {
|
2020-07-12 03:26:48 +02:00
|
|
|
closeAllLists(e.target);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
autocompletes.forEach((value) => {
|
|
|
|
autocomplete(document.getElementById(value.id), value.instances);
|
2020-07-16 01:59:14 +02:00
|
|
|
});
|