Finished adding default & custom instances

This commit is contained in:
ManeraKai 2022-02-06 17:24:39 +03:00
parent 5cc8ed3f60
commit 30421fa685
No known key found for this signature in database
GPG Key ID: 5ABC31FFD562E337
24 changed files with 904 additions and 173 deletions

View File

@ -23,7 +23,7 @@ function updateInstances() {
if (request.status === 200) {
const instances = JSON.parse(request.responseText);
nameHelper.setInvidiousRedirects(instances.invidious);
youtubeHelper.setInvidiousRedirects(instances.invidious);
twitterHelper.setRedirects(instances.nitter);
@ -140,6 +140,7 @@ function processDefaultCustomInstances(
if (!nameCustomInstances.includes(val)) {
nameCustomInstances.push(val)
setNameCustomRedirects(nameCustomInstances);
nameCustomInstanceInput.value = '';
}
calcNameCustomInstances();
}

View File

@ -7,6 +7,7 @@ const targets = [
"about.instagram.com",
];
let redirects = {
"bibliogram": {
"normal": [
"https://bibliogram.art",
"https://bibliogram.snopyta.org",
@ -18,14 +19,32 @@ let redirects = {
"https://bib.actionsack.com",
"https://biblio.alefvanoon.xyz"
]
}
};
const getRedirects = () => redirects;
function setRedirects(val) {
redirects = val;
browser.storage.sync.set({ instagramRedirects: val })
redirects.bibliogram = val;
browser.storage.sync.set({ instagramRedirects: redirects })
console.log("instagramRedirects: ", val)
}
let bibliogramRedirectsChecks;
const getBibliogramRedirectsChecks = () => bibliogramRedirectsChecks;
function setBibliogramRedirectsChecks(val) {
bibliogramRedirectsChecks = val;
browser.storage.sync.set({ bibliogramRedirectsChecks })
console.log("bibliogramRedirectsChecks: ", val)
}
let bibliogramCustomRedirects = [];
const getBibliogramCustomRedirects = () => bibliogramCustomRedirects;
function setBibliogramCustomRedirects(val) {
bibliogramCustomRedirects = val;
browser.storage.sync.set({ bibliogramCustomRedirects })
console.log("bibliogramCustomRedirects: ", val)
}
const reservedPaths = [
"about",
"explore",
@ -61,22 +80,24 @@ function setDisableInstagram(val) {
}
function redirect(url, initiator, type) {
if (disableInstagram)
return null;
if (disableInstagram) return null;
let instancesList = [...bibliogramRedirectsChecks, ...bibliogramCustomRedirects];
if (instancesList.length === 0) return null;
let randomInstance = commonHelper.getRandomInstance(instancesList)
// Do not redirect Bibliogram view on Instagram links
if (initiator && (redirects.normal.includes(initiator.origin) || targets.includes(initiator.host)))
if (initiator && (instancesList.includes(initiator.origin) || 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(bypassPaths))
return 'CANCEL';
let link = commonHelper.getRandomInstance(redirects.normal);
if (url.pathname === "/" || instagramReservedPaths.includes(url.pathname.split("/")[1]))
return `${link}${url.pathname}${url.search}`;
return `${randomInstance}${url.pathname}${url.search}`;
else
return `${link}/u${url.pathname}${url.search}`; // Likely a user profile, redirect to '/u/...'
return `${randomInstance}/u${url.pathname}${url.search}`; // Likely a user profile, redirect to '/u/...'
}
function isInstagram(url) {
@ -86,19 +107,34 @@ function isInstagram(url) {
async function init() {
let result = await browser.storage.sync.get([
"disableInstagram",
"instagramRedirects"
"instagramRedirects",
"bibliogramRedirectsChecks",
"bibliogramCustomRedirects",
])
disableInstagram = result.disableInstagram ?? false;
if (result.instagramRedirects)
redirects = result.instagramRedirects
bibliogramRedirectsChecks = result.bibliogramRedirectsChecks ?? [...redirects.bibliogram.normal];
bibliogramCustomRedirects = result.bibliogramCustomRedirects ?? [];
}
export default {
getRedirects,
setRedirects,
getDisableInstagram,
setDisableInstagram,
getBibliogramRedirectsChecks,
setBibliogramRedirectsChecks,
getBibliogramCustomRedirects,
setBibliogramCustomRedirects,
isInstagram,
redirect,
init,
};

View File

@ -17,20 +17,38 @@ const targets = [
];
let redirects = {
"scribe": {
"normal": [
"https://scribe.rip",
"https://scribe.nixnet.services",
"https://scribe.citizen4.eu",
"https://scribe.bus-hit.me"
]
}
};
const getRedirects = () => redirects;
function setRedirects(val) {
redirects = val;
browser.storage.sync.set({ mediumRedirects: val })
redirects.scribe = val;
browser.storage.sync.set({ mediumRedirects: redirects })
console.log("mediumRedirects: ", val)
}
let scribeRedirectsChecks;
const getScribeRedirectsChecks = () => scribeRedirectsChecks;
function setScribeRedirectsChecks(val) {
scribeRedirectsChecks = val;
browser.storage.sync.set({ scribeRedirectsChecks })
console.log("scribeRedirectsChecks: ", val)
}
let scribeCustomRedirects = [];
const getScribeCustomRedirects = () => scribeCustomRedirects;
function setScribeCustomRedirects(val) {
scribeCustomRedirects = val;
browser.storage.sync.set({ scribeCustomRedirects })
console.log("scribeCustomRedirects: ", val)
}
let disableMedium;
const getDisableMedium = () => disableMedium;
function setDisableMedium(val) {
@ -45,14 +63,19 @@ function redirect(url, initiator) {
if (url.pathname == "/") return null;
let instancesList = [...scribeRedirectsChecks, ...scribeCustomRedirects];
if (instancesList.length === 0) return null;
let randomInstance = commonHelper.getRandomInstance(instancesList)
if (
commonHelper.isFirefox() && initiator &&
(redirects.normal.includes(initiator.origin) || targets.includes(initiator.host))
(instancesList.includes(initiator.origin) || targets.includes(initiator.host))
) {
browser.storage.sync.set({ redirectBypassFlag: true });
return null;
}
return `${commonHelper.getRandomInstance(redirects.normal)}${url.pathname}${url.search}`;
return `${randomInstance}${url.pathname}${url.search}`;
}
function isMedium(url) {
@ -62,11 +85,16 @@ function isMedium(url) {
async function init() {
let result = await browser.storage.sync.get([
"disableMedium",
"mediumRedirects"
"mediumRedirects",
"scribeRedirectsChecks",
"scribeCustomRedirects",
])
disableMedium = result.disableMedium ?? false;
if (result.mediumRedirects)
redirects = result.mediumRedirects;
scribeRedirectsChecks = result.scribeRedirectsChecks ?? [...redirects.scribe.normal];
scribeCustomRedirects = result.scribeCustomRedirects ?? [];
}
export default {
@ -78,6 +106,12 @@ export default {
getDisableMedium,
setDisableMedium,
getScribeRedirectsChecks,
setScribeRedirectsChecks,
getScribeCustomRedirects,
setScribeCustomRedirects,
redirect,
isMedium,
init,

View File

@ -71,6 +71,39 @@ function setTedditRedirects(val) {
console.log("tedditRedirects:", val)
}
let libredditRedirectsChecks;
const getLibredditRedirectsChecks = () => libredditRedirectsChecks;
function setLibredditRedirectsChecks(val) {
libredditRedirectsChecks = val;
browser.storage.sync.set({ libredditRedirectsChecks })
console.log("libredditRedirectsChecks: ", val)
}
let libredditCustomRedirects = [];
const getLibredditCustomRedirects = () => libredditCustomRedirects;
function setLibredditCustomRedirects(val) {
libredditCustomRedirects = val;
browser.storage.sync.set({ libredditCustomRedirects })
console.log("libredditCustomRedirects: ", val)
}
let tedditRedirectsChecks;
const getTedditRedirectsChecks = () => tedditRedirectsChecks;
function setTedditRedirectsChecks(val) {
tedditRedirectsChecks = val;
browser.storage.sync.set({ tedditRedirectsChecks })
console.log("tedditRedirectsChecks: ", val)
}
let tedditCustomRedirects = [];
const getTedditCustomRedirects = () => tedditCustomRedirects;
function setTedditCustomRedirects(val) {
tedditCustomRedirects = val;
browser.storage.sync.set({ tedditCustomRedirects })
console.log("tedditCustomRedirects: ", val)
}
const bypassPaths = /\/(gallery\/poll\/rpan\/settings\/topics)/;
let disableReddit;
@ -101,8 +134,13 @@ function redirect(url, initiator, type) {
if (type !== "main_frame" || url.pathname.match(bypassPaths))
return null;
let libredditLink = commonHelper.getRandomInstance(redirects.libreddit.normal);
let tedditLink = commonHelper.getRandomInstance(redirects.teddit.normal);
let libreddtInstancesList = [...libredditRedirectsChecks, ...libredditCustomRedirects];
if (libreddtInstancesList.length === 0) return null;
let libredditRandomInstance = commonHelper.getRandomInstance(libreddtInstancesList);
let tedditInstancesList = [...tedditRedirectsChecks, ...tedditCustomRedirects];
if (tedditInstancesList.length === 0) return null;
let tedditRandomInstance = commonHelper.getRandomInstance(tedditInstancesList);
if (url.host === "i.redd.it")
// As of 2021-04-09, redirects for teddit images are nontrivial:
@ -110,9 +148,9 @@ function redirect(url, initiator, type) {
// 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}`;
return `${libredditRandomInstance}/img${url.pathname}${url.search}`;
else if (url.host === "redd.it") {
if (redditFrontend == 'libreddit') return `${libredditLink}${url.pathname}${url.search}`;
if (redditFrontend == 'libreddit') return `${libredditRandomInstance}${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
@ -121,10 +159,10 @@ function redirect(url, initiator, type) {
// 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}`;
return `${tedditRandomInstance}/comments${url.pathname}${url.search}`;
}
if (redditFrontend == 'libreddit') return `${libredditLink}${url.pathname}${url.search}`;
if (redditFrontend == 'teddit') return `${tedditLink}${url.pathname}${url.search}`;
if (redditFrontend == 'libreddit') return `${libredditRandomInstance}${url.pathname}${url.search}`;
if (redditFrontend == 'teddit') return `${tedditRandomInstance}${url.pathname}${url.search}`;
}
function isReddit(url) {
@ -135,12 +173,22 @@ async function init() {
let result = await browser.storage.sync.get([
"disableReddit",
"redditFrontend",
"redditRedirects"
"redditRedirects",
"libredditRedirectsChecks",
"libredditCustomRedirects",
"tedditRedirectsChecks",
"tedditCustomRedirects",
])
disableReddit = result.disableReddit ?? false;
redditFrontend = result.redditFrontend ?? 'libreddit';
if (result.redditRedirects)
redirects = result.redditRedirects;
libredditRedirectsChecks = result.libredditRedirectsChecks ?? [...redirects.libreddit.normal];
libredditCustomRedirects = result.libredditCustomRedirects ?? [];
tedditRedirectsChecks = result.tedditRedirectsChecks ?? [...redirects.teddit.normal];
tedditCustomRedirects = result.tedditCustomRedirects ?? [];
}
export default {
@ -155,6 +203,18 @@ export default {
getRedditFrontend,
setRedditFrontend,
getLibredditRedirectsChecks,
setLibredditRedirectsChecks,
getLibredditCustomRedirects,
setLibredditCustomRedirects,
getTedditRedirectsChecks,
setTedditRedirectsChecks,
getTedditCustomRedirects,
setTedditCustomRedirects,
redirect,
isReddit,
init,

View File

@ -157,6 +157,37 @@ function setSearxRedirects(val) {
browser.storage.sync.set({ searchRedirects: redirects })
console.log("searxRedirects:", val)
}
let whoogleRedirectsChecks;
const getWhoogleRedirectsChecks = () => whoogleRedirectsChecks;
function setWhoogleRedirectsChecks(val) {
whoogleRedirectsChecks = val;
browser.storage.sync.set({ whoogleRedirectsChecks })
console.log("whoogleRedirectsChecks: ", val)
}
let whoogleCustomRedirects = [];
const getWhoogleCustomRedirects = () => whoogleCustomRedirects;
function setWhoogleCustomRedirects(val) {
whoogleCustomRedirects = val;
browser.storage.sync.set({ whoogleCustomRedirects })
console.log("whoogleCustomRedirects: ", val)
}
let searxRedirectsChecks;
const getSearxRedirectsChecks = () => searxRedirectsChecks;
function setSearxRedirectsChecks(val) {
searxRedirectsChecks = val;
browser.storage.sync.set({ searxRedirectsChecks })
console.log("searxRedirectsChecks: ", val)
}
let searxCustomRedirects = [];
const getSearxCustomRedirects = () => searxCustomRedirects;
function setSearxCustomRedirects(val) {
searxCustomRedirects = val;
browser.storage.sync.set({ searxCustomRedirects })
console.log("searxCustomRedirects: ", val)
}
function setWhoogleRedirects(val) {
redirects.whoogle = val;
@ -184,14 +215,18 @@ function redirect(url, initiator) {
if (disableSearch)
return null;
let instance;
let randomInstance;
let path;
if (searchFrontend == 'searx') {
instance = commonHelper.getRandomInstance(redirects.searx.normal);
let instancesList = [...searxRedirectsChecks, ...searxCustomRedirects];
if (instancesList.length === 0) return null;
randomInstance = commonHelper.getRandomInstance(instancesList)
path = "/"
}
if (searchFrontend == 'whoogle') {
instance = commonHelper.getRandomInstance(redirects.whoogle.normal);
let instancesList = [...whoogleRedirectsChecks, ...whoogleCustomRedirects];
if (instancesList.length === 0) return null;
randomInstance = commonHelper.getRandomInstance(instancesList)
path = "/search"
}
@ -199,7 +234,7 @@ function redirect(url, initiator) {
url.search.slice(1).split("&").forEach(function (input) {
if (input.startsWith("q=")) searchQuery = input;
});
return `${instance}${path}?${searchQuery}`;
return `${randomInstance}${path}?${searchQuery}`;
}
function isSearch(url) {
@ -211,11 +246,22 @@ async function init() {
"disableSearch",
"searchFrontend",
"searchRedirects",
"whoogleRedirectsChecks",
"whoogleCustomRedirects",
"searxRedirectsChecks",
"searxCustomRedirects",
])
disableSearch = result.disableSearch ?? false;
searchFrontend = result.searchFrontend ?? 'searx';
if (result.searchRedirects)
redirects = result.searchRedirects;
whoogleRedirectsChecks = result.whoogleRedirectsChecks ?? [...redirects.whoogle.normal];
whoogleCustomRedirects = result.whoogleCustomRedirects ?? [];
searxRedirectsChecks = result.searxRedirectsChecks ?? [...redirects.whoogle.normal];
searxCustomRedirects = result.searxCustomRedirects ?? [];
}
export default {
@ -232,6 +278,18 @@ export default {
getSearchFrontend,
setSearchFrontend,
getWhoogleRedirectsChecks,
setWhoogleRedirectsChecks,
getWhoogleCustomRedirects,
setWhoogleCustomRedirects,
getSearxRedirectsChecks,
setSearxRedirectsChecks,
getSearxCustomRedirects,
setSearxCustomRedirects,
redirect,
init,
};

View File

@ -44,12 +44,46 @@ function setSimplyTranslateRedirects(val) {
console.log("simplyTranslateRedirects:", val)
}
let simplyTranslateRedirectsChecks;
const getSimplyTranslateRedirectsChecks = () => simplyTranslateRedirectsChecks;
function setSimplyTranslateRedirectsChecks(val) {
simplyTranslateRedirectsChecks = val;
browser.storage.sync.set({ simplyTranslateRedirectsChecks })
console.log("simplyTranslateRedirectsChecks: ", val)
}
let simplyTranslateCustomRedirects = [];
const getSimplyTranslateCustomRedirects = () => simplyTranslateCustomRedirects;
function setSimplyTranslateCustomRedirects(val) {
simplyTranslateCustomRedirects = val;
browser.storage.sync.set({ simplyTranslateCustomRedirects })
console.log("simplyTranslateCustomRedirects: ", val)
}
function setLingvaRedirects(val) {
redirects.lingva = val;
browser.storage.sync.set({ translateRedirects: redirects })
console.log("lingvaRedirects:", val)
}
let lingvaRedirectsChecks;
const getLingvaRedirectsChecks = () => lingvaRedirectsChecks;
function setLingvaRedirectsChecks(val) {
lingvaRedirectsChecks = val;
browser.storage.sync.set({ lingvaRedirectsChecks })
console.log("lingvaRedirectsChecks: ", val)
}
let lingvaCustomRedirects = [];
const getLingvaCustomRedirects = () => lingvaCustomRedirects;
function setLingvaCustomRedirects(val) {
lingvaCustomRedirects = val;
browser.storage.sync.set({ lingvaCustomRedirects })
console.log("lingvaCustomRedirects: ", val)
}
let disableTranslate;
const getDisableTranslate = () => disableTranslate;
function setDisableTranslate(val) {
@ -63,34 +97,39 @@ const getFrontend = () => translateFrontend;
function setFrontend(val) {
translateFrontend = val;
browser.storage.sync.set({ translateFrontend })
console.log("Translate frontend: ", frontend)
console.log("Translate frontend: ", val)
}
function redirect(url, initiator) {
if (disableTranslate) {
console.log("SImplyTranslte disabled")
console.log("SimplyTranslate disabled")
return null
};
let link;
if (translateFrontend == 'simplyTransalte') {
link = commonHelper.getRandomInstance(redirects.simplyTranslate.normal);
console.log(`${link}/${url.search}`);
return `${link}/${url.search}`;
if (translateFrontend == 'simplyTranslate') {
let instancesList = [...simplyTranslateRedirectsChecks, ...simplyTranslateCustomRedirects];
if (instancesList.length === 0) return null;
let randomInstance = commonHelper.getRandomInstance(instancesList)
return `${randomInstance}/${url.search}`;
}
else if (translateFrontend == 'lingva') {
let params_arr = url.search.split('&');
params_arr[0] = params_arr[0].substring(1);
let myMap = new Map();
let myMap = {};
for (let i = 0; i < params_arr.length; i++) {
let pair = params_arr[i].split('=');
myMap.set(pair[0], pair[1]);
myMap[pair[0]] = pair[1];
}
link = commonHelper.getRandomInstance(redirects.lingva.normal);
if (myMap.get("sl") && myMap.get("tl") && myMap.get("text"))
return `${link}/${myMap.get("sl")}/${myMap.get("tl")}/${myMap.get("text")}`;
let instancesList = [...lingvaRedirectsChecks, ...lingvaCustomRedirects];
if (instancesList.length === 0) return null;
let randomInstance = commonHelper.getRandomInstance(instancesList)
if (myMap.sl && myMap.tl && myMap.text)
return `${randomInstance}/${myMap.sl}/${myMap.tl}/${myMap.text}`;
else
return link;
return randomInstance;
}
}
@ -103,12 +142,22 @@ async function init() {
let result = await browser.storage.sync.get([
"disableTranslate",
"translateFrontend",
"translateRedirects"
"translateRedirects",
"simplyTranslateRedirectsChecks",
"simplyTranslateCustomRedirects",
"lingvaRedirectsChecks",
"lingvaCustomRedirects",
]);
disableTranslate = result.disableTranslate ?? false;
translateFrontend = result.translateFrontend ?? "simplyTransalte";
translateFrontend = result.translateFrontend ?? "simplyTranslate";
if (result.translateRedirects)
redirects = result.translateRedirects
simplyTranslateRedirectsChecks = result.simplyTranslateRedirectsChecks ?? [...redirects.simplyTranslate.normal];
simplyTranslateCustomRedirects = result.simplyTranslateCustomRedirects ?? [];
lingvaRedirectsChecks = result.lingvaRedirectsChecks ?? [...redirects.lingva.normal];
lingvaCustomRedirects = result.lingvaCustomRedirects ?? [];
}
export default {
@ -124,6 +173,18 @@ export default {
getFrontend,
setFrontend,
getSimplyTranslateRedirectsChecks,
setSimplyTranslateRedirectsChecks,
getSimplyTranslateCustomRedirects,
setSimplyTranslateCustomRedirects,
getLingvaRedirectsChecks,
setLingvaRedirectsChecks,
getLingvaCustomRedirects,
setLingvaCustomRedirects,
redirect,
init,
};

View File

@ -14,6 +14,7 @@ const targets = [
];
let redirects = {
"nitter": {
"normal": [
"https://nitter.net",
"https://nitter.42l.fr",
@ -74,14 +75,31 @@ let redirects = {
"http://nitraeju2mipeziu2wtcrqsxg7h62v5y4eqgwi75uprynkj74gevvuqd.onion",
"http://nitter.lqs5fjmajyp7rvp4qvyubwofzi6d4imua7vs237rkc4m5qogitqwrgyd.onion"
]
}
};
const getRedirects = () => redirects;
function setRedirects(val) {
redirects = val;
browser.storage.sync.set({ twitterRedirects: val })
redirects.nitter = val;
browser.storage.sync.set({ twitterRedirects: redirects })
console.log("twitterRedirects:", val)
}
let nitterRedirectsChecks;
const getNitterRedirectsChecks = () => nitterRedirectsChecks;
function setNitterRedirectsChecks(val) {
nitterRedirectsChecks = val;
browser.storage.sync.set({ nitterRedirectsChecks })
console.log("nitterRedirectsChecks: ", val)
}
let nitterCustomRedirects = [];
const getNitterCustomRedirects = () => nitterCustomRedirects;
function setNitterCustomRedirects(val) {
nitterCustomRedirects = val;
browser.storage.sync.set({ nitterCustomRedirects })
console.log("nitterCustomRedirects: ", val)
}
let disableTwitter;
const getDisableTwitter = () => disableTwitter;
function setDisableTwitter(val) {
@ -97,23 +115,27 @@ function redirect(url, initiator) {
if (url.pathname.split("/").includes("home")) {
return null;
}
let instancesList = [...nitterRedirectsChecks, ...nitterCustomRedirects];
if (instancesList.length === 0) return null;
let randomInstance = commonHelper.getRandomInstance(instancesList)
if (
commonHelper.isFirefox() &&
initiator &&
(redirects.normal.includes(initiator.origin) || targets.includes(initiator.host))
(instancesList.includes(initiator.origin) || targets.includes(initiator.host))
) {
browser.storage.sync.set({ redirectBypassFlag: true });
return null;
}
let link = commonHelper.getRandomInstance(redirects.normal)
if (url.host.split(".")[0] === "pbs" || url.host.split(".")[0] === "video")
return `${link}/pic/${encodeURIComponent(url.href)}`;
return `${randomInstance}/pic/${encodeURIComponent(url.href)}`;
else if (url.pathname.split("/").includes("tweets"))
return `${link}${url.pathname.replace("/tweets", "")}${url.search}`;
return `${randomInstance}${url.pathname.replace("/tweets", "")}${url.search}`;
else
return `${link}${url.pathname}${url.search}`;
return `${randomInstance}${url.pathname}${url.search}`;
}
@ -124,11 +146,16 @@ function isTwitter(url) {
async function init() {
let result = await browser.storage.sync.get([
"disableTwitter",
"twitterRedirects"
"twitterRedirects",
"nitterRedirectsChecks",
"nitterCustomRedirects",
]);
disableTwitter = result.disableTwitter ?? false;
if (result.twitterRedirects)
redirects = result.twitterRedirects;
nitterRedirectsChecks = result.nitterRedirectsChecks ?? [...redirects.nitter.normal];
nitterCustomRedirects = result.nitterCustomRedirects ?? [];
}
export default {
@ -138,6 +165,12 @@ export default {
getDisableTwitter,
setDisableTwitter,
getNitterRedirectsChecks,
setNitterRedirectsChecks,
getNitterCustomRedirects,
setNitterCustomRedirects,
redirect,
isTwitter,
init,

View File

@ -3,6 +3,7 @@ import commonHelper from './common.js'
const targets = /wikipedia.org/;
let redirects = {
"wikiless": {
"normal": [
"https://wikiless.org",
"https://wikiless.alefvanoon.xyz",
@ -12,11 +13,12 @@ let redirects = {
"onion": [
"http://dj2tbh2nqfxyfmvq33cjmhuw7nb6am7thzd3zsjvizeqf374fixbrxyd.onion"
]
}
};
const getRedirects = () => redirects;
function setRedirects(val) {
redirects = val;
browser.storage.sync.set({ wikipediaRedirects: val })
redirects.wikiless = val;
browser.storage.sync.set({ wikipediaRedirects: redirects })
console.log("wikipediaRedirects: ", val)
}
@ -27,6 +29,23 @@ function setDisableWikipedia(val) {
browser.storage.sync.set({ disableWikipedia })
}
let wikilessRedirectsChecks;
const getWikilessRedirectsChecks = () => wikilessRedirectsChecks;
function setWikilessRedirectsChecks(val) {
wikilessRedirectsChecks = val;
browser.storage.sync.set({ wikilessRedirectsChecks })
console.log("wikilessRedirectsChecks: ", val)
}
let wikilessCustomRedirects = [];
const getWikilessCustomRedirects = () => wikilessCustomRedirects;
function setWikilessCustomRedirects(val) {
wikilessCustomRedirects = val;
browser.storage.sync.set({ wikilessCustomRedirects })
console.log("wikilessCustomRedirects: ", val)
}
function redirect(url, initiator) {
if (disableWikipedia) return null;
@ -39,8 +58,15 @@ function redirect(url, initiator) {
GETArguments.push([args[0], args[1]]);
}
}
let instance = commonHelper.getRandomInstance(redirects.normal)
let link = `${instance}${url.pathname}`;
let instancesList = [...wikilessRedirectsChecks, ...wikilessCustomRedirects];
if (instancesList.length === 0)
return null;
let randomInstance = commonHelper.getRandomInstance(instancesList)
let link = `${randomInstance}${url.pathname}`;
let urlSplit = url.host.split(".");
if (urlSplit[0] != "wikipedia" && urlSplit[0] != "www") {
if (urlSplit[0] == "m")
@ -69,11 +95,16 @@ function isWikipedia(url) {
async function init() {
let result = await browser.storage.sync.get([
"disableWikipedia",
"wikipediaRedirects"
"wikipediaRedirects",
"wikilessRedirectsChecks",
"wikilessCustomRedirects",
]);
disableWikipedia = result.disableWikipedia ?? false;
if (result.wikipediaRedirects)
redirects = result.wikipediaRedirects;
wikilessRedirectsChecks = result.wikilessRedirectsChecks ?? [...redirects.wikiless.normal];
wikilessCustomRedirects = result.wikilessCustomRedirects ?? [];
}
export default {
@ -83,6 +114,12 @@ export default {
setDisableWikipedia,
getDisableWikipedia,
getWikilessRedirectsChecks,
setWikilessRedirectsChecks,
getWikilessCustomRedirects,
setWikilessCustomRedirects,
redirect,
isWikipedia,
init,

View File

@ -92,18 +92,25 @@ browser.tabs.onUpdated.addListener((tabId, changeInfo, _) => {
mightyList.push(
...youtubeHelper.getRedirects().invidious.normal,
...youtubeHelper.getRedirects().piped.normal,
...twitterHelper.getRedirects().normal,
...instagramHelper.getRedirects().normal,
...twitterHelper.getRedirects().nitter.normal,
...instagramHelper.getRedirects().bibliogram.normal,
...redditHelper.getRedirects().libreddit.normal,
...redditHelper.getRedirects().teddit.normal,
redditHelper.getRedirects().desktop,
redditHelper.getRedirects().mobile,
...searchHelper.getRedirects().searx.normal,
...searchHelper.getRedirects().whoogle.normal,
...translateHelper.getRedirects().simplyTranslate.normal,
...translateHelper.getRedirects().lingva.normal,
...mediumHelper.getRedirects().normal,
...wikipediaHelper.getRedirects().normal
...mediumHelper.getRedirects().scribe.normal,
...wikipediaHelper.getRedirects().wikiless.normal
);
if (mightyList.includes(protocolHost)) browser.pageAction.show(tabId);

View File

@ -29,6 +29,30 @@
<input id="disable-bibliogram" type="checkbox" checked />
</div>
<hr>
<div class="some-block option-block">
<h4>Default Instances</h4>
</div>
<div class="checklist" id="bibliogram-checklist"></div>
<hr>
<div class="some-block option-block">
<h4>Custom Instances</h4>
</div>
<form id="custom-bibliogram-instance-form">
<div class="some-block option-block">
<input id="bibliogram-custom-instance" placeholder="https://bibliogram.com" type="url" />
<button type="submit" class="add" id="bibliogram-add-instance">
<svg xmlns="http://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px"
fill="currentColor">
<path d="M0 0h24v24H0V0z" fill="none" />
<path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" />
</svg>
</button>
</div>
</form>
<div class="checklist" id="bibliogram-custom-checklist"></div>
</section>
<script type="module" src="../init.js"></script>
<script type="module" src="./instagram.js"></script>

View File

@ -1,4 +1,5 @@
import instagramHelper from "../../../assets/javascripts/helpers/instagram.js";
import commonHelper from "../../../assets/javascripts/helpers/common.js";
let disableInstagramElement = document.getElementById("disable-bibliogram");
disableInstagramElement.addEventListener("change",
@ -7,4 +8,14 @@ disableInstagramElement.addEventListener("change",
instagramHelper.init().then(() => {
disableInstagramElement.checked = !instagramHelper.getDisableInstagram();
commonHelper.processDefaultCustomInstances(
'bibliogram',
instagramHelper,
document,
instagramHelper.getBibliogramRedirectsChecks,
instagramHelper.setBibliogramRedirectsChecks,
instagramHelper.getBibliogramCustomRedirects,
instagramHelper.setBibliogramCustomRedirects
)
})

View File

@ -28,8 +28,33 @@
<h4>Enable</h4>
<input id="disable-scribe" type="checkbox" checked />
</div>
<hr>
<div class="some-block option-block">
<h4>Default Instances</h4>
</div>
<div class="checklist" id="scribe-checklist"></div>
<hr>
<div class="some-block option-block">
<h4>Custom Instances</h4>
</div>
<form id="custom-scribe-instance-form">
<div class="some-block option-block">
<input id="scribe-custom-instance" placeholder="https://scribe.com" type="url" />
<button type="submit" class="add" id="scribe-add-instance">
<svg xmlns="http://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px"
fill="currentColor">
<path d="M0 0h24v24H0V0z" fill="none" />
<path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" />
</svg>
</button>
</div>
</form>
<div class="checklist" id="scribe-custom-checklist"></div>
</section>
<script type="module" src="../init.js"></script>
<script type="module" src="./medium.js"></script>
<!-- <script src="../../assets/javascripts/localise.js"></script> -->

View File

@ -1,4 +1,5 @@
import mediumHelper from "../../../assets/javascripts/helpers/medium.js";
import commonHelper from "../../../assets/javascripts/helpers/common.js";
let disableMediumElement = document.getElementById("disable-scribe");
disableMediumElement.addEventListener("change",
@ -7,4 +8,14 @@ disableMediumElement.addEventListener("change",
mediumHelper.init().then(() => {
disableMediumElement.checked = !mediumHelper.getDisableMedium();
commonHelper.processDefaultCustomInstances(
'scribe',
mediumHelper,
document,
mediumHelper.getScribeRedirectsChecks,
mediumHelper.setScribeRedirectsChecks,
mediumHelper.getScribeCustomRedirects,
mediumHelper.setScribeCustomRedirects
)
})

View File

@ -45,6 +45,58 @@
<option value="teddit">Teddit</option>
</select>
</div>
<hr>
<div id="libreddit">
<div class="some-block option-block">
<h4>Default Instances</h4>
</div>
<div class="checklist" id="libreddit-checklist">
</div>
<hr>
<div class="some-block option-block">
<h4>Custom Instances</h4>
</div>
<form id="custom-libreddit-instance-form">
<div class="some-block option-block">
<input id="libreddit-custom-instance" placeholder="https://libreddit.com" type="url" />
<button type="submit" class="add" id="libreddit-add-instance">
<svg xmlns="http://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px"
fill="currentColor">
<path d="M0 0h24v24H0V0z" fill="none" />
<path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" />
</svg>
</button>
</div>
</form>
<div class="checklist" id="libreddit-custom-checklist"></div>
</div>
<div id="teddit">
<div class="some-block option-block">
<h4>Default Instances</h4>
</div>
<div class="checklist" id="teddit-checklist">
</div>
<hr>
<div class="some-block option-block">
<h4>Custom Instances</h4>
</div>
<form id="custom-teddit-instance-form">
<div class="some-block option-block">
<input id="teddit-custom-instance" placeholder="https://teddit.com" type="url" />
<button type="submit" class="add" id="teddit-add-instance">
<svg xmlns="http://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px"
fill="currentColor">
<path d="M0 0h24v24H0V0z" fill="none" />
<path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" />
</svg>
</button>
</div>
</form>
<div class="checklist" id="teddit-custom-checklist"></div>
</div>
</section>
<script type="module" src="../init.js"></script>

View File

@ -1,16 +1,54 @@
import redditHelper from "../../../assets/javascripts/helpers/reddit.js";
import commonHelper from "../../../assets/javascripts/helpers/common.js";
let disableRedditElement = document.getElementById("disable-reddit");
disableRedditElement.addEventListener("change",
(event) => redditHelper.setDisableReddit(!event.target.checked)
);
let libredditDivElement = document.getElementById("libreddit")
let tedditDivElement = document.getElementById("teddit")
function changeFrontendsSettings(frontend) {
if (frontend == 'libreddit') {
libredditDivElement.style.display = 'block';
tedditDivElement.style.display = 'none';
}
else if (frontend == 'teddit') {
libredditDivElement.style.display = 'none';
tedditDivElement.style.display = 'block';
}
}
let redditFrontendElement = document.getElementById("reddit-frontend");
redditFrontendElement.addEventListener("change",
(event) => redditHelper.setRedditFrontend(event.target.options[redditFrontendElement.selectedIndex].value)
(event) => {
let frontend = event.target.options[redditFrontendElement.selectedIndex].value
redditHelper.setRedditFrontend(frontend)
changeFrontendsSettings(frontend);
}
);
redditHelper.init().then(() => {
disableRedditElement.checked = !redditHelper.getDisableReddit();
redditFrontendElement.value = redditHelper.getRedditFrontend();
commonHelper.processDefaultCustomInstances(
'libreddit',
redditHelper,
document,
redditHelper.getLibredditRedirectsChecks,
redditHelper.setLibredditRedirectsChecks,
redditHelper.getLibredditCustomRedirects,
redditHelper.setLibredditCustomRedirects
)
commonHelper.processDefaultCustomInstances(
'teddit',
redditHelper,
document,
redditHelper.getTedditRedirectsChecks,
redditHelper.setTedditRedirectsChecks,
redditHelper.getTedditCustomRedirects,
redditHelper.setTedditCustomRedirects
)
})

View File

@ -28,15 +28,6 @@
<h4>Enable</h4>
<input id="disable-search" type="checkbox" checked />
</div>
<!-- <div class="some-block option-block">
<h4>Instance</h4>
<div class="autocomplete">
<input id="search-instance" type="url"
data-localise-placeholder="__MSG_randomInstancePlaceholder__"
placeholder="Random instance (none selected)" />
</div>
</div> -->
<div class="some-block option-block">
<h4>Frontend</h4>
<select id="search-frontend">
@ -44,6 +35,57 @@
<option value="whoogle">Whoogle</option>
</select>
</div>
<hr>
<div id="searx">
<div class="some-block option-block">
<h4>Default Instances</h4>
</div>
<div class="checklist" id="searx-checklist">
</div>
<hr>
<div class="some-block option-block">
<h4>Custom Instances</h4>
</div>
<form id="custom-searx-instance-form">
<div class="some-block option-block">
<input id="searx-custom-instance" placeholder="https://searx.com" type="url" />
<button type="submit" class="add" id="searx-add-instance">
<svg xmlns="http://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px"
fill="currentColor">
<path d="M0 0h24v24H0V0z" fill="none" />
<path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" />
</svg>
</button>
</div>
</form>
<div class="checklist" id="searx-custom-checklist"></div>
</div>
<div id="whoogle">
<div class="some-block option-block">
<h4>Default Instances</h4>
</div>
<div class="checklist" id="whoogle-checklist">
</div>
<hr>
<div class="some-block option-block">
<h4>Custom Instances</h4>
</div>
<form id="custom-whoogle-instance-form">
<div class="some-block option-block">
<input id="whoogle-custom-instance" placeholder="https://whoogle.com" type="url" />
<button type="submit" class="add" id="whoogle-add-instance">
<svg xmlns="http://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px"
fill="currentColor">
<path d="M0 0h24v24H0V0z" fill="none" />
<path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" />
</svg>
</button>
</div>
</form>
<div class="checklist" id="whoogle-custom-checklist"></div>
</div>
</section>

View File

@ -1,16 +1,58 @@
import searchHelper from "../../../assets/javascripts/helpers/search.js";
let searchFrontendElement = document.getElementById("search-frontend");
searchFrontendElement.addEventListener("change",
(event) => searchHelper.setSearchFrontend(event.target.options[searchFrontendElement.selectedIndex].value)
);
import commonHelper from "../../../assets/javascripts/helpers/common.js";
let disableSearchElement = document.getElementById("disable-search");
disableSearchElement.addEventListener("change",
(event) => searchHelper.setDisableSearch(!event.target.checked)
);
let searxDivElement = document.getElementById("searx")
let whoogleDivElement = document.getElementById("whoogle")
function changeFrontendsSettings(frontend) {
if (frontend == 'searx') {
searxDivElement.style.display = 'block';
whoogleDivElement.style.display = 'none';
}
else if (frontend == 'whoogle') {
searxDivElement.style.display = 'none';
whoogleDivElement.style.display = 'block';
}
}
let searchFrontendElement = document.getElementById("search-frontend");
searchFrontendElement.addEventListener("change",
(event) => {
let frontend = event.target.options[searchFrontendElement.selectedIndex].value
searchHelper.setSearchFrontend(frontend)
changeFrontendsSettings(frontend);
}
);
searchHelper.init().then(() => {
disableSearchElement.checked = !searchHelper.getDisableSearch();
searchFrontendElement.value = searchHelper.getSearchFrontend();
let frontend = searchHelper.getSearchFrontend();
searchFrontendElement.value = frontend;
changeFrontendsSettings(frontend);
commonHelper.processDefaultCustomInstances(
'searx',
searchHelper,
document,
searchHelper.getSearxRedirectsChecks,
searchHelper.setSearxRedirectsChecks,
searchHelper.getSearxCustomRedirects,
searchHelper.setSearxCustomRedirects
)
commonHelper.processDefaultCustomInstances(
'whoogle',
searchHelper,
document,
searchHelper.getWhoogleRedirectsChecks,
searchHelper.setWhoogleRedirectsChecks,
searchHelper.getWhoogleCustomRedirects,
searchHelper.setWhoogleCustomRedirects
)
});

View File

@ -27,20 +27,67 @@
<h4>Enable</h4>
<input id="disable-simplyTranslate" type="checkbox" checked />
</div>
<!-- <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 class="some-block option-block">
<h4>Frontend</h4>
<select id="translate-frontend">
<option value="simplyTransalte">SimplyTransalte</option>
<option value="simplyTranslate">SimplyTranslate</option>
<option value="lingva">Lingva</option>
</select>
</div>
<hr>
<div id="simplyTranslate">
<div class="some-block option-block">
<h4>Default Instances</h4>
</div>
<div class="checklist" id="simplyTranslate-checklist">
</div>
<hr>
<div class="some-block option-block">
<h4>Custom Instances</h4>
</div>
<form id="custom-simplyTranslate-instance-form">
<div class="some-block option-block">
<input id="simplyTranslate-custom-instance" placeholder="https://simplyTranslate.com" type="url" />
<button type="submit" class="add" id="simplyTranslate-add-instance">
<svg xmlns="http://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px"
fill="currentColor">
<path d="M0 0h24v24H0V0z" fill="none" />
<path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" />
</svg>
</button>
</div>
</form>
<div class="checklist" id="simplyTranslate-custom-checklist"></div>
</div>
<div id="lingva">
<div class="some-block option-block">
<h4>Default Instances</h4>
</div>
<div class="checklist" id="lingva-checklist">
</div>
<hr>
<div class="some-block option-block">
<h4>Custom Instances</h4>
</div>
<form id="custom-lingva-instance-form">
<div class="some-block option-block">
<input id="lingva-custom-instance" placeholder="https://lingva.com" type="url" />
<button type="submit" class="add" id="lingva-add-instance">
<svg xmlns="http://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px"
fill="currentColor">
<path d="M0 0h24v24H0V0z" fill="none" />
<path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" />
</svg>
</button>
</div>
</form>
<div class="checklist" id="lingva-custom-checklist"></div>
</div>
</section>
<script type="module" src="../init.js"></script>

View File

@ -1,16 +1,58 @@
import translateHelper from "../../../assets/javascripts/helpers/translate.js";
import commonHelper from "../../../assets/javascripts/helpers/common.js";
let disableTranslateElement = document.getElementById("disable-simplyTranslate");
disableTranslateElement.addEventListener("change",
(event) => translateHelper.setDisableTranslate(!event.target.checked)
);
let simplyTranslateDivElement = document.getElementById("simplyTranslate")
let lingvaDivElement = document.getElementById("lingva")
function changeFrontendsSettings(frontend) {
if (frontend == 'simplyTranslate') {
simplyTranslateDivElement.style.display = 'block';
lingvaDivElement.style.display = 'none';
}
else if (frontend == 'lingva') {
simplyTranslateDivElement.style.display = 'none';
lingvaDivElement.style.display = 'block';
}
}
let translateFrontendElement = document.getElementById("translate-frontend");
translateFrontendElement.addEventListener("change",
(event) => translateHelper.setFrontend(event.target.options[translateFrontendElement.selectedIndex].value)
(event) => {
let frontend = event.target.options[translateFrontendElement.selectedIndex].value
translateHelper.setFrontend(frontend)
changeFrontendsSettings(frontend);
}
);
translateHelper.init().then(() => {
disableTranslateElement.checked = !translateHelper.getDisableTranslate();
translateFrontendElement.value = translateHelper.getFrontend();
let frontend = translateHelper.getFrontend();
translateFrontendElement.value = frontend;
changeFrontendsSettings(frontend);
commonHelper.processDefaultCustomInstances(
'simplyTranslate',
translateHelper,
document,
translateHelper.getSimplyTranslateRedirectsChecks,
translateHelper.setSimplyTranslateRedirectsChecks,
translateHelper.getSimplyTranslateCustomRedirects,
translateHelper.setSimplyTranslateCustomRedirects
)
commonHelper.processDefaultCustomInstances(
'lingva',
translateHelper,
document,
translateHelper.getLingvaRedirectsChecks,
translateHelper.setLingvaRedirectsChecks,
translateHelper.getLingvaCustomRedirects,
translateHelper.setLingvaCustomRedirects
)
});

View File

@ -30,10 +30,30 @@
<h4>Enable</h4>
<input id="disable-nitter" type="checkbox" checked />
</div>
<hr>
<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 />
<h4>Default Instances</h4>
</div>
<div class="checklist" id="nitter-checklist"></div>
<hr>
<div class="some-block option-block">
<h4>Custom Instances</h4>
</div>
<form id="custom-nitter-instance-form">
<div class="some-block option-block">
<input id="nitter-custom-instance" placeholder="https://nitter.com" type="url" />
<button type="submit" class="add" id="nitter-add-instance">
<svg xmlns="http://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px"
fill="currentColor">
<path d="M0 0h24v24H0V0z" fill="none" />
<path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" />
</svg>
</button>
</div>
</form>
<div class="checklist" id="nitter-custom-checklist"></div>
</section>

View File

@ -1,4 +1,5 @@
import twitterHelper from "../../../assets/javascripts/helpers/twitter.js";
import commonHelper from "../../../assets/javascripts/helpers/common.js";
let disableTwitterElement = document.getElementById("disable-nitter");
disableTwitterElement.addEventListener("change",
@ -7,4 +8,14 @@ disableTwitterElement.addEventListener("change",
twitterHelper.init().then(() => {
disableTwitterElement.checked = !twitterHelper.getDisableTwitter();
commonHelper.processDefaultCustomInstances(
'nitter',
twitterHelper,
document,
twitterHelper.getNitterRedirectsChecks,
twitterHelper.setNitterRedirectsChecks,
twitterHelper.getNitterCustomRedirects,
twitterHelper.setNitterCustomRedirects
)
});

View File

@ -28,6 +28,32 @@
<h4>Enable</h4>
<input id="disable-wikipedia" type="checkbox" checked />
</div>
<hr>
<div class="some-block option-block">
<h4>Default Instances</h4>
</div>
<div class="checklist" id="wikiless-checklist">
</div>
<hr>
<div class="some-block option-block">
<h4>Custom Instances</h4>
</div>
<form id="custom-wikiless-instance-form">
<div class="some-block option-block">
<input id="wikiless-custom-instance" placeholder="https://wikiless.com" type="url" />
<button type="submit" class="add" id="wikiless-add-instance">
<svg xmlns="http://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px"
fill="currentColor">
<path d="M0 0h24v24H0V0z" fill="none" />
<path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" />
</svg>
</button>
</div>
</form>
<div class="checklist" id="wikiless-custom-checklist"></div>
</section>
<script type="module" src="../init.js"></script>

View File

@ -1,10 +1,20 @@
import wikipediaHelper from "../../../assets/javascripts/helpers/wikipedia.js";
import commonHelper from "../../../assets/javascripts/helpers/common.js";
let disableWikipediaElement = document.getElementById("disable-wikipedia");
disableWikipediaElement.addEventListener("change",
(event) => wikipediaHelper.setDisableWikipedia(!event.target.checked)
);
wikipediaHelper.init().then(() => {
disableWikipediaElement.checked = !wikipediaHelper.getDisableWikipedia();
commonHelper.processDefaultCustomInstances(
'wikiless',
wikipediaHelper,
document,
wikipediaHelper.getWikilessRedirectsChecks,
wikipediaHelper.setWikilessRedirectsChecks,
wikipediaHelper.getWikilessCustomRedirects,
wikipediaHelper.setWikilessCustomRedirects
)
})

View File

@ -146,7 +146,10 @@
</div>
<div id="piped">
<hr>
<div class="some-block option-block">
<h4>Default Instances</h4>
</div>