Changing data handling

This commit is contained in:
ManeraKai 2022-02-01 21:37:43 +03:00
parent c9728f754e
commit 41c1c6effa
No known key found for this signature in database
GPG Key ID: 5ABC31FFD562E337
34 changed files with 1155 additions and 1423 deletions

View File

@ -0,0 +1,20 @@
"use strict";
let exceptions;
function setExceptions(val) {
exceptions = val;
browser.storage.sync.set({ exceptions })
};
let theme;
function setTheme(val) {
theme = val;
browser.storage.sync.set({ theme })
};
export default {
exceptions,
theme,
setTheme,
setExceptions,
}

View File

@ -1,3 +1,14 @@
import twitterHelper from "./twitter.js";
import youtubeHelper from "./youtube.js";
import instagramHelper from "./instagram.js";
import mediumHelper from "./medium.js";
import redditHelper from "./reddit.js";
import searchHelper from "./google-search.js";
import googleTranslateHelper from "./google-translate.js";
import wikipediaHelper from "./wikipedia.js";
import mapsHelper from "./google-maps.js";
import medium from "./medium.js";
function filterInstances(instances) {
let onionScan = instances.filter((instance) => !instance.includes(".onion"))
@ -21,27 +32,16 @@ function updateInstances() {
if (request.status === 200) {
const instances = JSON.parse(request.responseText);
const invidiousRandomPool = addHttps(filterInstances(instances.invidious));
const nitterRandomPool = addHttps(filterInstances(instances.nitter));
const bibliogramRandomPool = addHttps(filterInstances(instances.bibliogram));
const tedditRandomPool = addHttps(filterInstances(instances.teddit));
const simplyTranslateRandomPool = addHttps(filterInstances(instances.simplyTranslate))
const searxRandomPool = addHttps(filterInstances(instances.simplyTranslate));
const whoogleRandomPool = addHttps(filterInstances(instances.whoogle));
const wikilessRandomPool = addHttps(filterInstances(instances.wikiless));
const scribeRandomPool = addHttps(filterInstances(instances.scribe));
browser.storage.sync.set({
invidiousRandomPool,
nitterRandomPool,
bibliogramRandomPool,
tedditRandomPool,
searxRandomPool,
whoogleRandomPool,
simplyTranslateRandomPool,
wikilessRandomPool,
scribeRandomPool
});
console.info("Successfully updated Instances")
youtubeHelper.redirects = addHttps(filterInstances(instances.invidious));
twitterHelper.redirects = addHttps(filterInstances(instances.nitter));
instagramHelper.redirects = addHttps(filterInstances(instances.bibliogram));
redditHelper.redirects.libreddit = addHttps(filterInstances(instances.simplyTranslate))
redditHelper.redirects.teddit = addHttps(filterInstances(instances.teddit));
searchHelper.redirects.searx = addHttps(filterInstances(instances.simplyTranslate));
searchHelper.redirects.whoogle = addHttps(filterInstances(instances.whoogle));
wikipediaHelper.redirects = addHttps(filterInstances(instances.wikiless));
mediumHelper.redirects = addHttps(filterInstances(instances.scribe));
console.info("Successfully updated Instances");
return true;
}
return false;
@ -95,6 +95,17 @@ function updateListElement(listElement, list) {
});
}
function isFirefox() {
return typeof InstallTrigger !== "undefined";
}
function isException(url, initiator) {
return (
data.exceptions.some((regex) => regex.test(url.href)) ||
(initiator && data.exceptions.some((regex) => regex.test(initiator.href)))
);
}
export default {
filterInstances,
getRandomInstance,
@ -103,5 +114,7 @@ export default {
debounce,
validURL,
filterList,
updateListElement
updateListElement,
isFirefox,
isException,
};

View File

@ -1,5 +1,9 @@
const targets = /https?:\/\/(((www|maps)\.)?(google\.).*(\/maps)|maps\.(google\.).*)/;
const redirects = ["https://openstreetmap.org"];
const redirects = {
"normal": [
"https://openstreetmap.org"
]
};
const mapCentreRegex = /@(-?\d[0-9.]*),(-?\d[0-9.]*),(\d{1,2})[.z]/;
const dataLatLngRegex = /(!3d|!4d)(-?[0-9]{1,10}.[0-9]{1,10})/g;
const placeRegex = /\/place\/(.*)\//;
@ -40,6 +44,99 @@ function addressToLatLng(address, callback) {
xmlhttp.send();
}
let disableOsm;
const getDisableOsm = () => disableOsm;
function setDisableOsm(val) {
disableOsm = val;
browser.storage.sync.set({ disableOsm })
}
let osmInstance;
const getOsmInstance = () => osmInstance;
function setOsmInstance(val) {
osmInstance = val;
browser.storage.sync.set({ osmInstance })
};
function redirectGoogleMaps(url, initiator) {
if (disableOsm || data.isException(url, initiator))
return null;
if (initiator && initiator.host === "earth.google.com")
return null;
let redirect;
let link = commonHelper.getRandomInstance(mapsHelper.redirects.normal);
let mapCentre = "";
let params = "";
// Set map centre if present
if (url.pathname.match(mapsHelper.mapCentreRegex)) {
const [, lat, lon, zoom] = url.pathname.match(mapsHelper.mapCentreRegex);
mapCentre = `#map=${zoom}/${lat}/${lon}`;
} else if (url.search.includes("center=")) {
const [lat, lon] = url.searchParams.get("center").split(",");
mapCentre = `#map=${url.searchParams.get("zoom") || "17"}/${lat}/${lon}`;
// Set default zoom if mapCentre not present
} else {
params = "&zoom=17";
}
// Set map layer
params = `${params}&layers=${mapsHelper.layers[url.searchParams.get("layer")] || mapsHelper.layers["none"]
}`;
// Handle Google Maps Embed API
if (url.pathname.split("/").includes("embed")) {
let query = "";
if (url.searchParams.has("q")) query = url.searchParams.get("q");
else if (url.searchParams.has("query")) query = url.searchParams.has("query");
else if (url.searchParams.has("pb")) {
try {
query = url.searchParams.get("pb").split(/!2s(.*?)!/)[1];
} catch (error) {
console.error(error);
// Unable to find map marker in URL.
}
}
let marker, bbox;
mapsHelper.addressToLatLng(query, (coords, boundingbox) => {
marker = coords;
bbox = boundingbox;
});
redirect = `${link}/export/embed.html?bbox=${bbox}&layer=mapnik&marker=${marker}`;
// Handle Google Maps Directions
} else if (url.pathname.split("/").includes("dir")) {
const travelMode = mapsHelper.travelModes[url.searchParams.get("travelmode")] || mapsHelper.travelModes["driving"];
let origin;
mapsHelper.addressToLatLng(url.searchParams.get("origin"), (coords) => origin = coords);
let destination;
mapsHelper.addressToLatLng(url.searchParams.get("destination"), (coords) => destination = coords);
redirect = `${link}/directions?engine=${travelMode}&route=${origin}%3B${destination}${mapCentre}${params}`;
// Get marker from data attribute
} else if (
url.pathname.includes("data=") &&
url.pathname.match(mapsHelper.dataLatLngRegex)
) {
const [mlat, mlon] = url.pathname.match(mapsHelper.dataLatLngRegex);
redirect = `${link}/?mlat=${mlat.replace("!3d", "")}&mlon=${mlon.replace("!4d", "")}${mapCentre}${params}`;
// Get marker from ll param
} else if (url.searchParams.has("ll")) {
const [mlat, mlon] = url.searchParams.get("ll").split(",");
redirect = `${link}/?mlat=${mlat}&mlon=${mlon}${mapCentre}${params}`;
// Get marker from viewpoint param.
} else if (url.searchParams.has("viewpoint")) {
const [mlat, mlon] = url.searchParams.get("viewpoint").split(",");
redirect = `${link}/?mlat=${mlat}&mlon=${mlon}${mapCentre}${params}`;
// Use query as search if present.
} else {
let query;
if (url.searchParams.has("q")) query = url.searchParams.get("q");
else if (url.searchParams.has("query")) query = url.searchParams.get("query");
else if (url.pathname.match(mapsHelper.placeRegex)) query = url.pathname.match(mapsHelper.placeRegex)[1];
redirect = `${link}/${query ? "search?query=" + query : ""}${mapCentre || "#"}${params}`;
}
return redirect;
}
export default {
targets,
redirects,
@ -49,4 +146,9 @@ export default {
travelModes,
layers,
addressToLatLng,
getDisableOsm,
setDisableOsm,
getOsmInstance,
setOsmInstance,
redirectGoogleMaps,
};

View File

@ -4,14 +4,8 @@ const targets = [
/https?:\/\/(((www|maps)\.)?(google\.).*(\/search)|search\.(google\.).*)/
];
const redirects = {
"searx":
[
"https://3afisqjw2rxm6z7mmstyt5rx75qfqrgxnkzftknbp2vhipr2nrmrjdyd.onion",
"https://ransack.i2p",
"https://mqamk4cfykdvhw5kjez2gnvse56gmnqxn7vkvvbuor4k4j2lbbnq.b32.i2p",
"https://searxbgetrkiwxhdwi6svpgh7eotopqyxhbqiokrwzg7dcte44t36kyd.onion",
"https://suche.xyzco456vwisukfg.onion",
"https://w5rl6wsd7mzj4bdkbuqvzidet5osdsm5jhg2f7nvfidakfq5exda5wid.onion",
"searx": {
"normal": [
"https://a.searx.space",
"https://anon.sx",
"https://beezboo.com",
@ -22,7 +16,6 @@ const redirects = {
"https://metasearch.nl",
"https://nibblehole.com",
"https://northboot.xyz",
"https://4n53nafyi77iplnbrpmxnp3x4exbswwxigujaxy3b37fvr7bvlopxeyd.onion",
"https://paulgo.io",
"https://procurx.pt",
"https://putin.agency",
@ -32,7 +25,6 @@ const redirects = {
"https://search.activemail.de",
"https://search.anonymize.com",
"https://search.antonkling.se",
"https://z34ambyi6makk6ta7ksog2sljly2ctt2sa3apekb7wkllk72sxecdtad.onion",
"https://search.asynchronousexchange.com",
"https://search.biboumail.fr",
"https://search.blou.xyz",
@ -43,28 +35,22 @@ const redirects = {
"https://search.jigsaw-security.com",
"https://search.jpope.org",
"https://search.mdosch.de",
"https://search.4bkxscubgtxwvhpe.onion",
"https://search.ononoki.org",
"https://search.snopyta.org",
"https://juy4e6eicawzdrz7.onion",
"https://search.st8.at",
"https://search.stinpriza.org",
"https://z5vawdol25vrmorm4yydmohsd4u6rdoj2sylvoi3e3nqvxkvpqul7bqd.onion",
"https://search.trom.tf",
"https://search.zdechov.net",
"https://searx.bar",
"https://searx.be",
"https://searx.bissisoft.com",
"https://zbuc3bbzbfdqqo2x46repx2ddajbha6fpsjeeptjhhhhzji3zopxdqyd.onion",
"https://searx.divided-by-zero.eu",
"https://f4qfqajszpx5b7itzxt6mb7kj4ktpgbdq7lq6xaiqyqx6a7de3epptad.onion",
"https://searx.dresden.network",
"https://searx.esmailelbob.xyz",
"https://searx.everdot.org",
"https://searx.feneas.org",
"https://searx.fmac.xyz",
"https://searx.fossencdi.org",
"https://searx.cwuzdtzlubq5uual.onion",
"https://searx.gnous.eu",
"https://searx.gnu.style",
"https://searx.hardwired.link",
@ -82,7 +68,6 @@ const redirects = {
"https://searx.operationtulip.com",
"https://searx.org",
"https://searx.prvcy.eu",
"https://rq2w52kyrif3xpfihkgjnhqm3a5aqhoikpv72z3drpjglfzc2wr5z4yd.onion",
"https://searx.pwoss.org",
"https://searx.rasp.fr",
"https://searx.roughs.ru",
@ -99,7 +84,6 @@ const redirects = {
"https://searx.theanonymouse.xyz",
"https://searx.thegreenwebfoundation.org",
"https://searx.tiekoetter.com",
"https://searx3aolosaf3urwnhpynlhuokqsgz47si4pzz5hvb7uuzyjncl2tid.onion",
"https://searx.tk",
"https://searx.tux.land",
"https://searx.tuxcloud.net",
@ -107,7 +91,6 @@ const redirects = {
"https://searx.vitanetworks.link",
"https://searx.webheberg.info",
"https://searx.xkek.net",
"https://searx.bsbvtqi5oq2cqzn32zt4cr2f2z2rwots3dq7gmdcnlyqoxko2wx6reqd.onion",
"https://searx.xyz",
"https://searx.zackptg5.com",
"https://searx.zapashcanon.fr",
@ -130,8 +113,30 @@ const redirects = {
"https://xeek.com",
"searx.roflcopter.fr"
],
"whoogle":
[
"onion": [
"https://3afisqjw2rxm6z7mmstyt5rx75qfqrgxnkzftknbp2vhipr2nrmrjdyd.onion",
"https://searxbgetrkiwxhdwi6svpgh7eotopqyxhbqiokrwzg7dcte44t36kyd.onion",
"https://suche.xyzco456vwisukfg.onion",
"https://w5rl6wsd7mzj4bdkbuqvzidet5osdsm5jhg2f7nvfidakfq5exda5wid.onion",
"https://4n53nafyi77iplnbrpmxnp3x4exbswwxigujaxy3b37fvr7bvlopxeyd.onion",
"https://z34ambyi6makk6ta7ksog2sljly2ctt2sa3apekb7wkllk72sxecdtad.onion",
"https://search.4bkxscubgtxwvhpe.onion",
"https://juy4e6eicawzdrz7.onion",
"https://z5vawdol25vrmorm4yydmohsd4u6rdoj2sylvoi3e3nqvxkvpqul7bqd.onion",
"https://zbuc3bbzbfdqqo2x46repx2ddajbha6fpsjeeptjhhhhzji3zopxdqyd.onion",
"https://f4qfqajszpx5b7itzxt6mb7kj4ktpgbdq7lq6xaiqyqx6a7de3epptad.onion",
"https://searx.cwuzdtzlubq5uual.onion",
"https://rq2w52kyrif3xpfihkgjnhqm3a5aqhoikpv72z3drpjglfzc2wr5z4yd.onion",
"https://searx3aolosaf3urwnhpynlhuokqsgz47si4pzz5hvb7uuzyjncl2tid.onion",
"https://searx.bsbvtqi5oq2cqzn32zt4cr2f2z2rwots3dq7gmdcnlyqoxko2wx6reqd.onion",
],
"i2p": [
"https://ransack.i2p",
"https://mqamk4cfykdvhw5kjez2gnvse56gmnqxn7vkvvbuor4k4j2lbbnq.b32.i2p",
]
},
"whoogle": {
"normal": [
"https://s.alefvanoon.xyz",
"https://search.albony.xyz",
"https://search.exonip.de",
@ -142,9 +147,63 @@ const redirects = {
"https://www.whooglesearch.ml",
"https://whoogle.dcs0.hu",
]
}
};
let disableSearch;
const getDisableSearch = () => disableSearch;
function setDisableSearch(val) {
disableSearch = val;
browser.storage.sync.set({ disableSearch })
}
let searchInstance;
const getSearchInstance = () => searchInstance;
function setSearchInstance(val) {
searchInstance = val;
browser.storage.sync.set({ searchInstance })
};
let searchFrontend;
const getSearchFrontend = () => searchFrontend;
function setSearchFrontend(val) {
searchFrontend = val;
browser.storage.sync.set({ searchFrontend })
};
function redirect(url, initiator) {
console.info("searchFrontend:", searchFrontend)
if (disableSearch || data.isException(url, initiator)) {
return null;
}
let instance;
let path;
if (searchFrontend == 'searx') {
instance = commonHelper.getRandomInstance(searchHelper.redirects.searx.normal);
path = "/"
}
if (searchFrontend == 'whoogle') {
instance = commonHelper.getRandomInstance(searchHelper.redirects.whoogle.normal);
path = "/search"
}
let searchQuery = "";
url.search.slice(1).split("&").forEach(function (input) {
if (input.startsWith("q=")) searchQuery = input;
});
return `${instance}${path}?${searchQuery}`;
}
export default {
targets,
redirects,
getDisableSearch,
setDisableSearch,
getSearchInstance,
setSearchInstance,
getSearchFrontend,
setSearchFrontend,
redirect,
};

View File

@ -3,20 +3,47 @@ const targets = [
"translate.google.no"
];
const redirects = [
"https://translate.metalune.xyz",
"https://simplytranslate.org",
"https://st.alefvanoon.xyz",
"https://translate.josias.dev",
"https://translate.namazso.eu",
"https://translate.riverside.rocks",
"https://manerakai.asuscomm.com:447",
"https://translate.bus-hit.me"
];
const redirects = {
"normal": [
"https://translate.metalune.xyz",
"https://simplytranslate.org",
"https://st.alefvanoon.xyz",
"https://translate.josias.dev",
"https://translate.namazso.eu",
"https://translate.riverside.rocks",
"https://manerakai.asuscomm.com:447",
"https://translate.bus-hit.me"
]
};
let disableSimplyTranslate;
const getDisableSimplyTranslate = () => disableSimplyTranslate;
function setDisableSimplyTranslate(val) {
disableSimplyTranslate = val;
browser.storage.sync.set({ disableSimplyTranslate })
}
let simplyTranslateInstance;
const getSimplyTranslateInstance = () => simplyTranslateInstance;
function setSimplyTranslateInstance(val) {
simplyTranslateInstance = val;
browser.storage.sync.set({ simplyTranslateInstance })
};
function redirectGoogleTranslate(url, initiator) {
if (disableSimplyTranslate || isException(url, initiator)) return null;
return `${simplyTranslateInstance}/${url.search}`;
}
export default {
targets,
redirects,
getDisableSimplyTranslate,
setDisableSimplyTranslate,
getSimplyTranslateInstance,
setSimplyTranslateInstance,
redirectGoogleTranslate,
};

View File

@ -4,16 +4,18 @@ const targets = [
"help.instagram.com",
"about.instagram.com",
];
const redirects = [
"https://bibliogram.art",
"https://bibliogram.snopyta.org",
"https://bibliogram.pussthecat.org",
"https://bibliogram.nixnet.services",
"https://bibliogram.ethibox.fr",
"https://bibliogram.hamster.dance",
"https://insta.trom.tf",
"https://bib.actionsack.com"
];
const redirects = {
"normal": [
"https://bibliogram.art",
"https://bibliogram.snopyta.org",
"https://bibliogram.pussthecat.org",
"https://bibliogram.nixnet.services",
"https://bibliogram.ethibox.fr",
"https://bibliogram.hamster.dance",
"https://insta.trom.tf",
"https://bib.actionsack.com"
],
};
const reservedPaths = [
"about",
"explore",
@ -41,9 +43,60 @@ const reservedPaths = [
];
const bypassPaths = /\/(accounts\/|embeds?.js)/;
let disableBibliogram;
const getDisableBibliogram = () => disableBibliogram;
function setDisableBibliogram(val) {
disableBibliogram = val;
browser.storage.sync.set({ disableBibliogram })
}
let bibliogramInstance;
const getBibliogramInstance = () => bibliogramInstance;
function setBibliogramInstance(val) {
bibliogramInstance = val;
browser.storage.sync.set({ bibliogramInstance })
};
function redirect(url, initiator, type) {
if (data.disableBibliogram || data.isException(url, initiator))
return null;
// Do not redirect Bibliogram view on Instagram links
if (
initiator &&
(
initiator.origin === data.bibliogramInstance ||
instagramHelper.redirects.normal.includes(initiator.origin) ||
instagramHelper.targets.includes(initiator.host)
)
)
return null;
// Do not redirect /accounts, /embeds.js, or anything other than main_frame
if (type !== "main_frame" || url.pathname.match(instagramHelper.bypassPaths))
return null;
let link = commonHelper.getRandomInstance(instagramHelper.redirects.normal);
if (
url.pathname === "/" ||
data.instagramReservedPaths.includes(url.pathname.split("/")[1])
)
return `${link}${url.pathname}${url.search}`;
else
// Likely a user profile, redirect to '/u/...'
return `${link}/u${url.pathname}${url.search}`;
}
export default {
targets,
redirects,
reservedPaths,
bypassPaths,
getDisableBibliogram,
setDisableBibliogram,
getBibliogramInstance,
setBibliogramInstance,
redirect,
};

View File

@ -1,3 +1,5 @@
import data from "../data.js";
const targets = [
// /(.*\.medium\.com)?(?(1)|^medium\.com)/,
/^medium.com/,
@ -14,12 +16,56 @@ const targets = [
/blog.coinbase.com/
];
const redirects = [
"https://scribe.rip",
"https://scribe.nixnet.services"
];
const redirects = {
"normal": [
"https://scribe.rip",
"https://scribe.nixnet.services"
]
};
let disableScribe;
const getDisableScribe = () => disableScribe;
function setDisableScribe(val) {
disableScribe = val;
browser.storage.sync.set({ disableScribe })
}
let scribeInstance;
const getScribeInstance = () => scribeInstance;
function setScribeInstance(val) {
scribeInstance = val;
browser.storage.sync.set({ scribeInstance })
};
function redirectMedium(url, initiator) {
if (disableScribe || data.isException(url, initiator)) return null;
if (url.pathname == "/") return null;
if (
data.isFirefox() &&
initiator &&
(
initiator.origin === scribeInstance ||
mediumHelper.redirects.normal.includes(initiator.origin) ||
mediumHelper.targets.includes(initiator.host)
)
) {
browser.storage.sync.set({ redirectBypassFlag: true });
return null;
}
return `${commonHelper.getRandomInstance(mediumHelper.redirects.normal)}${url.pathname}${url.search}`;
}
export default {
targets,
redirects,
getDisableScribe,
setDisableScribe,
getScribeInstance,
setScribeInstance,
redirectMedium,
};

View File

@ -8,45 +8,119 @@ const targets = [
];
const redirects = {
// modern UI
"libreddit": [
"https://libredd.it",
"https://libreddit.spike.codes",
"https://libreddit.kavin.rocks",
"https://libreddit.insanity.wtf",
"https://libreddit.dothq.co",
"https://libreddit.silkky.cloud",
"https://libreddit.himiko.cloud",
"https://reddit.artemislena.eu",
"https://reddit.git-bruh.duckdns.org",
],
"libreddit": {
"normal": [
"https://libredd.it",
"https://libreddit.spike.codes",
"https://libreddit.kavin.rocks",
"https://libreddit.insanity.wtf",
"https://libreddit.dothq.co",
"https://libreddit.silkky.cloud",
"https://libreddit.himiko.cloud",
"https://reddit.artemislena.eu",
"https://reddit.git-bruh.duckdns.org",
]
},
// old UI
"teddit": [
"https://teddit.net",
"https://teddit.ggc-project.de",
"https://teddit.kavin.rocks",
"https://teddit.zaggy.nl",
"https://teddit.namazso.eu",
"https://teddit.nautolan.racing",
"https://teddit.tinfoil-hat.net",
"https://teddit.domain.glass",
"https://snoo.ioens.is",
"https://teddit.httpjames.space",
"https://teddit.alefvanoon.xyz",
"https://incogsnoo.com",
"https://teddit.pussthecat.org",
"https://reddit.lol",
"https://teddit.sethforprivacy.com",
"https://teddit.totaldarkness.net",
"https://teddit.adminforge.de",
"https://teddit.bus-hit.me"
],
"teddit": {
"normal": [
"https://teddit.net",
"https://teddit.ggc-project.de",
"https://teddit.kavin.rocks",
"https://teddit.zaggy.nl",
"https://teddit.namazso.eu",
"https://teddit.nautolan.racing",
"https://teddit.tinfoil-hat.net",
"https://teddit.domain.glass",
"https://snoo.ioens.is",
"https://teddit.httpjames.space",
"https://teddit.alefvanoon.xyz",
"https://incogsnoo.com",
"https://teddit.pussthecat.org",
"https://reddit.lol",
"https://teddit.sethforprivacy.com",
"https://teddit.totaldarkness.net",
"https://teddit.adminforge.de",
"https://teddit.bus-hit.me"
],
},
"desktop": "https://old.reddit.com", // desktop
"mobile": "https://i.reddit.com", // mobile
};
const bypassPaths = /\/(gallery\/poll\/rpan\/settings\/topics)/;
let disableReddit;
const getDisableReddit = () => disableReddit;
function setDisableReddit(val) {
disableReddit = val;
browser.storage.sync.set({ disableReddit })
}
let redditInstance;
const getRedditInstance = () => redditInstance;
function setRedditInstance(val) {
redditInstance = val;
browser.storage.sync.set({ redditInstance })
};
let redditFrontend;
const getRedditFrontend = () => redditFrontend;
function setRedditFrontend(val) {
redditFrontend = val;
browser.storage.sync.set({ redditFrontend })
};
function redirect(url, initiator, type) {
if (disableReddit || data.isException(url, initiator))
return null;
// Do not redirect when already on the selected view
if ((initiator && initiator.origin === redditInstance) || url.origin === redditInstance)
return null;
// Do not redirect exclusions nor anything other than main_frame
if (type !== "main_frame" || url.pathname.match(redditHelper.bypassPaths))
return null;
let libredditLink = commonHelper.getRandomInstance(redditHelper.redirects.libreddit.normal);
let tedditLink = commonHelper.getRandomInstance(redditHelper.redirects.teddit.normal);
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 `${libredditLink}/img${url.pathname}${url.search}`;
else if (url.host === "redd.it") {
if (redditFrontend == 'libreddit') return `${libredditLink}${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
// 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 `${tedditLink}/comments${url.pathname}${url.search}`;
}
if (redditFrontend == 'libreddit') return `${libredditLink}${url.pathname}${url.search}`;
if (redditFrontend == 'teddit') return `${tedditLink}${url.pathname}${url.search}`;
}
export default {
targets,
redirects,
bypassPaths,
getDisableReddit,
setDisableReddit,
getRedditInstance,
setRedditInstance,
getRedditFrontend,
setRedditFrontend,
redirect,
};

View File

@ -1,3 +1,4 @@
import data from "../data.js";
/*
Please remember to also update the src/manifest.json file
(content_scripts > matches, 'remove-twitter-sw.js')
@ -15,30 +16,86 @@ const targets = [
src/assets/javascripts/remove-twitter-sw.js file
(const nitterInstances) when updating this list:
*/
const redirects = [
"https://nitter.net",
"https://nitter.snopyta.org",
"https://nitter.42l.fr",
"https://nitter.nixnet.services",
"https://nitter.pussthecat.org",
"https://nitter.dark.fail",
"https://nitter.tedomum.net",
"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.vxempire.xyz",
"https://nitter.unixfox.eu",
"https://bird.trom.tf",
"http://3nzoldnxplag42gqjs23xvghtzf6t6yzssrtytnntc6ppc7xxuoneoad.onion",
"http://nitter.l4qlywnpwqsluw65ts7md3khrivpirse744un3x7mlskqauz5pyuzgqd.onion",
"http://nitterlgj3n5fgwesu3vxc5h67ruku33nqaoeoocae2mvlzhsu6k7fqd.onion",
"http://npf37k3mtzwxreiw52ccs5ay4e6qt2fkcs2ndieurdyn2cuzzsfyfvid.onion",
];
const redirects = {
"normal": [
"https://nitter.net",
"https://nitter.snopyta.org",
"https://nitter.42l.fr",
"https://nitter.nixnet.services",
"https://nitter.pussthecat.org",
"https://nitter.dark.fail",
"https://nitter.tedomum.net",
"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.vxempire.xyz",
"https://nitter.unixfox.eu",
"https://bird.trom.tf",
],
"onion": [
"http://3nzoldnxplag42gqjs23xvghtzf6t6yzssrtytnntc6ppc7xxuoneoad.onion",
"http://nitter.l4qlywnpwqsluw65ts7md3khrivpirse744un3x7mlskqauz5pyuzgqd.onion",
"http://nitterlgj3n5fgwesu3vxc5h67ruku33nqaoeoocae2mvlzhsu6k7fqd.onion",
"http://npf37k3mtzwxreiw52ccs5ay4e6qt2fkcs2ndieurdyn2cuzzsfyfvid.onion",
]
};
let disableNitter;
const getDisableNitter = () => disableNitter;
function setDisableNitter(val) {
disableNitter = val;
browser.storage.sync.set({ disableNitter })
}
let nitterInstance;
const getNitterInstance = () => nitterInstance;
function setNitterInstance(val) {
nitterInstance = val;
browser.storage.sync.set({ nitterInstance })
}
function redirect(url, initiator) {
if (disableNitter || data.isException(url, initiator))
return null;
if (url.pathname.split("/").includes("home")) {
return null;
}
if (
data.isFirefox() &&
initiator &&
(
initiator.origin === nitterInstance ||
twitterHelper.redirects.normal.includes(initiator.origin) ||
twitterHelper.targets.includes(initiator.host)
)
) {
browser.storage.sync.set({ redirectBypassFlag: true });
return null;
}
let link = commonHelper.getRandomInstance(twitterHelper.redirects.normal)
if (url.host.split(".")[0] === "pbs" || url.host.split(".")[0] === "video")
return `${link}/pic/${encodeURIComponent(url.href)}`;
else if (url.pathname.split("/").includes("tweets"))
return `${link}${url.pathname.replace("/tweets", "")}${url.search}`;
else
return `${link}${url.pathname}${url.search}`;
}
export default {
targets,
redirects,
getDisableNitter,
setDisableNitter,
getNitterInstance,
setNitterInstance,
redirect,
};

View File

@ -1,8 +1,65 @@
const targets = /wikipedia.org/;
const redirects = ["https://wikiless.org"];
const redirects = {
"normal": [
"https://wikiless.org"
]
};
let disableWikipedia;
function setDisableWikipedia(val) {
disableWikipedia = val;
browser.storage.sync.set({ disableWikipedia })
}
const getDisableWikipedia = () => disableWikipedia;
let wikipediaInstance;
function setWikipediaInstance(val) {
wikipediaInstance = val;
browser.storage.sync.set({ wikipediaInstance })
};
const getWikipediaInstance = () => wikipediaInstance;
function redirectWikipedia(url, initiator) {
if (disableWikipedia || data.isException(url, initiator)) return null;
let GETArguments = [];
if (url.search.length > 0) {
let search = url.search.substring(1); //get rid of '?'
let argstrings = search.split("&");
for (let i = 0; i < argstrings.length; i++) {
let args = argstrings[i].split("=");
GETArguments.push([args[0], args[1]]);
}
}
let link = `${wikipediaInstance}${url.pathname}`;
let urlSplit = url.host.split(".");
if (urlSplit[0] != "wikipedia" && urlSplit[0] != "www") {
if (urlSplit[0] == "m")
GETArguments.push(["mobileaction", "toggle_view_mobile"]);
else GETArguments.push(["lang", urlSplit[0]]);
if (urlSplit[1] == "m")
GETArguments.push(["mobileaction", "toggle_view_mobile"]);
//wikiless doesn't have mobile view support yet
}
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"
)
//just in case someone wanted to visit wikipedia.org.foo.bar.net
return link;
else return null;
}
export default {
setDisableWikipedia,
getDisableWikipedia,
setWikipediaInstance,
getWikipediaInstance,
redirectWikipedia,
targets,
redirects,
};

View File

@ -1,3 +1,7 @@
"use strict";
window.browser = window.browser || window.chrome;
const targets = [
"m.youtube.com",
"youtube.com",
@ -14,33 +18,278 @@ const targets = [
(content_scripts > matches, 'persist-invidious-prefs.js')
when updating this list:
*/
const redirects = [
"https://invidious.snopyta.org",
"https://invidious.xyz",
"https://invidious.kavin.rocks",
"https://tube.connect.cafe",
"https://invidious.zapashcanon.fr",
"https://invidiou.site",
"https://vid.mint.lgbt",
"https://invidious.site",
"https://yewtu.be",
"https://invidious.tube",
"https://invidious.silkky.cloud",
"https://invidious.himiko.cloud",
"https://inv.skyn3t.in",
"https://tube.incognet.io",
"https://invidious.tinfoil-hat.net",
"https://invidious.namazso.eu",
"https://vid.puffyan.us",
"https://dev.viewtube.io",
"https://invidious.048596.xyz",
"http://fz253lmuao3strwbfbmx46yu7acac2jz27iwtorgmbqlkurlclmancad.onion",
"http://qklhadlycap4cnod.onion",
"http://c7hqkpkpemu6e7emz5b4vyz7idjgdvgaaa3dyimmeojqbgpea3xqjoid.onion",
"http://w6ijuptxiku4xpnnaetxvnkc5vqcdu7mgns2u77qefoixi63vbvnpnqd.onion",
];
const redirects = {
"normal": [
"https://invidious.snopyta.org",
"https://invidious.xyz",
"https://invidious.kavin.rocks",
"https://tube.connect.cafe",
"https://invidious.zapashcanon.fr",
"https://invidiou.site",
"https://vid.mint.lgbt",
"https://invidious.site",
"https://yewtu.be",
"https://invidious.tube",
"https://invidious.silkky.cloud",
"https://invidious.himiko.cloud",
"https://inv.skyn3t.in",
"https://tube.incognet.io",
"https://invidious.tinfoil-hat.net",
"https://invidious.namazso.eu",
"https://vid.puffyan.us",
"https://dev.viewtube.io",
"https://invidious.048596.xyz",
],
"onion": [
"http://fz253lmuao3strwbfbmx46yu7acac2jz27iwtorgmbqlkurlclmancad.onion",
"http://qklhadlycap4cnod.onion",
"http://c7hqkpkpemu6e7emz5b4vyz7idjgdvgaaa3dyimmeojqbgpea3xqjoid.onion",
"http://w6ijuptxiku4xpnnaetxvnkc5vqcdu7mgns2u77qefoixi63vbvnpnqd.onion",
]
};
let disableInvidious;
const getDisableInvidious = () => disableInvidious;
function setDisableInvidious(val) {
disableInvidious = val;
browser.storage.sync.set({ disableInvidious })
console.log("disableInvidious: ", disableInvidious)
}
let invidiousInstance;
const getInvidiousInstance = () => invidiousInstance;
function setInvidiousInstance(val) {
invidiousInstance = val;
browser.storage.sync.set({ invidiousInstance })
console.log("invidiousInstance: ", invidiousInstance)
}
let invidiousAlwaysProxy;
function setInvidiousAlwaysProxy(val) {
invidiousAlwaysProxy = val;
browser.storage.sync.set({ invidiousAlwaysProxy })
console.log("invidiousAlwaysProxy: ", invidiousAlwaysProxy);
}
const getInvidiousAlwaysProxy = () => invidiousAlwaysProxy;
let invidiousOnlyEmbeddedVideo;
function setInvidiousOnlyEmbeddedVideo(val) {
invidiousOnlyEmbeddedVideo = val;
browser.storage.sync.set({ invidiousOnlyEmbeddedVideo })
console.log("invidiousOnlyEmbeddedVideo: ", invidiousOnlyEmbeddedVideo)
}
const getInvidiousOnlyEmbeddedVideo = () => invidiousOnlyEmbeddedVideo;
let invidiousVideoQuality;
function setInvidiousVideoQuality(val) {
invidiousVideoQuality = val;
browser.storage.sync.set({ invidiousVideoQuality })
console.log("invidiousVideoQuality: ", invidiousVideoQuality)
}
const getInvidiousVideoQuality = () => invidiousVideoQuality;
let invidiousDarkMode;
const getInvidiousDarkMode = () => invidiousDarkMode;
function setInvidiousDarkMode(val) {
invidiousDarkMode = val;
browser.storage.sync.set({ invidiousDarkMode })
console.log("invidiousDarkMode: ", invidiousDarkMode)
}
let invidiousVolume;
const getInvidiousVolume = () => invidiousVolume;
function setInvidiousVolume(val) {
invidiousVolume = val;
browser.storage.sync.set({ invidiousVolume })
console.log("invidiousVolume: ", invidiousVolume)
}
let invidiousPlayerStyle;
const getInvidiousPlayerStyle = () => invidiousPlayerStyle;
function setInvidiousPlayerStyle(val) {
invidiousPlayerStyle = val;
browser.storage.sync.set({ invidiousPlayerStyle })
console.log("invidiousPlayerStyle: ", invidiousPlayerStyle)
}
let invidiousSubtitles;
function setInvidiousSubtitles(val) {
invidiousSubtitles = val;
browser.storage.sync.set({ invidiousSubtitles })
console.log("invidiousSubtitles: ", invidiousSubtitles)
}
let getInvidiousSubtitles = () => invidiousSubtitles;
let invidiousAutoplay;
function setInvidiousAutoplay(val) {
invidiousAutoplay = val;
browser.storage.sync.set({ invidiousAutoplay })
console.log("invidiousAutoplay: ", invidiousAutoplay)
}
const getInvidiousAutoplay = () => invidiousAutoplay;
let useFreeTube;
function setUseFreeTube(val) {
useFreeTube = val;
browser.storage.sync.set({ useFreeTube })
console.log("useFreeTube: ", useFreeTube)
}
const getUseFreeTube = () => useFreeTube;
let persistInvidiousPrefs;
function setPersistInvidiousPrefs(val) {
persistInvidiousPrefs = val;
browser.storage.sync.set({ persistInvidiousPrefs })
console.log("persistInvidiousPrefs: ", persistInvidiousPrefs)
if (persistInvidiousPrefs) initInvidiousCookie()
}
const getPersistInvidiousPrefs = () => persistInvidiousPrefs;
function redirect(url, initiator, type) {
if (disableInvidious || data.isException(url, initiator))
return null;
if (
initiator &&
(
initiator.origin === invidiousInstance ||
youtubeHelper.redirects.normal.includes(initiator.origin) ||
youtubeHelper.targets.includes(initiator.host)
)
)
return null;
if (url.pathname.match(/iframe_api/) || url.pathname.match(/www-widgetapi/))
// Don't redirect YouTube Player API.
return null;
if (url.host.split(".")[0] === "studio")
// Avoid redirecting `studio.youtube.com`
return null;
if (invidiousOnlyEmbeddedVideo && type !== "sub_frame")
return null;
if (useFreeTube && type === "main_frame")
return `freetube://${url}`;
// Apply settings
if (invidiousAlwaysProxy) url.searchParams.append("local", true);
if (invidiousVideoQuality) url.searchParams.append("quality", invidiousVideoQuality);
if (invidiousDarkMode) url.searchParams.append("dark_mode", invidiousDarkMode);
if (invidiousVolume) url.searchParams.append("volume", invidiousVolume);
if (invidiousPlayerStyle) url.searchParams.append("player_style", invidiousPlayerStyle);
if (invidiousSubtitles) url.searchParams.append("subtitles", invidiousSubtitles);
if (invidiousAutoplay) url.searchParams.append("autoplay", 1);
let randomInstance = commonHelper.getRandomInstance(youtubeHelper.redirects.normal)
return `${randomInstance}${url.pathname.replace("/shorts", "")}${url.search}`;
}
function getCookie() {
let ca = document.cookie.split(";");
for (let i = 0; i < ca.length; i++) {
let c = ca[i];
while (c.charAt(0) == " ") c = c.substring(1, c.length);
if (c.indexOf("PREFS=") == 0)
return JSON.parse(
decodeURIComponent(c.substring("PREFS=".length, c.length))
);
}
return {};
}
function initInvidiousCookie() {
const prefs = getCookie();
prefs.local = invidiousAlwaysProxy;
prefs.quality = invidiousVideoQuality;
prefs.dark_mode = invidiousDarkMode;
document.cookie = `PREFS=${encodeURIComponent(JSON.stringify(prefs))}`;
}
async function init() {
let result = await browser.storage.sync.get(
[
"invidiousAlwaysProxy",
"invidiousVideoQuality",
"invidiousDarkMode",
"persistInvidiousPrefs",
"disableInvidious",
"invidiousInstance",
"invidiousAlwaysProxy",
"invidiousOnlyEmbeddedVideo",
"invidiousVideoQuality",
"invidiousDarkMode",
"invidiousVolume",
"invidiousPlayerStyle",
"invidiousSubtitles",
"invidiousAutoplay",
"useFreeTube",
]);
disableInvidious = result.disableInvidious;
invidiousInstance = result.invidiousInstance;
invidiousAlwaysProxy = result.invidiousAlwaysProxy;
invidiousOnlyEmbeddedVideo = result.invidiousOnlyEmbeddedVideo;
invidiousVideoQuality = result.invidiousVideoQuality;
invidiousDarkMode = result.invidiousDarkMode;
invidiousVolume = result.invidiousVolume;
invidiousPlayerStyle = result.invidiousPlayerStyle;
invidiousSubtitles = result.invidiousSubtitles;
invidiousAutoplay = result.invidiousAutoplay;
useFreeTube = result.useFreeTube;
if (result.persistInvidiousPrefs) initInvidiousCookie();
}
export default {
targets,
redirects,
redirect,
getDisableInvidious,
setDisableInvidious,
setInvidiousInstance,
getInvidiousInstance,
setInvidiousAlwaysProxy,
getInvidiousAlwaysProxy,
setInvidiousOnlyEmbeddedVideo,
getInvidiousOnlyEmbeddedVideo,
setInvidiousVideoQuality,
getInvidiousVideoQuality,
setInvidiousDarkMode,
getInvidiousDarkMode,
setInvidiousVolume,
getInvidiousVolume,
setInvidiousPlayerStyle,
getInvidiousPlayerStyle,
setInvidiousSubtitles,
getInvidiousSubtitles,
setInvidiousAutoplay,
getInvidiousAutoplay,
getUseFreeTube,
setUseFreeTube,
getPersistInvidiousPrefs,
setPersistInvidiousPrefs,
init,
};

View File

@ -1,30 +0,0 @@
"use strict";
window.browser = window.browser || window.chrome;
function getCookie() {
let ca = document.cookie.split(";");
for (let i = 0; i < ca.length; i++) {
let c = ca[i];
while (c.charAt(0) == " ") c = c.substring(1, c.length);
if (c.indexOf("PREFS=") == 0) {
return JSON.parse(
decodeURIComponent(c.substring("PREFS=".length, c.length))
);
}
}
return {};
}
browser.storage.sync.get(
["invidiousAlwaysProxy", "invidiousVideoQuality", "invidiousDarkMode", "persistInvidiousPrefs"],
(result) => {
if (result.persistInvidiousPrefs) {
const prefs = getCookie();
prefs.local = result.invidiousAlwaysProxy;
prefs.quality = result.invidiousVideoQuality;
prefs.dark_mode = result.invidiousDarkMode;
document.cookie = `PREFS=${encodeURIComponent(JSON.stringify(prefs))}`;
}
}
);

View File

@ -1,7 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script type="module" src="background.js"></script>
</head>
</html>
<head>
<meta charset="utf-8" />
<script type="module" src="../../assets/javascripts/data.js"></script>
<script type="module" src="background.js"></script>
</head>
</html>

View File

@ -1,585 +1,29 @@
"use strict";
import commonHelper from "../../assets/javascripts/helpers/common.js";
import mapsHelper from "../../assets/javascripts/helpers/google-maps.js";
import twitterHelper from "../../assets/javascripts/helpers/twitter.js";
import youtubeHelper from "../../assets/javascripts/helpers/youtube.js";
import instagramHelper from "../../assets/javascripts/helpers/instagram.js";
import mapsHelper from "../../assets/javascripts/helpers/google-maps.js";
import mediumHelper from "../../assets/javascripts/helpers/medium.js";
import redditHelper from "../../assets/javascripts/helpers/reddit.js";
import searchHelper from "../../assets/javascripts/helpers/google-search.js";
import googleTranslateHelper from "../../assets/javascripts/helpers/google-translate.js";
import wikipediaHelper from "../../assets/javascripts/helpers/wikipedia.js";
const nitterInstances = twitterHelper.redirects;
const twitterDomains = twitterHelper.targets;
const youtubeDomains = youtubeHelper.targets;
const mediumDomains = mediumHelper.targets;
const scribeInstances = mediumHelper.redirects;
const scribeDefault = mediumHelper.redirects[0];
const invidiousInstances = youtubeHelper.redirects;
const instagramDomains = instagramHelper.targets;
const bibliogramInstances = instagramHelper.redirects;
const instagramReservedPaths = instagramHelper.reservedPaths;
const bibliogramBypassPaths = instagramHelper.bypassPaths;
const osmDefault = mapsHelper.redirects[0];
const googleMapsRegex = mapsHelper.targets;
const mapCentreRegex = mapsHelper.mapCentreRegex;
const dataLatLngRegex = mapsHelper.dataLatLngRegex;
const placeRegex = mapsHelper.placeRegex;
const travelModes = mapsHelper.travelModes;
const layers = mapsHelper.layers;
const redditInstances = redditHelper.redirects;
const redditDomains = redditHelper.targets;
const redditBypassPaths = redditHelper.bypassPaths;
const redditDefault = redditHelper.redirects[0];
const googleSearchRegex = searchHelper.targets;
const searchInstances = searchHelper.redirects;
const simplyTranslateInstances = googleTranslateHelper.redirects;
const simplyTranslateDefault = simplyTranslateInstances[0];
const googleTranslateDomains = googleTranslateHelper.targets;
const wikipediaInstances = wikipediaHelper.redirects;
const wikipediaDefault = wikipediaInstances[0];
const wikipediaRegex = wikipediaHelper.targets;
let disableNitter;
let disableInvidious;
let disableBibliogram;
let disableOsm;
let disableReddit;
let disableScribe;
let disableSearch;
let disableSimplyTranslate;
let disableWikipedia;
let nitterInstance;
let invidiousInstance;
let bibliogramInstance;
let osmInstance;
let scribeInstance;
let redditInstance;
let searchInstance;
let simplyTranslateInstance;
let wikipediaInstance;
let invidiousAlwaysProxy;
let invidiousOnlyEmbeddedVideo;
let invidiousVideoQuality;
let invidiousDarkMode;
let invidiousVolume;
let invidiousPlayerStyle;
let invidiousSubtitles;
let invidiousAutoplay;
let useFreeTube;
let nitterRandomPool;
let invidiousRandomPool;
let bibliogramRandomPool;
let scribeRandomPool;
let exceptions;
let redditFrontend;
let searchFrontend;
import data from "../../assets/javascripts/data.js";
import googleMaps from "../../assets/javascripts/helpers/google-maps.js";
window.browser = window.browser || window.chrome;
browser.storage.sync.get(
[
"nitterInstance",
"invidiousInstance",
"bibliogramInstance",
"osmInstance",
"redditInstance",
"scribeInstance",
"searchInstance",
"simplyTranslateInstance",
"wikipediaInstance",
"disableNitter",
"disableInvidious",
"disableBibliogram",
"disableOsm",
"disableReddit",
"disableScribe",
"disableSearch",
"disableSimplyTranslate",
"disableWikipedia",
"invidiousAlwaysProxy",
"invidiousOnlyEmbeddedVideo",
"invidiousVideoQuality",
"invidiousDarkMode",
"invidiousVolume",
"invidiousPlayerStyle",
"invidiousSubtitles",
"invidiousAutoplay",
"useFreeTube",
"nitterRandomPool",
"invidiousRandomPool",
"bibliogramRandomPool",
"scribeRandomPool",
"wikilessRandomPool",
"exceptions",
"redditFrontend",
"searchFrontend",
],
(result) => {
osmInstance = result.osmInstance || osmDefault;
disableOsm = result.disableOsm;
// data.osmInstance = result.osmInstance || data.osmDefault;
// data.simplyTranslateInstance = result.simplyTranslateInstance || data.simplyTranslateDefault;
// data.wikipediaInstance = result.wikipediaInstance || data.wikipediaDefault;
// data.exceptions = result.exceptions
// ? result.exceptions.map((e) => {
// return new RegExp(e);
// })
// : [];
// data.invidiousSubtitles = result.invidiousSubtitles || "";
searchInstance = result.searchInstance;
disableSearch = result.disableSearch;
searchFrontend = result.searchFrontend;
simplyTranslateInstance = result.simplyTranslateInstance || simplyTranslateDefault;
disableSimplyTranslate = result.disableSimplyTranslate;
redditInstance = result.redditInstance;
disableReddit = result.disableReddit;
redditFrontend = result.redditFrontend;
disableWikipedia = result.disableWikipedia;
wikipediaInstance = result.wikipediaInstance || wikipediaDefault;
exceptions = result.exceptions
? result.exceptions.map((e) => {
return new RegExp(e);
})
: [];
invidiousOnlyEmbeddedVideo = result.invidiousOnlyEmbeddedVideo;
invidiousDarkMode = result.invidiousDarkMode;
disableInvidious = result.disableInvidious;
invidiousAlwaysProxy = result.invidiousAlwaysProxy;
invidiousInstance = result.invidiousInstance;
invidiousVideoQuality = result.invidiousVideoQuality;
invidiousVolume = result.invidiousVolume;
invidiousPlayerStyle = result.invidiousPlayerStyle;
invidiousSubtitles = result.invidiousSubtitles || "";
invidiousAutoplay = result.invidiousAutoplay;
useFreeTube = result.useFreeTube;
invidiousRandomPool =
result.invidiousRandomPool
? result.invidiousRandomPool
: commonHelper.filterInstances(invidiousInstances);
nitterInstance = result.nitterInstance;
disableNitter = result.disableNitter;
nitterRandomPool =
result.nitterRandomPool
? result.nitterRandomPool
: commonHelper.filterInstances(nitterInstances);
bibliogramInstance = result.bibliogramInstance;
disableBibliogram = result.disableBibliogram;
bibliogramRandomPool =
result.bibliogramRandomPool
? result.bibliogramRandomPool
: commonHelper.filterInstances(bibliogramInstances);
scribeInstance = result.scribeInstance;
disableScribe = result.disableScribe;
scribeRandomPool =
result.scribeRandomPool
? result.scribeRandomPool
: commonHelper.filterInstances(scribeInstances);
}
);
browser.storage.onChanged.addListener((changes) => {
if ("invidiousInstance" in changes) invidiousInstance = changes.invidiousInstance.newValue;
if ("disableInvidious" in changes) disableInvidious = changes.disableInvidious.newValue;
if ("invidiousAlwaysProxy" in changes) invidiousAlwaysProxy = changes.invidiousAlwaysProxy.newValue;
if ("invidiousOnlyEmbeddedVideo" in changes) invidiousOnlyEmbeddedVideo = changes.invidiousOnlyEmbeddedVideo.newValue;
if ("invidiousVideoQuality" in changes) invidiousVideoQuality = changes.invidiousVideoQuality.newValue;
if ("invidiousDarkMode" in changes) invidiousDarkMode = changes.invidiousDarkMode.newValue;
if ("invidiousVolume" in changes) invidiousVolume = changes.invidiousVolume.newValue;
if ("invidiousPlayerStyle" in changes) invidiousPlayerStyle = changes.invidiousPlayerStyle.newValue;
if ("invidiousSubtitles" in changes) invidiousSubtitles = changes.invidiousSubtitles.newValue;
if ("invidiousAutoplay" in changes) invidiousAutoplay = changes.invidiousAutoplay.newValue;
if ("useFreeTube" in changes) useFreeTube = changes.useFreeTube.newValue;
if ("invidiousRandomPool" in changes) invidiousRandomPool = changes.invidiousRandomPool.newValue;
if ("nitterInstance" in changes) nitterInstance = changes.nitterInstance.newValue;
if ("disableNitter" in changes) disableNitter = changes.disableNitter.newValue;
if ("nitterRandomPool" in changes) nitterRandomPool = changes.nitterRandomPool.newValue;
if ("bibliogramInstance" in changes) bibliogramInstance = changes.bibliogramInstance.newValue;
if ("disableBibliogram" in changes) disableBibliogram = changes.disableBibliogram.newValue;
if ("bibliogramRandomPool" in changes) bibliogramRandomPool = changes.bibliogramRandomPool.newValue;
if ("redditInstance" in changes) redditInstance = changes.redditInstance.newValue || redditDefault;
if ("disableReddit" in changes) disableReddit = changes.disableReddit.newValue;
if ("redditFrontend" in changes) redditFrontend = changes.redditFrontend.newValue
if ("searchInstance" in changes) searchInstance = changes.searchInstance.newValue;
if ("disableSearch" in changes) disableSearch = changes.disableSearch.newValue;
if ("searchFrontend" in changes) searchFrontend = changes.searchFrontend.newValue
if ("simplyTranslateInstance" in changes) simplyTranslateInstance = changes.simplyTranslateInstance.newValue || simplyTranslateDefault;
if ("disableSimplyTranslate" in changes) disableSimplyTranslate = changes.disableSimplyTranslate.newValue;
if ("osmInstance" in changes) osmInstance = changes.osmInstance.newValue || osmDefault;
if ("disableOsm" in changes) disableOsm = changes.disableOsm.newValue;
if ("wikipediaInstance" in changes) wikipediaInstance = changes.wikipediaInstance.newValue || wikipediaDefault;
if ("disableWikipedia" in changes) disableWikipedia = changes.disableWikipedia.newValue;
if ("scribeInstance" in changes) scribeInstance = changes.scribeInstance.newValue || scribeDefault;
if ("disableScribe" in changes) disableScribe = changes.disableScribe.newValue;
if ("scribeRandomPool" in changes) scribeRandomPool = changes.scribeRandomPool.newValue;
if ("exceptions" in changes) exceptions = changes.exceptions.newValue.map((e) => new RegExp(e));
});
function isException(url, initiator) {
return (
exceptions.some((regex) => regex.test(url.href)) ||
(initiator && exceptions.some((regex) => regex.test(initiator.href)))
);
}
function isFirefox() {
return typeof InstallTrigger !== "undefined";
}
function redirectYouTube(url, initiator, type) {
if (disableInvidious || isException(url, initiator)) {
return null;
}
if (
initiator &&
(initiator.origin === invidiousInstance ||
invidiousInstances.includes(initiator.origin) ||
youtubeDomains.includes(initiator.host))
) {
return null;
}
if (url.pathname.match(/iframe_api/) || url.pathname.match(/www-widgetapi/)) {
// Don't redirect YouTube Player API.
return null;
}
if (url.host.split(".")[0] === "studio") {
// Avoid redirecting `studio.youtube.com`
return null;
}
if (invidiousOnlyEmbeddedVideo && type !== "sub_frame") {
return null;
}
if (useFreeTube && type === "main_frame") {
return `freetube://${url}`;
}
// Apply settings
if (invidiousAlwaysProxy) {
url.searchParams.append("local", true);
}
if (invidiousVideoQuality) {
url.searchParams.append("quality", invidiousVideoQuality);
}
if (invidiousDarkMode) {
url.searchParams.append("dark_mode", invidiousDarkMode);
}
if (invidiousVolume) {
url.searchParams.append("volume", invidiousVolume);
}
if (invidiousPlayerStyle) {
url.searchParams.append("player_style", invidiousPlayerStyle);
}
if (invidiousSubtitles) {
url.searchParams.append("subtitles", invidiousSubtitles);
}
if (invidiousAutoplay) {
url.searchParams.append("autoplay", 1);
}
return `${invidiousInstance || commonHelper.getRandomInstance(invidiousRandomPool)
}${url.pathname.replace("/shorts", "")}${url.search}`;
}
function redirectTwitter(url, initiator) {
if (disableNitter || isException(url, initiator)) {
return null;
}
if (url.pathname.split("/").includes("home")) {
return null;
}
if (
isFirefox() &&
initiator &&
(initiator.origin === nitterInstance ||
nitterInstances.includes(initiator.origin) ||
twitterDomains.includes(initiator.host))
) {
browser.storage.sync.set({
redirectBypassFlag: true,
});
return null;
}
if (url.host.split(".")[0] === "pbs" || url.host.split(".")[0] === "video") {
return `${nitterInstance || commonHelper.getRandomInstance(nitterRandomPool)}/pic/${encodeURIComponent(url.href)}`;
} else if (url.pathname.split("/").includes("tweets")) {
return `${nitterInstance || commonHelper.getRandomInstance(nitterRandomPool)}${url.pathname.replace("/tweets", "")}${url.search}`;
} else {
return `${nitterInstance || commonHelper.getRandomInstance(nitterRandomPool)}${url.pathname}${url.search}`;
}
}
function redirectInstagram(url, initiator, type) {
if (disableBibliogram || isException(url, initiator)) {
return null;
}
// Do not redirect Bibliogram view on Instagram links
if (
initiator &&
(initiator.origin === bibliogramInstance ||
bibliogramInstances.includes(initiator.origin) ||
instagramDomains.includes(initiator.host))
) {
return null;
}
// Do not redirect /accounts, /embeds.js, or anything other than main_frame
if (type !== "main_frame" || url.pathname.match(bibliogramBypassPaths)) {
return null;
}
if (
url.pathname === "/" ||
instagramReservedPaths.includes(url.pathname.split("/")[1])
) {
return `${bibliogramInstance || commonHelper.getRandomInstance(bibliogramRandomPool)
}${url.pathname}${url.search}`;
} else {
// Likely a user profile, redirect to '/u/...'
return `${bibliogramInstance || commonHelper.getRandomInstance(bibliogramRandomPool)
}/u${url.pathname}${url.search}`;
}
}
function redirectGoogleMaps(url, initiator) {
if (disableOsm || isException(url, initiator)) {
return null;
}
if (initiator.host === "earth.google.com") {
return null;
}
let redirect;
let mapCentre = "";
let params = "";
// Set map centre if present
if (url.pathname.match(mapCentreRegex)) {
const [, lat, lon, zoom] = url.pathname.match(mapCentreRegex);
mapCentre = `#map=${zoom}/${lat}/${lon}`;
} else if (url.search.includes("center=")) {
const [lat, lon] = url.searchParams.get("center").split(",");
mapCentre = `#map=${url.searchParams.get("zoom") || "17"}/${lat}/${lon}`;
// Set default zoom if mapCentre not present
} else {
params = "&zoom=17";
}
// Set map layer
params = `${params}&layers=${layers[url.searchParams.get("layer")] || layers["none"]
}`;
// Handle Google Maps Embed API
if (url.pathname.split("/").includes("embed")) {
let query = "";
if (url.searchParams.has("q")) {
query = url.searchParams.get("q");
} else if (url.searchParams.has("query")) {
query = url.searchParams.has("query");
} else if (url.searchParams.has("pb")) {
try {
query = url.searchParams.get("pb").split(/!2s(.*?)!/)[1];
} catch (error) {
console.error(error);
// Unable to find map marker in URL.
}
}
let marker, bbox;
mapsHelper.addressToLatLng(query, (coords, boundingbox) => {
marker = coords;
bbox = boundingbox;
});
redirect = `${osmInstance}/export/embed.html?bbox=${bbox}&layer=mapnik&marker=${marker}`;
// Handle Google Maps Directions
} else if (url.pathname.split("/").includes("dir")) {
const travelMode =
travelModes[url.searchParams.get("travelmode")] || travelModes["driving"];
let origin;
mapsHelper.addressToLatLng(url.searchParams.get("origin"), (coords) => {
origin = coords;
});
let destination;
mapsHelper.addressToLatLng(
url.searchParams.get("destination"),
(coords) => {
destination = coords;
}
);
redirect = `${osmInstance}/directions?engine=${travelMode}&route=${origin}%3B${destination}${mapCentre}${params}`;
// Get marker from data attribute
} else if (
url.pathname.includes("data=") &&
url.pathname.match(dataLatLngRegex)
) {
const [mlat, mlon] = url.pathname.match(dataLatLngRegex);
redirect = `${osmInstance}/?mlat=${mlat.replace(
"!3d",
""
)}&mlon=${mlon.replace("!4d", "")}${mapCentre}${params}`;
// Get marker from ll param
} else if (url.searchParams.has("ll")) {
const [mlat, mlon] = url.searchParams.get("ll").split(",");
redirect = `${osmInstance}/?mlat=${mlat}&mlon=${mlon}${mapCentre}${params}`;
// Get marker from viewpoint param.
} else if (url.searchParams.has("viewpoint")) {
const [mlat, mlon] = url.searchParams.get("viewpoint").split(",");
redirect = `${osmInstance}/?mlat=${mlat}&mlon=${mlon}${mapCentre}${params}`;
// Use query as search if present.
} else {
let query;
if (url.searchParams.has("q")) {
query = url.searchParams.get("q");
} else if (url.searchParams.has("query")) {
query = url.searchParams.get("query");
} else if (url.pathname.match(placeRegex)) {
query = url.pathname.match(placeRegex)[1];
}
redirect = `${osmInstance}/${query ? "search?query=" + query : ""}${mapCentre || "#"
}${params}`;
}
return redirect;
}
function redirectReddit(url, initiator, type) {
if (disableReddit || isException(url, initiator))
return null;
// Do not redirect when already on the selected view
if ((initiator && initiator.origin === redditInstance) || url.origin === redditInstance)
return null;
// Do not redirect exclusions nor anything other than main_frame
if (type !== "main_frame" || url.pathname.match(redditBypassPaths))
return null;
console.info(url.host);
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
// 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}`;
return null;
}
if (redditFrontend == 'libreddit')
return `${redditInstance || commonHelper.getRandomInstance(redditInstances['libreddit'])}${url.pathname}${url.search}`;
if (redditFrontend == 'teddit')
return `${redditInstance || commonHelper.getRandomInstance(redditInstances['teddit'])}${url.pathname}${url.search}`;
}
function redirectMedium(url, initiator) {
if (disableScribe || isException(url, initiator))
return null;
if (url.pathname == "/")
return null;
if (
isFirefox() &&
initiator &&
(initiator.origin === scribeInstance ||
scribeInstances.includes(initiator.origin) ||
mediumDomains.includes(initiator.host))
) {
browser.storage.sync.set({ redirectBypassFlag: true });
return null;
}
return `${scribeInstance || commonHelper.getRandomInstance(scribeRandomPool)}${url.pathname}${url.search}`;
}
function redirectSearch(url, initiator) {
if (disableSearch || isException(url, initiator)) {
console.log("disableSearch:", disableSearch)
return null;
}
let search;
let searchQ;
console.log("searchFrontend", searchFrontend);
if (searchFrontend == 'searx') {
search = searchInstance || commonHelper.getRandomInstance(searchInstances["searx"]);
searchQ = "/"
}
if (searchFrontend == 'whoogle') {
search = searchInstance || commonHelper.getRandomInstance(searchInstances["whoogle"]);
searchQ = "/search"
}
let searchQuery = "";
url.search
.slice(1)
.split("&")
.forEach(function (input) {
if (input.startsWith("q=")) searchQuery = input;
});
console.info("It will direct to:", `${search}${searchQ}?${searchQuery}`)
return `${search}${searchQ}?${searchQuery}`;
}
function redirectGoogleTranslate(url, initiator) {
if (disableSimplyTranslate || isException(url, initiator)) return null;
return `${simplyTranslateInstance}/${url.search}`;
}
function redirectWikipedia(url, initiator) {
if (disableWikipedia || isException(url, initiator)) return null;
let GETArguments = [];
if (url.search.length > 0) {
let search = url.search.substring(1); //get rid of '?'
let argstrings = search.split("&");
for (let i = 0; i < argstrings.length; i++) {
let args = argstrings[i].split("=");
GETArguments.push([args[0], args[1]]);
}
}
let link = `${wikipediaInstance}${url.pathname}`;
let urlSplit = url.host.split(".");
if (urlSplit[0] != "wikipedia" && urlSplit[0] != "www") {
if (urlSplit[0] == "m")
GETArguments.push(["mobileaction", "toggle_view_mobile"]);
else GETArguments.push(["lang", urlSplit[0]]);
if (urlSplit[1] == "m")
GETArguments.push(["mobileaction", "toggle_view_mobile"]);
//wikiless doesn't have mobile view support yet
}
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"
)
//just in case someone wanted to visit wikipedia.org.foo.bar.net
return link;
else return null;
}
browser.webRequest.onBeforeRequest.addListener(
(details) => {
@ -591,23 +35,24 @@ browser.webRequest.onBeforeRequest.addListener(
initiator = new URL(details.initiator);
let newUrl;
if (youtubeDomains.includes(url.host)) newUrl = redirectYouTube(url, initiator, details.type)
else if (twitterDomains.includes(url.host)) newUrl = redirectTwitter(url, initiator);
if (youtubeHelper.targets.includes(url.host)) newUrl = youtubeHelper.redirect(url, initiator, details.type)
else if (instagramDomains.includes(url.host)) newUrl = redirectInstagram(url, initiator, details.type);
else if (twitterHelper.targets.includes(url.host)) newUrl = redirectTwitter(url, initiator);
else if (url.href.match(googleMapsRegex)) newUrl = redirectGoogleMaps(url, initiator);
else if (instagramHelper.targets.includes(url.host)) newUrl = redirectInstagram(url, initiator, details.type);
else if (redditDomains.includes(url.host)) newUrl = redirectReddit(url, initiator, details.type);
else if (url.href.match(mapsHelper.targets)) newUrl = redirectGoogleMaps(url, initiator);
else if (mediumDomains.some((rx) => rx.test(url.host))) newUrl = redirectMedium(url, initiator);
else if (redditHelper.targets.includes(url.host)) newUrl = redirectReddit(url, initiator, details.type);
else if (googleSearchRegex.some((rx) => rx.test(url.href))) newUrl = redirectSearch(url, initiator);
else if (mediumHelper.targets.some((rx) => rx.test(url.host))) newUrl = redirectMedium(url, initiator);
else if (googleTranslateDomains.includes(url.host)) newUrl = redirectGoogleTranslate(url, initiator);
else if (searchHelper.targets.some((rx) => rx.test(url.href))) newUrl = redirectSearch(url, initiator);
else if (url.host.match(wikipediaRegex)) newUrl = redirectWikipedia(url, initiator);
else if (googleTranslateHelper.targets.includes(url.host)) newUrl = redirectGoogleTranslate(url, initiator);
else if (url.host.match(wikipediaHelper.targets)) newUrl = redirectWikipedia(url, initiator);
if (newUrl) {
console.info("Redirecting", url.href, "=>", newUrl);
@ -628,18 +73,20 @@ browser.tabs.onUpdated.addListener((tabId, changeInfo, _) => {
}
var protocolHost = `${url.protocol}//${url.host}`;
var mightyList = [];
mightyList.push(...invidiousInstances);
mightyList.push(...nitterInstances);
mightyList.push(...bibliogramInstances);
mightyList.push(...redditInstances.libreddit);
mightyList.push(...redditInstances.teddit);
mightyList.push(redditInstances.desktop);
mightyList.push(redditInstances.mobile);
mightyList.push(...searchInstances.searx);
mightyList.push(...searchInstances.whoogle);
mightyList.push(...simplyTranslateInstances);
mightyList.push(...scribeInstances);
mightyList.push(...wikipediaInstances);
mightyList.push(
...youtubeHelper.redirects.normal,
...twitterHelper.redirects.normal,
...instagramHelper.redirects.normal,
...redditHelper.redirects.libreddit.normal,
...redditHelper.redirects.teddit.normal,
redditHelper.redirects.desktop,
redditHelper.redirects.mobile,
...searchHelper.redirects.searx.normal,
...searchHelper.redirects.whoogle.normal,
...googleTranslateHelper.redirects.normal,
...mediumHelper.redirects.normal,
...wikipediaHelper.redirects.normal
);
if (mightyList.includes(protocolHost)) browser.pageAction.show(tabId);
});
@ -649,13 +96,14 @@ browser.pageAction.onClicked.addListener((tab) => {
var tabUrl = new URL(tab.url);
var protocolHost = `${tabUrl.protocol}//${tabUrl.host}`;
var newUrl;
if (invidiousInstances.includes(protocolHost))
newUrl = 'https://youtube.com';
else if (nitterInstances.includes(protocolHost))
newUrl = 'https://twitter.com';
else if (bibliogramInstances.includes(protocolHost))
newUrl = 'https://instagram.com';
else if (redditInstances['libreddit'].includes(protocolHost) || redditInstances['teddit'].includes(protocolHost)) {
if (youtubeHelper.redirects.normal.includes(protocolHost)) newUrl = 'https://youtube.com';
if (twitterHelper.redirects.normal.includes(protocolHost)) newUrl = 'https://twitter.com';
if (instagramHelper.redirects.normal.includes(protocolHost)) newUrl = 'https://instagram.com';
if (redditHelper.redirects.libreddit.normal.includes(protocolHost) || redditHelper.redirects.teddit.normal.includes(protocolHost)) {
if (tabUrl.pathname.startsWith('/img')) {
newUrl = "https://i.redd.it"
tabUrl.href = tabUrl.href.replace("/img", "")
@ -663,19 +111,19 @@ browser.pageAction.onClicked.addListener((tab) => {
else
newUrl = 'https://reddit.com';
}
else if (searchInstances.searx.includes(protocolHost) || searchInstances.whoogle.includes(protocolHost))
newUrl = 'https://google.com';
else if (simplyTranslateInstances.includes(protocolHost))
newUrl = 'https://translate.google.com';
else if (scribeInstances.includes(protocolHost))
newUrl = 'https://medium.com';
else if (wikipediaInstances.includes(protocolHost))
newUrl = 'https://wikipedia.com';
if (newUrl)
browser.tabs.update({
url: tabUrl.href.replace(protocolHost, newUrl)
});
if (
searchHelper.redirects.searx.normal.includes(protocolHost) ||
searchHelper.redirects.whoogle.normal.includes(protocolHost)
) newUrl = 'https://google.com';
if (googleTranslateHelper.redirects.normal.includes(protocolHost)) newUrl = 'https://translate.google.com';
if (mediumHelper.redirects.normal.includes(protocolHost)) newUrl = 'https://medium.com';
if (wikipediaHelper.redirects.normal.includes(protocolHost)) newUrl = 'https://wikipedia.com';
if (newUrl) browser.tabs.update({ url: tabUrl.href.replace(protocolHost, newUrl) });
});
browser.runtime.onInstalled.addListener((details) => {
@ -697,7 +145,10 @@ browser.runtime.onInstalled.addListener((details) => {
if (result.redditFrontend === undefined) browser.storage.sync.set({ redditFrontend: 'libreddit' })
if (result.searchFrontend === undefined) browser.storage.sync.set({ searchFrontend: 'searx' })
if (result.searchFrontend === undefined) {
data.searchFrontend = 'searx';
browser.storage.sync.set({ searchFrontend: data.searchFrontend })
}
}
);
@ -714,11 +165,8 @@ browser.runtime.onInstalled.addListener((details) => {
whitelist: null,
});
}
if (result.invidiousInstance === "https://invidio.us") {
browser.storage.sync.set({
invidiousInstance: null,
});
}
if (result.invidiousInstance === "https://invidio.us")
browser.storage.sync.set({ invidiousInstance: null });
}
);
}

View File

@ -1,5 +1,6 @@
"use strict";
import data from "../../assets/javascripts/data.js";
import commonHelper from "../../assets/javascripts/helpers/common.js";
import shared from "./shared.js";
@ -7,7 +8,6 @@ import shared from "./shared.js";
const domparser = new DOMParser();
let themeElement = document.getElementById("theme");
let exceptions;
window.browser = window.browser || window.chrome;
@ -37,10 +37,11 @@ browser.storage.sync.get(
"theme",
],
(result) => {
data.theme = result.theme || "";
themeElement.value = result.theme || "";
if (result.theme) document.body.classList.add(result.theme);
exceptions = result.exceptions || [];
exceptions.forEach(prependExceptionsItem);
data.exceptions = result.exceptions || [];
data.exceptions.forEach(prependExceptionsItem);
shared.autocompletes.forEach((value) => {
});
}

View File

@ -28,21 +28,21 @@
<h1>Enable</h1>
<input id="disable-bibliogram" type="checkbox" checked />
</div>
<div class="some-block option-block">
<!-- <div class="some-block option-block">
<h4>Instance</h4>
<div class="autocomplete">
<input id="bibliogram-instance" type="url" data-localise-placeholder="__MSG_randomInstancePlaceholder__"
placeholder="Random instance (none selected)" />
</div>
</div>
</div> -->
<section class="settings-block">
<!-- <section class="settings-block">
<h4>Instance List</h4>
<div class="random-pool">
<textarea id="bibliogram-random-pool" name="bibliogram-random-pool" type="text"></textarea>
<ul id="bibliogram-random-pool-list"></ul>
</div>
</section>
</section> -->
</section>

View File

@ -1,58 +1,9 @@
import instagramHelper from "../../assets/javascripts/helpers/instagram.js";
import commonHelper from "../../assets/javascripts/helpers/common.js";
import shared from "./shared.js";
const bibliogramInstances = instagramHelper.redirects;
let bibliogramInstanceElement = document.getElementById("bibliogram-instance");
let disableBibliogramElement = document.getElementById("disable-bibliogram");
let bibliogramRandomPoolElement = document.getElementById("bibliogram-random-pool");
let bibliogramRandomPoolListElement = document.getElementById("bibliogram-random-pool-list");
let bibliogramRandomPool;
disableBibliogramElement.checked = !instagramHelper.getDisableBibliogram();
browser.storage.sync.get(
[
"bibliogramInstance",
"disableBibliogram",
"bibliogramRandomPool",
],
(result) => {
bibliogramInstanceElement.value = result.bibliogramInstance || "";
disableBibliogramElement.checked = !result.disableBibliogram;
bibliogramRandomPool = result.bibliogramRandomPool || commonHelper.filterInstances(bibliogramInstances)
bibliogramRandomPoolElement.value = bibliogramRandomPool.join("\n");
commonHelper.updateListElement(bibliogramRandomPoolListElement, bibliogramRandomPool);
let id = "bibliogram-instance";
let instances = bibliogramRandomPoolElement.value.split(',')
shared.autocompletes.push({ id: id, instances: instances })
shared.autocomplete(document.getElementById(id), instances);
}
)
bibliogramInstanceElement.addEventListener("input", commonHelper.debounce(() => {
if (bibliogramInstanceElement.checkValidity())
browser.storage.sync.set({ bibliogramInstance: shared.parseURL(bibliogramInstanceElement.value) });
}, 500));
disableBibliogramElement.addEventListener("change", (event) => {
browser.storage.sync.set({ disableBibliogram: !event.target.checked });
});
bibliogramRandomPoolElement.addEventListener("input", commonHelper.debounce(() => {
bibliogramRandomPool = commonHelper.filterList(bibliogramRandomPoolElement.value.split("\n"))
commonHelper.updateListElement(bibliogramRandomPoolListElement, bibliogramRandomPool);
browser.storage.sync.set({ bibliogramRandomPool: bibliogramRandomPool });
}, 50));
browser.storage.onChanged.addListener((changes) => {
if ("bibliogramRandomPool" in changes) {
bibliogramRandomPool = changes.bibliogramRandomPool.newValue;
bibliogramRandomPoolElement.value = bibliogramRandomPool.join("\n");
commonHelper.updateListElement(bibliogramRandomPoolListElement, bibliogramRandomPool);
}
})
disableBibliogramElement.addEventListener("change",
(event) => instagramHelper.setDisableBibliogram(!event.target.checked)
);

View File

@ -26,15 +26,15 @@
<section class="option-block">
<div class="some-block option-block">
<h1>Maps (OpenStreetMap)</h1>
<h1>Enable</h1>
<input id="disable-osm" type="checkbox" checked />
</div>
<div class="some-block option-block">
<!-- <div class="some-block option-block">
<h4>Instance</h4>
<div class="autocomplete">
<input id="osm-instance" type="url" placeholder="https://openstreetmap.org" />
</div>
</div>
</div> -->
</section>
<script type="module" src="./init.js"></script>
<script type="module" src="./maps.js"></script>

View File

@ -1,32 +1,9 @@
import mapsHelper from "../../assets/javascripts/helpers/google-maps.js";
import commonHelper from "../../assets/javascripts/helpers/common.js";
import shared from "./shared.js";
const osmInstances = mapsHelper.redirects;
let osmInstanceElement = document.getElementById("osm-instance");
let disableOsmElement = document.getElementById("disable-osm");
browser.storage.sync.get(
[
"osmInstance",
"disableOsm",
],
(result) => {
osmInstanceElement.value = result.osmInstance || "";
disableOsmElement.checked = !result.disableOsm;
let id = "osm-instance"
let instances = osmInstances
shared.autocompletes.push({ id: id, instances: instances })
shared.autocomplete(document.getElementById(id), instances);
}
)
disableOsmElement.checked = !mapsHelper.getDisableOsm();
osmInstanceElement.addEventListener("input", commonHelper.debounce(() => {
if (osmInstanceElement.checkValidity())
browser.storage.sync.set({ osmInstance: shared.parseURL(osmInstanceElement.value) });
}, 500));
disableOsmElement.addEventListener("change", (event) => {
browser.storage.sync.set({ disableOsm: !event.target.checked });
});
disableOsmElement.addEventListener("change",
(event) => mapsHelper.setDisableOsm(!event.target.checked)
);

View File

@ -25,10 +25,10 @@
<section class="option-block">
<div class="some-block option-block">
<h1>Medium (Scribe)</h1>
<h1>Enable</h1>
<input id="disable-scribe" type="checkbox" checked />
</div>
<div class="some-block option-block">
<!-- <div class="some-block option-block">
<h4>Instance</h4>
<div class="autocomplete">
<input id="scribe-instance" type="url" name="scribe-instance"
@ -42,7 +42,7 @@
<textarea id="scribe-random-pool" type="text"></textarea>
<ul id="scribe-random-pool-list"></ul>
</div>
</section>
</section> -->
</section>
<script type="module" src="./init.js"></script>

View File

@ -1,61 +1,9 @@
import mediumHelper from "../../assets/javascripts/helpers/medium.js";
import commonHelper from "../../assets/javascripts/helpers/common.js";
import shared from "./shared.js";
const scribeInstances = mediumHelper.redirects;
let scribeInstanceElement = document.getElementById("scribe-instance");
let disableScribeElement = document.getElementById("disable-scribe");
let scribeRandomPoolElement = document.getElementById("scribe-random-pool");
let scribeRandomPoolListElement = document.getElementById('scribe-random-pool-list');
let scribeRandomPool;
disableScribeElement.checked = !mediumHelper.getDisableScribe();
browser.storage.sync.get(
[
"disableScribe",
"scribeInstance",
"scribeRandomPool",
],
(result) => {
scribeInstanceElement.value = result.scribeInstance || "";
disableScribeElement.checked = !result.disableScribe;
scribeRandomPool = result.scribeRandomPool || commonHelper.filterInstances(scribeInstances)
scribeRandomPoolElement.value = scribeRandomPool.join("\n");
commonHelper.updateListElement(scribeRandomPoolListElement, scribeRandomPool);
let id = "scribe-instance";
let instances = scribeRandomPoolElement.value.split('\n')
shared.autocompletes.push({ id: id, instances: instances })
shared.autocomplete(document.getElementById(id), instances);
}
)
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({
scribeInstance: shared.parseURL(scribeInstanceElement.value)
});
}
}, 500));
scribeRandomPoolElement.addEventListener("input", commonHelper.debounce(() => {
scribeRandomPool = commonHelper.filterList(scribeRandomPoolElement.value.split("\n"))
commonHelper.updateListElement(scribeRandomPoolListElement, scribeRandomPool);
browser.storage.sync.set({ scribeRandomPool: scribeRandomPool });
}, 50));
browser.storage.onChanged.addListener((changes) => {
if ("scribeRandomPool" in changes) {
scribeRandomPool = changes.scribeRandomPool.newValue;
scribeRandomPoolElement.value = scribeRandomPool.join("\n");
commonHelper.updateListElement(scribeRandomPoolListElement, scribeRandomPool);
}
})
disableScribeElement.addEventListener("change",
(event) => mediumHelper.setDisableScribe(!event.target.checked)
);

View File

@ -27,16 +27,16 @@
<section class="option-block">
<div class="some-block option-block">
<h1>Reddit</h1>
<h1>Enable</h1>
<input id="disable-reddit" type="checkbox" checked />
</div>
<div class="some-block option-block">
<!-- <div class="some-block option-block">
<h4>Instance</h4>
<div class="autocomplete">
<input id="reddit-instance" type="url" placeholder="https://libredd.it" />
</div>
</div>
</div> -->
<div class="some-block option-block">
<h4>Frontend</h4>
@ -46,7 +46,7 @@
</select>
</div>
<section class="settings-block">
<!-- <section class="settings-block">
<h4>LibReddit Instance List</h4>
<div class="random-pool">
<textarea id="libreddit-random-pool" type="text"></textarea>
@ -60,7 +60,7 @@
<textarea id="teddit-random-pool" type="text"></textarea>
<ul id="teddit-random-pool-list"></ul>
</div>
</section>
</section> -->
</section>

View File

@ -1,91 +1,15 @@
import redditHelper from "../../assets/javascripts/helpers/reddit.js";
import commonHelper from "../../assets/javascripts/helpers/common.js";
import shared from "./shared.js";
import reddit from "../../assets/javascripts/helpers/reddit.js";
const redditInstances = redditHelper.redirects;
let redditInstanceElement = document.getElementById("reddit-instance");
let disableRedditElement = document.getElementById("disable-reddit");
let redditFrontendElement = document.getElementById("reddit-frontend");
let libredditRandomPoolElement = document.getElementById("libreddit-random-pool");
let libredditRandomPoolListElement = document.getElementById("libreddit-random-pool-list");
disableRedditElement.checked = !reddit.getDisableReddit();
redditFrontendElement.value = reddit.getRedditFrontend();
let tedditRandomPoolElement = document.getElementById("teddit-random-pool");
let tedditRandomPoolListElement = document.getElementById("teddit-random-pool-list");
disableRedditElement.addEventListener("change",
(event) => reddit.setDisableReddit(!event.target.checked)
);
let libredditRandomPool
let tedditRandomPool
browser.storage.sync.get(
[
"redditInstance",
"disableReddit",
"redditFrontend",
"libredditRandomPool",
"tedditRandomPool"
],
(result) => {
redditInstanceElement.value = result.redditInstance || "";
disableRedditElement.checked = !result.disableReddit;
redditFrontendElement.value = result.redditFrontend;
libredditRandomPool = result.libredditRandomPool || commonHelper.filterInstances(redditInstances.libreddit)
libredditRandomPoolElement.value = libredditRandomPool.join("\n");
commonHelper.updateListElement(libredditRandomPoolListElement, libredditRandomPool);
tedditRandomPool = result.tedditRandomPool || commonHelper.filterInstances(redditInstances.teddit)
tedditRandomPoolElement.value = tedditRandomPool.join("\n");
commonHelper.updateListElement(tedditRandomPoolListElement, tedditRandomPool);
// let id = "reddit-instance";
// let instances = redditInstances;
// shared.autocompletes.push({ id: id, instances: instances })
// shared.autocomplete(document.getElementById(id), instances);
}
)
redditInstanceElement.addEventListener("input", commonHelper.debounce(() => {
if (redditInstanceElement.checkValidity()) {
browser.storage.sync.set({
redditInstance: shared.parseURL(redditInstanceElement.value),
});
}
}, 500));
disableRedditElement.addEventListener("change", (event) => {
browser.storage.sync.set({ disableReddit: !event.target.checked });
});
redditFrontendElement.addEventListener("change", (event) => {
const value = event.target.options[redditFrontendElement.selectedIndex].value;
console.info("Reddit Frontend:", value)
browser.storage.sync.set({ redditFrontend: value })
});
libredditRandomPoolElement.addEventListener("input", commonHelper.debounce(() => {
libredditRandomPool = commonHelper.filterList(libredditRandomPoolElement.value.split("\n"))
commonHelper.updateListElement(libredditRandomPoolListElement, libredditRandomPool);
browser.storage.sync.set({ libredditRandomPool: libredditRandomPool });
}, 50));
tedditRandomPoolElement.addEventListener("input", commonHelper.debounce(() => {
tedditRandomPool = commonHelper.filterList(tedditRandomPoolElement.value.split("\n"))
commonHelper.updateListElement(tedditRandomPoolListElement, tedditRandomPool);
browser.storage.sync.set({ tedditRandomPool: tedditRandomPool });
}, 50));
browser.storage.onChanged.addListener((changes) => {
if ("libredditRandomPool" in changes) {
libredditRandomPool = changes.libredditRandomPool.newValue;
libredditRandomPoolElement.value = libredditRandomPool.join("\n");
commonHelper.updateListElement(libredditRandomPoolListElement, libredditRandomPool);
}
if ("tedditRandomPool" in changes) {
tedditRandomPool = changes.tedditRandomPool.newValue;
tedditRandomPoolElement.value = tedditRandomPool.join("\n");
commonHelper.updateListElement(tedditRandomPoolListElement, tedditRandomPool);
}
})
redditFrontendElement.addEventListener("change",
(event) => reddit.setRedditFrontend(event.target.options[redditFrontendElement.selectedIndex].value)
);

View File

@ -25,17 +25,17 @@
<section class="option-block">
<div class="some-block option-block">
<h1>Search</h1>
<h1>Enable</h1>
<input id="disable-search" type="checkbox" checked />
</div>
<div class="some-block option-block">
<!-- <div class="some-block option-block">
<h4>Instance</h4>
<!-- <div class="autocomplete"> -->
<div class="autocomplete">
<input id="search-instance" type="url"
data-localise-placeholder="__MSG_randomInstancePlaceholder__"
placeholder="Random instance (none selected)" />
<!-- </div> -->
</div>
</div>
</div> -->
<div class="some-block option-block">
<h4>Frontend</h4>
@ -44,7 +44,7 @@
<option value="whoogle">Whoogle</option>
</select>
</div>
<!--
<section class="settings-block">
<h4>SearX Instance List</h4>
<div class="random-pool">
@ -59,7 +59,7 @@
<textarea id="whoogle-random-pool" type="text"></textarea>
<ul id="whoogle-random-pool-list"></ul>
</div>
</section>
</section> -->
</section>

View File

@ -1,69 +1,15 @@
import searchHelper from "../../assets/javascripts/helpers/google-search.js";
import commonHelper from "../../assets/javascripts/helpers/common.js";
import shared from "./shared.js";
const searchInstances = searchHelper.redirects;
let searchInstanceElement = document.getElementById("search-instance");
let disableSearchElement = document.getElementById("disable-search");
let searchFrontendElement = document.getElementById("search-frontend");
let searxRandomPoolElement = document.getElementById("searx-random-pool");
let searxRandomPoolListElement = document.getElementById("searx-random-pool-list");
disableSearchElement.checked = !searchHelper.getDisableSearch();
searchFrontendElement.value = searchHelper.getSearchFrontend();
let whoogleRandomPoolElement = document.getElementById("whoogle-random-pool");
let whoogleRandomPoolListElement = document.getElementById("whoogle-random-pool-list");
searchFrontendElement.addEventListener("change",
(event) => searchHelper.setSearchFrontend(event.target.options[searchFrontendElement.selectedIndex].value)
);
let searxRandomPool
let whoogleRandomPool
browser.storage.sync.get(
[
"searchInstance",
"disableSearch",
"searchFrontend",
"searxRandomPool",
"whoogleRandomPool"
],
(result) => {
searchInstanceElement.value = (result.searchInstance && result.searchInstance.link) || "";
disableSearchElement.checked = !result.disableSearch;
searchFrontendElement.value = result.searchFrontend;
searxRandomPool = result.searxRandomPool || commonHelper.filterInstances(searchInstances.searx)
searxRandomPoolElement.value = searxRandomPool.join("\n");
commonHelper.updateListElement(searxRandomPoolListElement, searxRandomPool);
whoogleRandomPool = result.whoogleRandomPool || commonHelper.filterInstances(searchInstances.whoogle)
whoogleRandomPoolElement.value = whoogleRandomPool.join("\n");
commonHelper.updateListElement(whoogleRandomPoolListElement, whoogleRandomPool);
// let id = "search-instance"
// let instances = searchInstances.map((instance) => instance.link)
// shared.autocompletes.push({ id: id, instances: instances })
// shared.autocomplete(document.getElementById(id), instances);
}
)
const searchInstanceChange = commonHelper.debounce(() => {
const instance = searchInstances.find(
(instance) => instance.link === searchInstanceElement.value
);
if (instance || !searchInstanceElement.value) {
browser.storage.sync.set({
searchInstance: instance || searchInstanceElement.value,
});
} else {
searchInstanceElement.setCustomValidity("Must be an instance from the list");
}
}, 500);
searchInstanceElement.addEventListener("input", searchInstanceChange);
searchFrontendElement.addEventListener("change", (event) => {
const value = event.target.options[searchFrontendElement.selectedIndex].value;
console.info("Search Frontend:", value)
browser.storage.sync.set({ searchFrontend: value })
});
disableSearchElement.addEventListener("change", (event) => {
browser.storage.sync.set({ disableSearch: !event.target.checked });
});
disableSearchElement.addEventListener("change",
(event) => searchHelper.setDisableSearch(!event.target.checked)
);

View File

@ -24,15 +24,15 @@
</section>
<section class="option-block">
<div class="some-block option-block">
<h1>Translate (SimplyTranslate)</h1>
<h1>Enable</h1>
<input id="disable-simplyTranslate" type="checkbox" checked />
</div>
<div class="some-block option-block">
<!-- <div class="some-block option-block">
<h4>Instance</h4>
<div class="autocomplete">
<input id="simplyTranslate-instance" type="url" placeholder="https://translate.metalune.xyz" />
</div>
</div>
</div> -->
</section>

View File

@ -1,38 +1,9 @@
import googleTranslateHelper from "../../assets/javascripts/helpers/google-translate.js";
import commonHelper from "../../assets/javascripts/helpers/common.js";
import shared from "./shared.js";
const simplyTranslateInstances = googleTranslateHelper.redirects;
let simplyTranslateInstanceElement = document.getElementById("simplyTranslate-instance");
let disableSimplyTranslateElement = document.getElementById("disable-simplyTranslate");
disableSimplyTranslateElement.checked = !googleTranslateHelper.getDisableSimplyTranslate();
browser.storage.sync.get(
[
"simplyTranslateInstance",
"disableSimplyTranslate",
],
(result) => {
simplyTranslateInstanceElement.value = result.simplyTranslateInstance || "";
disableSimplyTranslateElement.checked = !result.disableSimplyTranslate;
let id = "simplyTranslate-instance"
let instances = simplyTranslateInstances;
shared.autocompletes.push({ id: id, instances: instances })
shared.autocomplete(document.getElementById(id), instances);
}
)
simplyTranslateInstanceElement.addEventListener(
"input",
commonHelper.debounce(() => {
if (simplyTranslateInstanceElement.checkValidity()) {
browser.storage.sync.set({
simplyTranslateInstance: shared.parseURL(simplyTranslateInstanceElement.value),
});
}
}, 500));
disableSimplyTranslateElement.addEventListener("change", (event) => {
browser.storage.sync.set({ disableSimplyTranslate: !event.target.checked });
});
disableSimplyTranslateElement.addEventListener("change",
(event) => googleTranslateHelper.setDisableSimplyTranslate(!event.target.checked)
);

View File

@ -30,22 +30,22 @@
<h1>Enable</h1>
<input id="disable-nitter" type="checkbox" checked />
</div>
<div class="some-block option-block">
<!-- <div class="some-block option-block">
<h4>Instance</h4>
<div class="autocomplete">
<input id="nitter-instance" type="url" name="nitter-instance"
data-localise-placeholder="__MSG_randomInstancePlaceholder__"
placeholder="Random instance (none selected)" />
</div>
</div>
</div> -->
<section class="settings-block">
<!-- <section class="settings-block">
<h4>Instance List</h4>
<div class="random-pool">
<textarea id="nitter-random-pool" type="text"></textarea>
<ul id="nitter-random-pool-list"></ul>
</div>
</section>
</section> -->
<div class="some-block option-block">
<h4 data-localise="__MSG_removeTwitterSW__">Proactively remove Twitter service worker</h4>
<input id="remove-twitter-sw" type="checkbox" checked />

View File

@ -1,66 +1,15 @@
import twitterHelper from "../../assets/javascripts/helpers/twitter.js";
import commonHelper from "../../assets/javascripts/helpers/common.js";
import shared from "./shared.js";
const nitterInstances = twitterHelper.redirects;
let nitterInstanceElement = document.getElementById("nitter-instance");
let removeTwitterSWElement = document.getElementById("remove-twitter-sw");
let disableNitterElement = document.getElementById("disable-nitter");
let nitterRandomPoolElement = document.getElementById("nitter-random-pool");
let nitterRandomPoolListElement = document.getElementById('nitter-random-pool-list');
let nitterRandomPool
disableNitterElement.checked = !twitterHelper.getDisableNitter();
removeTwitterSWElement.checked = !remove.getRemoveTwitterSW; // Problem
browser.storage.sync.get(
[
"nitterInstance",
"disableNitter",
"nitterRandomPool",
"removeTwitterSW",
],
(result) => {
nitterInstanceElement.value = result.nitterInstance || "";
disableNitterElement.checked = !result.disableNitter;
removeTwitterSWElement.checked = !result.removeTwitterSW;
nitterRandomPool = result.nitterRandomPool || commonHelper.filterInstances(nitterInstances)
nitterRandomPoolElement.value = nitterRandomPool.join("\n");
commonHelper.updateListElement(nitterRandomPoolListElement, nitterRandomPool);
let id = "nitter-instance"
let instances = nitterRandomPool
shared.autocompletes.push({ id: id, instances: instances })
shared.autocomplete(document.getElementById(id), instances);
}
)
nitterInstanceElement.addEventListener("input", commonHelper.debounce(() => {
if (nitterInstanceElement.checkValidity()) {
browser.storage.sync.set({
nitterInstance: shared.parseURL(nitterInstanceElement.value),
});
}
}, 500));
disableNitterElement.addEventListener("change", (event) => {
browser.storage.sync.set({ disableNitter: !event.target.checked });
});
disableNitterElement.addEventListener("change",
(event) => twitterHelper.setDisableNitter(!event.target.checked)
);
removeTwitterSWElement.addEventListener("change", (event) => {
browser.storage.sync.set({ removeTwitterSW: !event.target.checked });
browser.storage.sync.set({ removeTwitterSW: !event.target.checked }); // Problem
});
nitterRandomPoolElement.addEventListener("input", commonHelper.debounce(() => {
nitterRandomPool = commonHelper.filterList(nitterRandomPoolElement.value.split("\n"))
commonHelper.updateListElement(nitterRandomPoolListElement, nitterRandomPool);
browser.storage.sync.set({ nitterRandomPool: nitterRandomPool });
}, 50));
browser.storage.onChanged.addListener((changes) => {
if ("nitterRandomPool" in changes) {
nitterRandomPool = changes.nitterRandomPool.newValue;
nitterRandomPoolElement.value = nitterRandomPool.join("\n");
commonHelper.updateListElement(nitterRandomPoolListElement, nitterRandomPool);
}
})

View File

@ -25,10 +25,10 @@
<section class="option-block">
<div class="some-block option-block">
<h1>Wikipedia (Wikiless)</h1>
<h1>Enable</h1>
<input id="disable-wikipedia" type="checkbox" checked />
</div>
<div class="some-block option-block">
<!-- <div class="some-block option-block">
<h4>Instance</h4>
<div class="autocomplete">
<input id="wikipedia-instance" type="url" placeholder="https://wikiless.org" />
@ -41,7 +41,7 @@
<textarea id="wikiless-random-pool" type="text"></textarea>
<ul id="wikiless-random-pool-list"></ul>
</div>
</section>
</section> -->
</section>
<script type="module" src="./init.js"></script>

View File

@ -1,63 +1,9 @@
import wikipediaHelper from "../../assets/javascripts/helpers/wikipedia.js";
import commonHelper from "../../assets/javascripts/helpers/common.js";
import shared from "./shared.js";
const wikilessInstances = wikipediaHelper.redirects;
let wikipediaInstanceElement = document.getElementById("wikipedia-instance");
let disableWikipediaElement = document.getElementById("disable-wikipedia");
let wikilessRandomPoolElement = document.getElementById("wikiless-random-pool");
let wikilessRandomPoolListElement = document.getElementById('wikiless-random-pool-list');
let wikilessRandomPool
disableWikipediaElement.checked = !wikipediaHelper.getDisableWikipedia();
browser.storage.sync.get(
[
"wikipediaInstance",
"disableWikipedia",
"wikilessRandomPool"
],
(result) => {
wikipediaInstanceElement.value = result.wikipediaInstance || "";
disableWikipediaElement.checked = !result.disableWikipedia;
wikilessRandomPool = result.wikilessRandomPool || commonHelper.filterInstances(wikilessInstances)
wikilessRandomPoolElement.value = wikilessRandomPool.join("\n")
commonHelper.updateListElement(wikilessRandomPoolListElement, wikilessRandomPool);
let id = "wikipedia-instance";
let instances = wikilessInstances;
shared.autocompletes.push({ id: id, instances: instances })
shared.autocomplete(document.getElementById(id), instances);
}
)
wikipediaInstanceElement.addEventListener("input", commonHelper.debounce(() => {
if (wikipediaInstanceElement.checkValidity()) {
browser.storage.sync.set({
wikipediaInstance: shared.parseURL(wikipediaInstanceElement.value),
});
}
}, 500));
disableWikipediaElement.addEventListener("change", (event) => {
browser.storage.sync.set({ disableWikipedia: !event.target.checked });
});
wikilessRandomPoolElement.addEventListener("input", commonHelper.debounce(() => {
wikilessRandomPool = commonHelper.filterList(wikilessRandomPoolElement.value.split("\n"))
commonHelper.updateListElement(wikilessRandomPoolListElement, wikilessRandomPool);
browser.storage.sync.set({ wikilessRandomPool: wikilessRandomPool });
}, 50));
browser.storage.onChanged.addListener((changes) => {
if ("wikilessRandomPool" in changes) {
console.info("Wikiless updating");
console.info(changes.wikilessRandomPool.newValue)
wikilessRandomPool = changes.wikilessRandomPool.newValue;
wikilessRandomPoolElement.value = wikilessRandomPool.join("\n");
commonHelper.updateListElement(wikilessRandomPoolListElement, wikilessRandomPool);
}
})
disableWikipediaElement.addEventListener("change",
(event) => wikipediaHelper.setDisableWikipedia(!event.target.checked)
);

View File

@ -30,27 +30,27 @@
<input id="disable-invidious" type="checkbox" checked />
</div>
<div class="some-block option-block">
<!-- <div class="some-block option-block">
<h4>Instance</h4>
<!-- <div class="autocomplete"> -->
<div class="autocomplete">
<input id="invidious-instance" type="url" data-localise-placeholder="__MSG_randomInstancePlaceholder__"
placeholder="Random instance (none selected)" />
<!-- </div> -->
</div>
</div>
</div> -->
<section class="settings-block">
<!-- <section class="settings-block">
<h4>Instance List</h4>
<div class="random-pool">
<textarea type="textarea" id="invidious-random-pool" name="invidious-random-pool"
type="text"></textarea>
<ul id="invidious-random-pool-list"></ul>
</div>
</section>
</section> -->
<div class="some-block option-block">
<h4>Player Style</h4>
<select id="invidious-player-style">
<option value="">Invidious</option>
<option value="invidious">Invidious</option>
<option value="youtube">YouTube</option>
</select>
</div>

View File

@ -1,10 +1,6 @@
import youtubeHelper from "../../assets/javascripts/helpers/youtube.js";
import commonHelper from "../../assets/javascripts/helpers/common.js";
import shared from "./shared.js";
const invidiousInstances = youtubeHelper.redirects;
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");
@ -12,128 +8,75 @@ 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 invidiousRandomPoolListElement = document.getElementById('invidious-random-pool-list');
let useFreeTubeElement = document.getElementById("use-freetube");
let invidiousAlwaysProxyElement = document.getElementById("always-proxy");
let invidiousOnlyEmbeddedVideoElement = document.getElementById("only-embed");
let invidiousVideoQualityElement = document.getElementById("video-quality");
let invidiousVolumeValueElement = document.querySelector("#volume-value");
let invidiousRandomPool;
youtubeHelper.init().then(() => {
disableInvidiousElement.checked = !youtubeHelper.getDisableInvidious();
invidiousDarkModeElement.checked = youtubeHelper.getInvidiousDarkMode();
persistInvidiousPrefsElement.checked = youtubeHelper.getPersistInvidiousPrefs();
invidiousVolumeElement.value = youtubeHelper.getInvidiousVolume();
invidiousVolumeValueElement.textContent = youtubeHelper.getInvidiousVolume() ? `${youtubeHelper.getInvidiousVolume()}%` : " - ";
invidiousPlayerStyleElement.value = youtubeHelper.getInvidiousPlayerStyle() || "";
invidiousSubtitlesElement.value = youtubeHelper.getInvidiousSubtitles() || "";
useFreeTubeElement.checked = youtubeHelper.getUseFreeTube();
invidiousOnlyEmbeddedVideoElement.checked = youtubeHelper.getInvidiousOnlyEmbeddedVideo();
invidiousAlwaysProxyElement.checked = youtubeHelper.getInvidiousAlwaysProxy();
invidiousVideoQualityElement.value = youtubeHelper.getInvidiousVideoQuality() || "";
invidiousAutoplayElement.checked = youtubeHelper.getInvidiousAutoplay();
});
browser.storage.sync.get(
[
"invidiousInstance",
"disableInvidious",
"invidiousDarkMode",
"persistInvidiousPrefs",
"invidiousVolume",
"invidiousPlayerStyle",
"invidiousSubtitles",
"invidiousAutoplay",
"invidiousRandomPool",
"useFreeTube",
"invidiousAlwaysProxy",
"invidiousOnlyEmbeddedVideo",
"invidiousVideoQuality",
],
(result) => {
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}%` : " - ";
invidiousPlayerStyleElement.value = result.invidiousPlayerStyle || "";
invidiousSubtitlesElement.value = result.invidiousSubtitles || "";
useFreeTubeElement.checked = result.useFreeTube;
invidiousOnlyEmbeddedVideoElement.checked = result.invidiousOnlyEmbeddedVideo;
invidiousAlwaysProxyElement.checked = result.invidiousAlwaysProxy;
invidiousVideoQualityElement.value = result.invidiousVideoQuality || "";
invidiousAutoplayElement.checked = result.invidiousAutoplay;
invidiousRandomPool = result.invidiousRandomPool || commonHelper.filterInstances(invidiousInstances)
invidiousRandomPoolElement.value = invidiousRandomPool.join("\n");
commonHelper.updateListElement(invidiousRandomPoolListElement, invidiousRandomPool);
let id = "invidious-instance"
let instances = invidiousRandomPool;
shared.autocompletes.push({ id: id, instances: instances });
shared.autocomplete(document.getElementById(id), instances);
}
)
invidiousInstanceElement.addEventListener("input",
commonHelper.debounce(() => {
if (invidiousInstanceElement.checkValidity())
browser.storage.sync.set({ invidiousInstance: shared.parseURL(invidiousInstanceElement.value) });
}, 500)
disableInvidiousElement.addEventListener("change",
(event) => youtubeHelper.setDisableInvidious(!event.target.checked)
);
disableInvidiousElement.addEventListener("change", (event) => {
browser.storage.sync.set({ disableInvidious: !event.target.checked });
});
invidiousDarkModeElement.addEventListener("change",
(event) => youtubeHelper.setInvidiousDarkMode(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 });
});
persistInvidiousPrefsElement.addEventListener("change",
(event) => youtubeHelper.setPersistInvidiousPrefs(event.target.checked)
);
invidiousVolumeElement.addEventListener("input",
commonHelper.debounce(() => {
document.querySelector("#volume-value").textContent = `${invidiousVolumeElement.value}%`;
browser.storage.sync.set({ invidiousVolume: invidiousVolumeElement.value });
youtubeHelper.setInvidiousVolume(invidiousVolumeElement.value);
console.info("youtubeHelper.invidiousVolume:", youtubeHelper.getInvidiousVolume());
invidiousVolumeValueElement.textContent = `${invidiousVolumeElement.value}%`;
}, 1)
);
invidiousPlayerStyleElement.addEventListener("change", (event) => {
browser.storage.sync.set({
invidiousPlayerStyle: event.target.options[invidiousPlayerStyleElement.selectedIndex].value,
});
});
invidiousPlayerStyleElement.addEventListener("change",
(event) => youtubeHelper.setInvidiousPlayerStyle(event.target.options[invidiousPlayerStyleElement.selectedIndex].value)
);
invidiousSubtitlesElement.addEventListener("input",
commonHelper.debounce(() => {
browser.storage.sync.set({ invidiousSubtitles: invidiousSubtitlesElement.value });
youtubeHelper.setInvidiousSubtitles(invidiousSubtitlesElement.value)
}, 500)
);
invidiousAutoplayElement.addEventListener("change", (event) => {
browser.storage.sync.set({ invidiousAutoplay: event.target.checked });
});
invidiousRandomPoolElement.addEventListener("input", commonHelper.debounce(() => {
invidiousRandomPool = commonHelper.filterList(invidiousRandomPoolElement.value.split("\n"))
commonHelper.updateListElement(invidiousRandomPoolListElement, invidiousRandomPool);
browser.storage.sync.set({ invidiousRandomPool: invidiousRandomPool });
}, 50)
invidiousAutoplayElement.addEventListener("change",
(event) => youtubeHelper.setInvidiousAutoplay(event.target.checked)
);
useFreeTubeElement.addEventListener("change", (event) => {
browser.storage.sync.set({ useFreeTube: event.target.checked });
});
invidiousAlwaysProxyElement.addEventListener("change", (event) => {
browser.storage.sync.set({ invidiousAlwaysProxy: event.target.checked });
});
useFreeTubeElement.addEventListener("change",
(event) => youtubeHelper.setUseFreeTube(event.target.checked)
);
invidiousOnlyEmbeddedVideoElement.addEventListener("change", (event) => {
browser.storage.sync.set({ invidiousOnlyEmbeddedVideo: event.target.checked });
});
invidiousAlwaysProxyElement.addEventListener("change",
(event) => youtubeHelper.setInvidiousAlwaysProxy(event.target.checked)
);
invidiousVideoQualityElement.addEventListener("change", (event) => {
browser.storage.sync.set({ invidiousVideoQuality: event.target.options[invidiousVideoQualityElement.selectedIndex].value });
});
invidiousOnlyEmbeddedVideoElement.addEventListener("change",
(event) => youtubeHelper.setInvidiousOnlyEmbeddedVideo(event.target.checked)
);
browser.storage.onChanged.addListener((changes) => {
if ("invidiousRandomPool" in changes) {
invidiousRandomPool = changes.invidiousRandomPool.newValue;
invidiousRandomPoolElement.value = invidiousRandomPool.join("\n");
commonHelper.updateListElement(invidiousRandomPoolListElement, invidiousRandomPool);
}
})
invidiousVideoQualityElement.addEventListener("change",
(event) => youtubeHelper.setInvidiousVideoQuality(event.target.options[invidiousVideoQualityElement.selectedIndex].value)
);

View File

@ -1,80 +1,78 @@
"use strict";
import commonHelper from "../../assets/javascripts/helpers/common.js";
import data from "../../assets/javascripts/data.js";
let disableNitter = document.querySelector("#disable-nitter");
let disableInvidious = document.querySelector("#disable-invidious");
let disableBibliogram = document.querySelector("#disable-bibliogram");
let disableOsm = document.querySelector("#disable-osm");
let disableReddit = document.querySelector("#disable-reddit");
let disableSearch = document.querySelector("#disable-search");
let disableSimplyTranslate = document.querySelector("#disable-simplyTranslate");
let disableWikipedia = document.querySelector("#disable-wikipedia");
let disableScribe = document.querySelector("#disable-scribe");
let disableNitterElement = document.querySelector("#disable-nitter");
let disableInvidiousElement = document.querySelector("#disable-invidious");
let disableBibliogramElement = document.querySelector("#disable-bibliogram");
let disableOsmElement = document.querySelector("#disable-osm");
let disableRedditElement = document.querySelector("#disable-reddit");
let disableSearchElement = document.querySelector("#disable-search");
let disableSimplyTranslateElement = document.querySelector("#disable-simplyTranslate");
let disableWikipediaElement = document.querySelector("#disable-wikipedia");
let disableScribeElement = document.querySelector("#disable-scribe");
window.browser = window.browser || window.chrome;
browser.storage.sync.get(
[
"disableNitter",
"disableInvidious",
"disableBibliogram",
"disableOsm",
"disableReddit",
"disableSearch",
"disableSimplyTranslate",
"disableWikipedia",
"disableScribe",
"theme",
],
(result) => {
if (result.theme) document.body.classList.add(result.theme);
disableNitter.checked = !result.disableNitter;
disableInvidious.checked = !result.disableInvidious;
disableBibliogram.checked = !result.disableBibliogram;
disableOsm.checked = !result.disableOsm;
disableReddit.checked = !result.disableReddit;
disableSearch.checked = !result.disableSearch;
disableSimplyTranslate.checked = !result.disableSimplyTranslate;
disableWikipedia.checked = !result.disableWikipedia;
disableScribe.checked = !result.disableScribe;
}
);
// Complete change to the global variables in data.js
disableNitter.addEventListener("change", (event) => {
browser.storage.sync.set({ disableNitter: !event.target.checked });
if (data.theme) document.body.classList.add(data.theme);
disableNitterElement.checked = !data.disableNitter;
disableInvidiousElement.checked = !data.disableInvidious;
disableBibliogramElement.checked = !data.disableBibliogram;
disableOsmElement.checked = !data.disableOsm;
disableRedditElement.checked = !data.disableReddit;
disableSearchElement.checked = !data.disableSearch;
disableSimplyTranslateElement.checked = !data.disableSimplyTranslate;
disableWikipediaElement.checked = !data.disableWikipedia;
disableScribeElement.checked = !data.disableScribe;
disableNitterElement.addEventListener("change", (event) => {
data.disableNitter = !event.target.checked;
browser.storage.sync.set({ disableNitter: data.disableNitter });
});
disableInvidious.addEventListener("change", (event) => {
browser.storage.sync.set({ disableInvidious: !event.target.checked });
disableInvidiousElement.addEventListener("change", (event) => {
data.disableInvidious = !event.target.checked;
browser.storage.sync.set({ disableInvidious: data.disableInvidious });
});
disableBibliogram.addEventListener("change", (event) => {
browser.storage.sync.set({ disableBibliogram: !event.target.checked });
disableBibliogramElement.addEventListener("change", (event) => {
data.disableBibliogram = !event.target.checked;
browser.storage.sync.set({ disableBibliogram: data.disableBibliogram });
});
disableOsm.addEventListener("change", (event) => {
browser.storage.sync.set({ disableOsm: !event.target.checked });
disableOsmElement.addEventListener("change", (event) => {
data.disableOsm = !event.target.checked;
browser.storage.sync.set({ disableOsm: data.disableOsm });
});
disableReddit.addEventListener("change", (event) => {
browser.storage.sync.set({ disableReddit: !event.target.checked });
disableRedditElement.addEventListener("change", (event) => {
data.disableReddit = !event.target.checked;
browser.storage.sync.set({ disableReddit: data.disableReddit });
});
disableSearch.addEventListener("change", (event) => {
browser.storage.sync.set({ disableSearch: !event.target.checked });
disableSearchElement.addEventListener("change", (event) => {
data.disableSearch = !event.target.checked;
console.log("DisableSearch", data.disableSearch)
browser.storage.sync.set({ disableSearch: data.disableSearch });
});
disableSimplyTranslate.addEventListener("change", (event) => {
browser.storage.sync.set({ disableSimplyTranslate: !event.target.checked });
disableSimplyTranslateElement.addEventListener("change", (event) => {
data.disableSimplyTranslate = !event.target.checked;
browser.storage.sync.set({ disableSimplyTranslate: data.disableSimplyTranslate });
});
disableWikipedia.addEventListener("change", (event) => {
browser.storage.sync.set({ disableWikipedia: !event.target.checked });
disableWikipediaElement.addEventListener("change", (event) => {
data.disableWikipedia = !event.target.checked;
browser.storage.sync.set({ disableWikipedia: data.disableWikipedia });
});
disableScribe.addEventListener("change", (event) => {
browser.storage.sync.set({ disableScribe: !event.target.checked });
disableScribeElement.addEventListener("change", (event) => {
data.disableScribe = !event.target.checked;
browser.storage.sync.set({ disableScribe: data.disableScribe });
});