mirror of
https://codeberg.org/LibRedirect/libredirect.git
synced 2025-01-31 19:44:54 +01:00
Fixed buttons in the general tab
This commit is contained in:
parent
060629143a
commit
68f9fbb3f7
@ -28,7 +28,7 @@ Reddit => [Libreddit](https://github.com/spikecodes/libreddit#instances), [Teddi
|
||||
Imgur => [Rimgo](https://codeberg.org/video-prize-ranch/rimgo)\
|
||||
Wikipedia => [Wikiless](https://codeberg.org/orenom/wikiless)\
|
||||
Medium => [Scribe](https://sr.ht/~edwardloveall/scribe/)\
|
||||
Peertube => [SimpleerTube](https://git.sr.ht/~metalune/simpleweb_peertube)\
|
||||
PeerTube => [SimpleerTube](https://git.sr.ht/~metalune/simpleweb_peertube)\
|
||||
LBRY/Odysee => [Librarian](https://codeberg.org/librarian/librarian)\
|
||||
Search => [SearXNG](https://github.com/searxng/searxng), [SearX](https://searx.github.io/searx/), [Whoogle](https://benbusby.com/projects/whoogle-search/)\
|
||||
Translate => [SimplyTranslate](https://git.sr.ht/~metalune/simplytranslate_web), [LingvaTranslate](https://github.com/TheDavidDelta/lingva-translate)\
|
||||
|
@ -1,88 +1,49 @@
|
||||
"use strict";
|
||||
window.browser = window.browser || window.chrome;
|
||||
|
||||
let theme;
|
||||
const getTheme = () => theme;
|
||||
function setTheme(val) {
|
||||
theme = val
|
||||
browser.storage.local.set({ theme, instancesCookies: [] });
|
||||
console.log("theme: ", theme)
|
||||
}
|
||||
|
||||
let exceptions = {
|
||||
"url": [],
|
||||
"regex": [],
|
||||
};
|
||||
const getExceptions = () => exceptions;
|
||||
function setExceptions(val) {
|
||||
exceptions = val;
|
||||
browser.storage.local.set({ exceptions })
|
||||
console.log("exceptions: ", val)
|
||||
}
|
||||
|
||||
let autoRedirect;
|
||||
const getAutoRedirect = () => autoRedirect;
|
||||
function setAutoRedirect(val) {
|
||||
autoRedirect = val;
|
||||
browser.storage.local.set({ autoRedirect })
|
||||
console.log("autoRedirect: ", val)
|
||||
}
|
||||
|
||||
function isException(url) {
|
||||
for (const item of exceptions.url) {
|
||||
console.log(item, `${url.protocol}//${url.host}`)
|
||||
if (item == `${url.protocol}//${url.host}`) return true;
|
||||
}
|
||||
for (const item of exceptions.regex)
|
||||
if (new RegExp(item).test(url.href)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
async function init() {
|
||||
return new Promise(
|
||||
resolve => browser.storage.local.get(
|
||||
[
|
||||
"exceptions",
|
||||
"theme",
|
||||
"popupFrontends",
|
||||
"autoRedirect"
|
||||
],
|
||||
return new Promise(resolve => {
|
||||
browser.storage.local.get(
|
||||
'exceptions',
|
||||
r => {
|
||||
if (r.exceptions) exceptions = r.exceptions;
|
||||
|
||||
theme = r.theme ?? "DEFAULT"
|
||||
|
||||
popupFrontends = r.popupFrontends ?? [
|
||||
"youtube",
|
||||
"twitter",
|
||||
"instagram",
|
||||
"tikTok",
|
||||
"imgur",
|
||||
"reddit",
|
||||
"search",
|
||||
"medium",
|
||||
"translate",
|
||||
"maps",
|
||||
];
|
||||
|
||||
autoRedirect = r.autoRedirect ?? false;
|
||||
|
||||
resolve();
|
||||
for (const item of r.exceptions.url)
|
||||
if (item == `${url.protocol}//${url.host}`) { resolve(true); return; }
|
||||
for (const item of r.exceptions.regex)
|
||||
if (new RegExp(item).test(url.href)) { resolve(true); return; }
|
||||
resolve(false); return;
|
||||
}
|
||||
)
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
function initDefaults() {
|
||||
return new Promise(async resolve => {
|
||||
await browser.storage.local.set({
|
||||
exceptions: {
|
||||
"url": [],
|
||||
"regex": [],
|
||||
},
|
||||
theme: "DEFAULT",
|
||||
popupFrontends: [
|
||||
"youtube",
|
||||
"twitter",
|
||||
"instagram",
|
||||
"tikTok",
|
||||
"imgur",
|
||||
"reddit",
|
||||
"search",
|
||||
"medium",
|
||||
"translate",
|
||||
"maps",
|
||||
],
|
||||
autoRedirect: false,
|
||||
})
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
let popupFrontends;
|
||||
const getPopupFrontends = () => popupFrontends;
|
||||
function setPopupFrontends(val) {
|
||||
popupFrontends = val;
|
||||
browser.storage.local.set({ popupFrontends })
|
||||
console.log("popupFrontends: ", val)
|
||||
}
|
||||
|
||||
let allPopupFrontends = [
|
||||
const allPopupFrontends = [
|
||||
"youtube",
|
||||
"youtubeMusic",
|
||||
"twitter",
|
||||
@ -102,20 +63,7 @@ let allPopupFrontends = [
|
||||
|
||||
|
||||
export default {
|
||||
getExceptions,
|
||||
setExceptions,
|
||||
|
||||
getAutoRedirect,
|
||||
setAutoRedirect,
|
||||
|
||||
getPopupFrontends,
|
||||
setPopupFrontends,
|
||||
|
||||
allPopupFrontends,
|
||||
|
||||
getTheme,
|
||||
setTheme,
|
||||
|
||||
isException,
|
||||
init,
|
||||
initDefaults,
|
||||
allPopupFrontends,
|
||||
}
|
||||
|
@ -167,31 +167,32 @@ function switchInstance(url) {
|
||||
})
|
||||
}
|
||||
|
||||
async function initDefaults() {
|
||||
fetch('/instances/data.json').then(response => response.text()).then(async data => {
|
||||
let dataJson = JSON.parse(data);
|
||||
redirects.rimgo = dataJson.rimgo;
|
||||
browser.storage.local.get('cloudflareList', async r => {
|
||||
rimgoNormalRedirectsChecks = [...redirects.rimgo.normal];
|
||||
for (const instance of r.cloudflareList) {
|
||||
let i;
|
||||
function initDefaults() {
|
||||
return new Promise(resolve => {
|
||||
fetch('/instances/data.json').then(response => response.text()).then(async data => {
|
||||
let dataJson = JSON.parse(data);
|
||||
redirects.rimgo = dataJson.rimgo;
|
||||
browser.storage.local.get('cloudflareList', async r => {
|
||||
rimgoNormalRedirectsChecks = [...redirects.rimgo.normal];
|
||||
for (const instance of r.cloudflareList) {
|
||||
let i = rimgoNormalRedirectsChecks.indexOf(instance);
|
||||
if (i > -1) rimgoNormalRedirectsChecks.splice(i, 1);
|
||||
}
|
||||
await browser.storage.local.set({
|
||||
disableImgur: false,
|
||||
imgurProtocol: 'normal',
|
||||
imgurRedirects: redirects,
|
||||
|
||||
i = rimgoNormalRedirectsChecks.indexOf(instance);
|
||||
if (i > -1) rimgoNormalRedirectsChecks.splice(i, 1);
|
||||
}
|
||||
await browser.storage.local.set({
|
||||
disableImgur: false,
|
||||
imgurProtocol: 'normal',
|
||||
imgurRedirects: redirects,
|
||||
rimgoNormalRedirectsChecks: rimgoNormalRedirectsChecks,
|
||||
rimgoNormalCustomRedirects: [],
|
||||
|
||||
rimgoNormalRedirectsChecks: rimgoNormalRedirectsChecks,
|
||||
rimgoNormalCustomRedirects: [],
|
||||
rimgoTorRedirectsChecks: [...redirects.rimgo.tor],
|
||||
rimgoTorCustomRedirects: [],
|
||||
|
||||
rimgoTorRedirectsChecks: [...redirects.rimgo.tor],
|
||||
rimgoTorCustomRedirects: [],
|
||||
|
||||
rimgoI2pRedirectsChecks: [...redirects.rimgo.i2p],
|
||||
rimgoI2pCustomRedirects: [],
|
||||
rimgoI2pRedirectsChecks: [...redirects.rimgo.i2p],
|
||||
rimgoI2pCustomRedirects: [],
|
||||
});
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -12,15 +12,18 @@ let redirects = {
|
||||
}
|
||||
};
|
||||
function setRedirects(val) {
|
||||
redirects.bibliogram = val;
|
||||
browser.storage.local.set({ instagramRedirects: redirects })
|
||||
console.log("instagramRedirects: ", val)
|
||||
for (const item of bibliogramNormalRedirectsChecks)
|
||||
if (!redirects.bibliogram.normal.includes(item)) {
|
||||
var index = bibliogramNormalRedirectsChecks.indexOf(item);
|
||||
if (index !== -1) bibliogramNormalRedirectsChecks.splice(index, 1);
|
||||
browser.storage.local.get('cloudflareList', async r => {
|
||||
redirects.bibliogram = val;
|
||||
bibliogramNormalRedirectsChecks = [...redirects.bibliogram.normal];
|
||||
for (const instance of r.cloudflareList) {
|
||||
const a = bibliogramNormalRedirectsChecks.indexOf(instance);
|
||||
if (a > -1) bibliogramNormalRedirectsChecks.splice(a, 1);
|
||||
}
|
||||
browser.storage.local.set({ bibliogramNormalRedirectsChecks });
|
||||
browser.storage.local.set({
|
||||
instagramRedirects: redirects,
|
||||
bibliogramNormalRedirectsChecks
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
let bibliogramNormalRedirectsChecks;
|
||||
@ -49,7 +52,7 @@ function redirect(url, type, initiator) {
|
||||
...r.instagramRedirects.bibliogram.tor,
|
||||
...r.bibliogramNormalCustomRedirects,
|
||||
...r.bibliogramTorCustomRedirects,
|
||||
].includes(initiator.origin) || targets.includes(initiator.host))
|
||||
].includes(initiator.origin))
|
||||
) { resolve('BYPASSTAB'); return; }
|
||||
|
||||
if (!targets.includes(url.host)) { resolve(); return; }
|
||||
|
@ -120,28 +120,31 @@ function redirect(url, type, initiator) {
|
||||
})
|
||||
}
|
||||
|
||||
async function initDefaults() {
|
||||
browser.storage.local.get('cloudflareList', async r => {
|
||||
librarianNormalRedirectsChecks = [...redirects.librarian.normal];
|
||||
for (const instance of r.cloudflareList) {
|
||||
let i;
|
||||
function initDefaults() {
|
||||
return new Promise(resolve => {
|
||||
browser.storage.local.get('cloudflareList', async r => {
|
||||
librarianNormalRedirectsChecks = [...redirects.librarian.normal];
|
||||
for (const instance of r.cloudflareList) {
|
||||
let i;
|
||||
|
||||
i = librarianNormalRedirectsChecks.indexOf(instance);
|
||||
if (i > -1) librarianNormalRedirectsChecks.splice(i, 1);
|
||||
}
|
||||
await browser.storage.local.set({
|
||||
disableLbryTargets: true,
|
||||
lbryTargetsRedirects: {
|
||||
'librarian': redirects.librarian
|
||||
},
|
||||
i = librarianNormalRedirectsChecks.indexOf(instance);
|
||||
if (i > -1) librarianNormalRedirectsChecks.splice(i, 1);
|
||||
}
|
||||
await browser.storage.local.set({
|
||||
disableLbryTargets: true,
|
||||
lbryTargetsRedirects: {
|
||||
'librarian': redirects.librarian
|
||||
},
|
||||
|
||||
librarianNormalRedirectsChecks: librarianNormalRedirectsChecks,
|
||||
librarianNormalCustomRedirects: [],
|
||||
librarianNormalRedirectsChecks: librarianNormalRedirectsChecks,
|
||||
librarianNormalCustomRedirects: [],
|
||||
|
||||
librarianTorRedirectsChecks: [...redirects.librarian.tor],
|
||||
librarianTorCustomRedirects: [],
|
||||
librarianTorRedirectsChecks: [...redirects.librarian.tor],
|
||||
librarianTorCustomRedirects: [],
|
||||
|
||||
lbryTargetsProtocol: "normal",
|
||||
lbryTargetsProtocol: "normal",
|
||||
})
|
||||
resolve();
|
||||
})
|
||||
})
|
||||
}
|
||||
|
@ -18,172 +18,180 @@ let redirects = {
|
||||
}
|
||||
};
|
||||
|
||||
let disable; // disableMaps
|
||||
let frontend; // mapsFrontend
|
||||
function redirect(url, initiator) {
|
||||
return new Promise(
|
||||
resolve => {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"disableMaps",
|
||||
"mapsFrontend",
|
||||
|
||||
let facilNormalRedirectsChecks;
|
||||
let facilNormalCustomRedirects = [];
|
||||
"facilNormalRedirectsChecks",
|
||||
"facilNormalCustomRedirects",
|
||||
],
|
||||
async r => {
|
||||
const mapCentreRegex = /@(-?\d[0-9.]*),(-?\d[0-9.]*),(\d{1,2})[.z]/;
|
||||
const dataLatLngRegex = /!3d(-?[0-9]{1,}.[0-9]{1,})!4d(-?[0-9]{1,}.[0-9]{1,})/;
|
||||
const placeRegex = /\/place\/(.*)\//;
|
||||
const travelModes = {
|
||||
driving: "fossgis_osrm_car",
|
||||
walking: "fossgis_osrm_foot",
|
||||
bicycling: "fossgis_osrm_bike",
|
||||
transit: "fossgis_osrm_car", // not implemented on OSM, default to car.
|
||||
};
|
||||
const travelModesFacil = {
|
||||
driving: "car",
|
||||
walking: "pedestrian",
|
||||
bicycling: "bicycle",
|
||||
transit: "car", // not implemented on Facil, default to car.
|
||||
};
|
||||
const osmLayers = {
|
||||
none: "S",
|
||||
transit: "T",
|
||||
traffic: "S", // not implemented on OSM, default to standard.
|
||||
bicycling: "C",
|
||||
};
|
||||
|
||||
async function redirect(url, initiator) {
|
||||
const mapCentreRegex = /@(-?\d[0-9.]*),(-?\d[0-9.]*),(\d{1,2})[.z]/;
|
||||
const dataLatLngRegex = /!3d(-?[0-9]{1,}.[0-9]{1,})!4d(-?[0-9]{1,}.[0-9]{1,})/;
|
||||
const placeRegex = /\/place\/(.*)\//;
|
||||
const travelModes = {
|
||||
driving: "fossgis_osrm_car",
|
||||
walking: "fossgis_osrm_foot",
|
||||
bicycling: "fossgis_osrm_bike",
|
||||
transit: "fossgis_osrm_car", // not implemented on OSM, default to car.
|
||||
};
|
||||
const travelModesFacil = {
|
||||
driving: "car",
|
||||
walking: "pedestrian",
|
||||
bicycling: "bicycle",
|
||||
transit: "car", // not implemented on Facil, default to car.
|
||||
};
|
||||
const osmLayers = {
|
||||
none: "S",
|
||||
transit: "T",
|
||||
traffic: "S", // not implemented on OSM, default to standard.
|
||||
bicycling: "C",
|
||||
};
|
||||
async function addressToLatLng(address) {
|
||||
return new Promise(async resolve => {
|
||||
const xmlhttp = new XMLHttpRequest();
|
||||
xmlhttp.onreadystatechange = () => {
|
||||
if (xmlhttp.readyState === XMLHttpRequest.DONE) {
|
||||
if (xmlhttp.status === 200) {
|
||||
const json = JSON.parse(xmlhttp.responseText)[0];
|
||||
|
||||
async function addressToLatLng(address) {
|
||||
return new Promise(async resolve => {
|
||||
const xmlhttp = new XMLHttpRequest();
|
||||
xmlhttp.onreadystatechange = () => {
|
||||
if (xmlhttp.readyState === XMLHttpRequest.DONE) {
|
||||
if (xmlhttp.status === 200) {
|
||||
const json = JSON.parse(xmlhttp.responseText)[0];
|
||||
if (json) {
|
||||
console.log('json', json)
|
||||
resolve([
|
||||
`${json.lat},${json.lon}`,
|
||||
`${json.boundingbox[2]},${json.boundingbox[1]},${json.boundingbox[3]},${json.boundingbox[0]}`,
|
||||
]);
|
||||
}
|
||||
} else
|
||||
console.info("Error: Status is " + xmlhttp.status);
|
||||
}
|
||||
};
|
||||
xmlhttp.open(
|
||||
"GET",
|
||||
`https://nominatim.openstreetmap.org/search/${address}?format=json&limit=1`,
|
||||
true
|
||||
);
|
||||
xmlhttp.send();
|
||||
})
|
||||
}
|
||||
|
||||
if (json) {
|
||||
console.log('json', json)
|
||||
resolve([
|
||||
`${json.lat},${json.lon}`,
|
||||
`${json.boundingbox[2]},${json.boundingbox[1]},${json.boundingbox[3]},${json.boundingbox[0]}`,
|
||||
]);
|
||||
if (r.disableMaps) { resolve(); return; }
|
||||
if (initiator && initiator.host === "earth.google.com") { resolve(); return; }
|
||||
if (!url.href.match(targets)) { resolve(); return; }
|
||||
|
||||
let randomInstance;
|
||||
if (r.mapsFrontend == 'osm') randomInstance = utils.getRandomInstance(redirects.osm.normal);
|
||||
if (r.mapsFrontend == 'facil') randomInstance = utils.getRandomInstance([...r.facilNormalRedirectsChecks, ...r.facilNormalCustomRedirects]);
|
||||
|
||||
let mapCentre = "#";
|
||||
let prefs = {};
|
||||
|
||||
if (url.pathname.match(mapCentreRegex)) { // Set map centre if present
|
||||
var [, lat, lon, zoom] = url.pathname.match(mapCentreRegex);
|
||||
} else if (url.searchParams.has("center")) {
|
||||
var [lat, lon] = url.searchParams.get("center").split(",");
|
||||
var zoom = url.searchParams.get("zoom") ?? "17";
|
||||
}
|
||||
|
||||
if (lat && lon && zoom) {
|
||||
if (r.mapsFrontend == 'osm') mapCentre = `#map=${zoom}/${lat}/${lon}`;
|
||||
if (r.mapsFrontend == 'facil') mapCentre = `#${zoom}/${lat}/${lon}`;
|
||||
}
|
||||
|
||||
if (url.searchParams.get("layer")) prefs.layers = osmLayers[url.searchParams.get("layer")];
|
||||
|
||||
if (url.pathname.includes("/embed")) { // Handle Google Maps Embed API
|
||||
// https://www.google.com/maps/embed/v1/place?key=AIzaSyD4iE2xVSpkLLOXoyqT-RuPwURN3ddScAI&q=Eiffel+Tower,Paris+France
|
||||
console.log("embed life");
|
||||
|
||||
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 [coords, boundingbox] = await addressToLatLng(query);
|
||||
prefs.bbox = boundingbox;
|
||||
prefs.marker = coords;
|
||||
prefs.layer = "mapnik";
|
||||
let prefsEncoded = new URLSearchParams(prefs).toString();
|
||||
if (r.mapsFrontend == 'osm') { resolve(`${randomInstance}/export/embed.html?${prefsEncoded}`); return; }
|
||||
|
||||
if (r.mapsFrontend == 'facil') { resolve(`${randomInstance}/#q=${query}`); return; }
|
||||
|
||||
} else if (url.pathname.includes("/dir")) { // Handle Google Maps Directions
|
||||
// https://www.google.com/maps/dir/?api=1&origin=Space+Needle+Seattle+WA&destination=Pike+Place+Market+Seattle+WA&travelmode=bicycling
|
||||
|
||||
let travMod = url.searchParams.get("travelmode");
|
||||
if (url.searchParams.has("travelmode")) prefs.engine = travelModes[travMod];
|
||||
|
||||
let orgVal = url.searchParams.get("origin");
|
||||
let destVal = url.searchParams.get("destination");
|
||||
|
||||
let org; addressToLatLng(orgVal, a => org = a);
|
||||
let dest; addressToLatLng(destVal, a => dest = a);
|
||||
prefs.route = `${org};${dest}`;
|
||||
|
||||
let prefsEncoded = new URLSearchParams(prefs).toString();
|
||||
if (r.mapsFrontend == 'osm') { resolve(`${randomInstance}/directions?${prefsEncoded}${mapCentre}`); return; }
|
||||
if (r.mapsFrontend == 'facil') { resolve(`${randomInstance}/#q=${orgVal}%20to%20${destVal}%20by%20${travelModesFacil[travMod]}`); return; }
|
||||
|
||||
} else if (url.pathname.includes("data=") && url.pathname.match(dataLatLngRegex)) { // Get marker from data attribute
|
||||
// https://www.google.com/maps/place/41%C2%B001'58.2%22N+40%C2%B029'18.2%22E/@41.032833,40.4862063,17z/data=!3m1!4b1!4m6!3m5!1s0x0:0xf64286eaf72fc49d!7e2!8m2!3d41.0328329!4d40.4883948
|
||||
console.log("data life");
|
||||
|
||||
let [, mlat, mlon] = url.pathname.match(dataLatLngRegex);
|
||||
|
||||
if (r.mapsFrontend == 'osm') { resolve(`${randomInstance}/search?query=${mlat}%2C${mlon}`); return; }
|
||||
if (r.mapsFrontend == 'facil') { resolve(`${randomInstance}/#q=${mlat}%2C${mlon}`); return; }
|
||||
|
||||
} else if (url.searchParams.has("ll")) { // Get marker from ll param
|
||||
// https://maps.google.com/?ll=38.882147,-76.99017
|
||||
console.log("ll life");
|
||||
|
||||
const [mlat, mlon] = url.searchParams.get("ll").split(",");
|
||||
|
||||
if (r.mapsFrontend == 'osm') { resolve(`${randomInstance}/search?query=${mlat}%2C${mlon}`); return; }
|
||||
if (r.mapsFrontend == 'facil') { resolve(`${randomInstance}/#q=${mlat}%2C${mlon}`); return; }
|
||||
} else if (url.searchParams.has("viewpoint")) { // Get marker from viewpoint param.
|
||||
// https://www.google.com/maps/@?api=1&map_action=pano&viewpoint=48.857832,2.295226&heading=-45&pitch=38&fov=80
|
||||
console.log("viewpoint life");
|
||||
|
||||
const [mlat, mlon] = url.searchParams.get("viewpoint").split(",");
|
||||
|
||||
if (r.mapsFrontend == 'osm') { resolve(`${randomInstance}/search?query=${mlat}%2C${mlon}`); return; }
|
||||
if (r.mapsFrontend == 'facil') { resolve(`${randomInstance}/#q=${mlat}%2C${mlon}`); return; }
|
||||
} else { // Use query as search if present.
|
||||
console.log("normal life");
|
||||
|
||||
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];
|
||||
|
||||
let prefsEncoded = new URLSearchParams(prefs).toString();
|
||||
if (query) {
|
||||
if (r.mapsFrontend == 'osm') { resolve(`${randomInstance}/search?query="${query}${mapCentre}&${prefsEncoded}`); return; }
|
||||
if (r.mapsFrontend == 'facil') { resolve(`${randomInstance}/${mapCentre}/Mpnk/${query}`); return; }
|
||||
}
|
||||
} else
|
||||
console.info("Error: Status is " + xmlhttp.status);
|
||||
}
|
||||
|
||||
let prefsEncoded = new URLSearchParams(prefs).toString();
|
||||
console.log("mapCentre", mapCentre);
|
||||
console.log("prefs", prefs);
|
||||
console.log("prefsEncoded", prefsEncoded);
|
||||
if (r.mapsFrontend == 'osm') { resolve(`${randomInstance}/${mapCentre}&${prefsEncoded}`); return; }
|
||||
if (r.mapsFrontend == 'facil') { resolve(`${randomInstance}/${mapCentre}/Mpnk`); return; }
|
||||
}
|
||||
};
|
||||
xmlhttp.open(
|
||||
"GET",
|
||||
`https://nominatim.openstreetmap.org/search/${address}?format=json&limit=1`,
|
||||
true
|
||||
);
|
||||
xmlhttp.send();
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
if (disable) return;
|
||||
if (initiator && initiator.host === "earth.google.com") return;
|
||||
if (!url.href.match(targets)) return;
|
||||
|
||||
let randomInstance;
|
||||
if (frontend == 'osm') randomInstance = utils.getRandomInstance(redirects.osm.normal);
|
||||
if (frontend == 'facil') randomInstance = utils.getRandomInstance([...facilNormalRedirectsChecks, ...facilNormalCustomRedirects]);
|
||||
|
||||
let mapCentre = "#";
|
||||
let prefs = {};
|
||||
|
||||
if (url.pathname.match(mapCentreRegex)) { // Set map centre if present
|
||||
var [, lat, lon, zoom] = url.pathname.match(mapCentreRegex);
|
||||
} else if (url.searchParams.has("center")) {
|
||||
var [lat, lon] = url.searchParams.get("center").split(",");
|
||||
var zoom = url.searchParams.get("zoom") ?? "17";
|
||||
}
|
||||
|
||||
if (lat && lon && zoom) {
|
||||
if (frontend == 'osm') mapCentre = `#map=${zoom}/${lat}/${lon}`;
|
||||
if (frontend == 'facil') mapCentre = `#${zoom}/${lat}/${lon}`;
|
||||
}
|
||||
|
||||
if (url.searchParams.get("layer")) prefs.layers = osmLayers[url.searchParams.get("layer")];
|
||||
|
||||
if (url.pathname.includes("/embed")) { // Handle Google Maps Embed API
|
||||
// https://www.google.com/maps/embed/v1/place?key=AIzaSyD4iE2xVSpkLLOXoyqT-RuPwURN3ddScAI&q=Eiffel+Tower,Paris+France
|
||||
console.log("embed life");
|
||||
|
||||
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 [coords, boundingbox] = await addressToLatLng(query);
|
||||
prefs.bbox = boundingbox;
|
||||
prefs.marker = coords;
|
||||
prefs.layer = "mapnik";
|
||||
let prefsEncoded = new URLSearchParams(prefs).toString();
|
||||
if (frontend == 'osm') return `${randomInstance}/export/embed.html?${prefsEncoded}`;
|
||||
|
||||
if (frontend == 'facil') return `${randomInstance}/#q=${query}`;
|
||||
|
||||
} else if (url.pathname.includes("/dir")) { // Handle Google Maps Directions
|
||||
// https://www.google.com/maps/dir/?api=1&origin=Space+Needle+Seattle+WA&destination=Pike+Place+Market+Seattle+WA&travelmode=bicycling
|
||||
|
||||
let travMod = url.searchParams.get("travelmode");
|
||||
if (url.searchParams.has("travelmode")) prefs.engine = travelModes[travMod];
|
||||
|
||||
let orgVal = url.searchParams.get("origin");
|
||||
let destVal = url.searchParams.get("destination");
|
||||
|
||||
let org; addressToLatLng(orgVal, a => org = a);
|
||||
let dest; addressToLatLng(destVal, a => dest = a);
|
||||
prefs.route = `${org};${dest}`;
|
||||
|
||||
let prefsEncoded = new URLSearchParams(prefs).toString();
|
||||
if (frontend == 'osm') return `${randomInstance}/directions?${prefsEncoded}${mapCentre}`;
|
||||
if (frontend == 'facil') return `${randomInstance}/#q=${orgVal}%20to%20${destVal}%20by%20${travelModesFacil[travMod]}`;
|
||||
|
||||
} else if (url.pathname.includes("data=") && url.pathname.match(dataLatLngRegex)) { // Get marker from data attribute
|
||||
// https://www.google.com/maps/place/41%C2%B001'58.2%22N+40%C2%B029'18.2%22E/@41.032833,40.4862063,17z/data=!3m1!4b1!4m6!3m5!1s0x0:0xf64286eaf72fc49d!7e2!8m2!3d41.0328329!4d40.4883948
|
||||
console.log("data life");
|
||||
|
||||
let [, mlat, mlon] = url.pathname.match(dataLatLngRegex);
|
||||
|
||||
if (frontend == 'osm') return `${randomInstance}/search?query=${mlat}%2C${mlon}`;
|
||||
if (frontend == 'facil') return `${randomInstance}/#q=${mlat}%2C${mlon}`;
|
||||
|
||||
} else if (url.searchParams.has("ll")) { // Get marker from ll param
|
||||
// https://maps.google.com/?ll=38.882147,-76.99017
|
||||
console.log("ll life");
|
||||
|
||||
const [mlat, mlon] = url.searchParams.get("ll").split(",");
|
||||
|
||||
if (frontend == 'osm') return `${randomInstance}/search?query=${mlat}%2C${mlon}`;
|
||||
if (frontend == 'facil') return `${randomInstance}/#q=${mlat}%2C${mlon}`;
|
||||
} else if (url.searchParams.has("viewpoint")) { // Get marker from viewpoint param.
|
||||
// https://www.google.com/maps/@?api=1&map_action=pano&viewpoint=48.857832,2.295226&heading=-45&pitch=38&fov=80
|
||||
console.log("viewpoint life");
|
||||
|
||||
const [mlat, mlon] = url.searchParams.get("viewpoint").split(",");
|
||||
|
||||
if (frontend == 'osm') return `${randomInstance}/search?query=${mlat}%2C${mlon}`;
|
||||
if (frontend == 'facil') return `${randomInstance}/#q=${mlat}%2C${mlon}`;
|
||||
} else { // Use query as search if present.
|
||||
console.log("normal life");
|
||||
|
||||
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];
|
||||
|
||||
let prefsEncoded = new URLSearchParams(prefs).toString();
|
||||
if (query) {
|
||||
if (frontend == 'osm') return `${randomInstance}/search?query="${query}${mapCentre}&${prefsEncoded}`;
|
||||
if (frontend == 'facil') return `${randomInstance}/${mapCentre}/Mpnk/${query}`
|
||||
}
|
||||
}
|
||||
|
||||
let prefsEncoded = new URLSearchParams(prefs).toString();
|
||||
console.log("mapCentre", mapCentre);
|
||||
console.log("prefs", prefs);
|
||||
console.log("prefsEncoded", prefsEncoded);
|
||||
if (frontend == 'osm') return `${randomInstance}/${mapCentre}&${prefsEncoded}`
|
||||
if (frontend == 'facil') return `${randomInstance}/${mapCentre}/Mpnk`
|
||||
}
|
||||
|
||||
async function initDefaults() {
|
||||
@ -198,32 +206,7 @@ async function initDefaults() {
|
||||
})
|
||||
}
|
||||
|
||||
async function init() {
|
||||
return new Promise(
|
||||
resolve => {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"disableMaps",
|
||||
"mapsFrontend",
|
||||
|
||||
"facilNormalRedirectsChecks",
|
||||
"facilNormalCustomRedirects",
|
||||
],
|
||||
r => {
|
||||
disable = r.disableMaps;
|
||||
frontend = r.mapsFrontend;
|
||||
|
||||
facilNormalRedirectsChecks = r.facilNormalRedirectsChecks;
|
||||
facilNormalCustomRedirects = r.facilNormalCustomRedirects;
|
||||
|
||||
resolve();
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
export default {
|
||||
redirect,
|
||||
init,
|
||||
initDefaults,
|
||||
};
|
||||
|
@ -35,25 +35,18 @@ let redirects = {
|
||||
}
|
||||
};
|
||||
function setRedirects(val) {
|
||||
redirects.scribe = val;
|
||||
browser.storage.local.set({ mediumRedirects: redirects })
|
||||
for (const item of scribeNormalRedirectsChecks) if (!redirects.scribe.normal.includes(item)) {
|
||||
var index = scribeNormalRedirectsChecks.indexOf(item);
|
||||
if (index !== -1) scribeNormalRedirectsChecks.splice(index, 1);
|
||||
}
|
||||
browser.storage.local.set({ scribeNormalRedirectsChecks })
|
||||
|
||||
for (const item of scribeNormalRedirectsChecks) if (!redirects.scribe.normal.includes(item)) {
|
||||
var index = scribeNormalRedirectsChecks.indexOf(item);
|
||||
if (index !== -1) scribeNormalRedirectsChecks.splice(index, 1);
|
||||
}
|
||||
browser.storage.local.set({ scribeNormalRedirectsChecks })
|
||||
|
||||
for (const item of scribeTorRedirectsChecks) if (!redirects.scribe.normal.includes(item)) {
|
||||
var index = scribeTorRedirectsChecks.indexOf(item);
|
||||
if (index !== -1) scribeTorRedirectsChecks.splice(index, 1);
|
||||
}
|
||||
browser.storage.local.set({ scribeTorRedirectsChecks })
|
||||
browser.storage.local.get('cloudflareList', r => {
|
||||
redirects.scribe = val;
|
||||
scribeNormalRedirectsChecks = [...redirects.scribe.normal];
|
||||
for (const instance of r.cloudflareList) {
|
||||
const a = scribeNormalRedirectsChecks.indexOf(instance);
|
||||
if (a > -1) scribeNormalRedirectsChecks.splice(a, 1);
|
||||
}
|
||||
browser.storage.local.set({
|
||||
mediumRedirects: redirects,
|
||||
scribeNormalRedirectsChecks
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
let scribeNormalRedirectsChecks;
|
||||
@ -133,27 +126,31 @@ function switchInstance(url) {
|
||||
}
|
||||
|
||||
function initDefaults() {
|
||||
fetch('/instances/data.json').then(response => response.text()).then(data => {
|
||||
let dataJson = JSON.parse(data);
|
||||
redirects.scribe = dataJson.scribe;
|
||||
browser.storage.local.get('cloudflareList', r => {
|
||||
scribeNormalRedirectsChecks = [...redirects.scribe.normal];
|
||||
for (const instance of r.cloudflareList) {
|
||||
let i = scribeNormalRedirectsChecks.indexOf(instance);
|
||||
if (i > -1) scribeNormalRedirectsChecks.splice(i, 1);
|
||||
}
|
||||
browser.storage.local.set({
|
||||
disableMedium: false,
|
||||
mediumRedirects: redirects,
|
||||
return new Promise(resolve => {
|
||||
fetch('/instances/data.json').then(response => response.text()).then(data => {
|
||||
let dataJson = JSON.parse(data);
|
||||
redirects.scribe = dataJson.scribe;
|
||||
browser.storage.local.get('cloudflareList',
|
||||
async r => {
|
||||
scribeNormalRedirectsChecks = [...redirects.scribe.normal];
|
||||
for (const instance of r.cloudflareList) {
|
||||
let i = scribeNormalRedirectsChecks.indexOf(instance);
|
||||
if (i > -1) scribeNormalRedirectsChecks.splice(i, 1);
|
||||
}
|
||||
await browser.storage.local.set({
|
||||
disableMedium: false,
|
||||
mediumRedirects: redirects,
|
||||
|
||||
scribeNormalRedirectsChecks: scribeNormalRedirectsChecks,
|
||||
scribeNormalCustomRedirects: [],
|
||||
scribeNormalRedirectsChecks: scribeNormalRedirectsChecks,
|
||||
scribeNormalCustomRedirects: [],
|
||||
|
||||
scribeTorRedirectsChecks: [...redirects.scribe.tor],
|
||||
scribeTorCustomRedirects: [],
|
||||
scribeTorRedirectsChecks: [...redirects.scribe.tor],
|
||||
scribeTorCustomRedirects: [],
|
||||
|
||||
mediumProtocol: "normal",
|
||||
})
|
||||
mediumProtocol: "normal",
|
||||
})
|
||||
resolve();
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
@ -2,8 +2,6 @@ window.browser = window.browser || window.chrome;
|
||||
|
||||
import utils from './utils.js'
|
||||
|
||||
let targets = [];
|
||||
|
||||
let redirects = {
|
||||
"simpleertube": {
|
||||
"normal": [
|
||||
@ -19,7 +17,6 @@ let redirects = {
|
||||
function setRedirects(val) {
|
||||
redirects.simpleertube = val;
|
||||
browser.storage.local.set({ peertubeTargetsRedirects: redirects })
|
||||
console.log("peertubeTargetsRedirects: ", val)
|
||||
for (const item of simpleertubeNormalRedirectsChecks)
|
||||
if (!redirects.simpleertube.normal.includes(item)) {
|
||||
var index = simpleertubeNormalRedirectsChecks.indexOf(item);
|
||||
@ -34,15 +31,10 @@ function setRedirects(val) {
|
||||
}
|
||||
browser.storage.local.set({ simpleertubeTorRedirectsChecks })
|
||||
}
|
||||
let
|
||||
simpleertubeNormalRedirectsChecks,
|
||||
simpleertubeTorRedirectsChecks;
|
||||
|
||||
let simpleertubeNormalRedirectsChecks;
|
||||
let simpleertubeTorRedirectsChecks;
|
||||
|
||||
let simpleertubeNormalCustomRedirects = [];
|
||||
let simpleertubeTorCustomRedirects = [];
|
||||
|
||||
let disable;
|
||||
let protocol;
|
||||
|
||||
async function switchInstance(url) {
|
||||
return new Promise(resolve => {
|
||||
@ -82,92 +74,82 @@ async function switchInstance(url) {
|
||||
}
|
||||
|
||||
function redirect(url, type, initiator) {
|
||||
if (disable) return null;
|
||||
if (
|
||||
initiator &&
|
||||
(
|
||||
return new Promise(resolve => {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
...redirects.simpleertube.normal,
|
||||
...simpleertubeNormalCustomRedirects
|
||||
].includes(initiator.origin) ||
|
||||
targets.includes(initiator.host)
|
||||
)
|
||||
) return null;
|
||||
let protocolHost = utils.protocolHost(url);
|
||||
if (!targets.includes(protocolHost)) return null;
|
||||
"disablePeertubeTargets",
|
||||
|
||||
if (type != "main_frame") return null;
|
||||
"peertubeRedirects",
|
||||
|
||||
let instancesList;
|
||||
if (protocol == 'normal') instancesList = [...simpleertubeNormalRedirectsChecks, ...simpleertubeNormalCustomRedirects];
|
||||
if (protocol == 'tor') instancesList = [...simpleertubeTorRedirectsChecks, ...simpleertubeTorCustomRedirects];
|
||||
if (instancesList.length === 0) return null;
|
||||
let randomInstance = utils.getRandomInstance(instancesList);
|
||||
"simpleertubeNormalRedirectsChecks",
|
||||
"simpleertubeNormalCustomRedirects",
|
||||
|
||||
if (url.host == 'search.joinpeertube.org') return randomInstance;
|
||||
"simpleertubeTorRedirectsChecks",
|
||||
"simpleertubeTorCustomRedirects",
|
||||
|
||||
return `${randomInstance}/${url.host}${url.pathname}${url.search}`;
|
||||
}
|
||||
"peerTubeTargets",
|
||||
"peertubeTargetsProtocol"
|
||||
],
|
||||
r => {
|
||||
if (r.disablePeertubeTargets) { resolve(); return; }
|
||||
if (
|
||||
initiator &&
|
||||
(
|
||||
[
|
||||
...r.peertubeRedirects.simpleertube.normal,
|
||||
...r.simpleertubeNormalCustomRedirects
|
||||
].includes(initiator.origin) ||
|
||||
r.peerTubeTargets.includes(initiator.host)
|
||||
)
|
||||
) { resolve(); return; }
|
||||
let protocolHost = utils.protocolHost(url);
|
||||
if (!r.peerTubeTargets.includes(protocolHost)) { resolve(); return; }
|
||||
if (type != "main_frame") { resolve(); return; }
|
||||
|
||||
async function initDefaults() {
|
||||
fetch('/instances/data.json').then(response => response.text()).then(async data => {
|
||||
let dataJson = JSON.parse(data);
|
||||
browser.storage.local.get('cloudflareList', async r => {
|
||||
simpleertubeNormalRedirectsChecks = [...redirects.simpleertube.normal];
|
||||
for (const instance of r.cloudflareList) {
|
||||
let i = simpleertubeNormalRedirectsChecks.indexOf(instance);
|
||||
if (i > -1) simpleertubeNormalRedirectsChecks.splice(i, 1);
|
||||
let instancesList;
|
||||
if (r.peertubeTargetsProtocol == 'normal') instancesList = [...r.simpleertubeNormalRedirectsChecks, ...r.simpleertubeNormalCustomRedirects];
|
||||
if (r.peertubeTargetsProtocol == 'tor') instancesList = [...r.simpleertubeTorRedirectsChecks, ...r.simpleertubeTorCustomRedirects];
|
||||
if (instancesList.length === 0) { resolve(); return; }
|
||||
let randomInstance = utils.getRandomInstance(instancesList);
|
||||
if (url.host == 'search.joinpeertube.org') { resolve(randomInstance); return; }
|
||||
|
||||
resolve(`${randomInstance}/${url.host}${url.pathname}${url.search}`);
|
||||
}
|
||||
await browser.storage.local.set({
|
||||
peerTubeTargets: ['https://search.joinpeertube.org', ...dataJson.peertube],
|
||||
disablePeertubeTargets: true,
|
||||
peertubeRedirects: redirects,
|
||||
)
|
||||
})
|
||||
}
|
||||
async function initDefaults() {
|
||||
return new Promise(resolve => {
|
||||
fetch('/instances/data.json').then(response => response.text()).then(async data => {
|
||||
let dataJson = JSON.parse(data);
|
||||
browser.storage.local.get('cloudflareList', async r => {
|
||||
simpleertubeNormalRedirectsChecks = [...redirects.simpleertube.normal];
|
||||
for (const instance of r.cloudflareList) {
|
||||
let i = simpleertubeNormalRedirectsChecks.indexOf(instance);
|
||||
if (i > -1) simpleertubeNormalRedirectsChecks.splice(i, 1);
|
||||
}
|
||||
await browser.storage.local.set({
|
||||
peerTubeTargets: ['https://search.joinpeertube.org', ...dataJson.peertube],
|
||||
disablePeertubeTargets: true,
|
||||
peertubeRedirects: redirects,
|
||||
|
||||
simpleertubeNormalRedirectsChecks: simpleertubeNormalRedirectsChecks,
|
||||
simpleertubeNormalCustomRedirects: [],
|
||||
simpleertubeNormalRedirectsChecks: simpleertubeNormalRedirectsChecks,
|
||||
simpleertubeNormalCustomRedirects: [],
|
||||
|
||||
simpleertubeTorRedirectsChecks: [...redirects.simpleertube.tor],
|
||||
simpleertubeTorCustomRedirects: [],
|
||||
simpleertubeTorRedirectsChecks: [...redirects.simpleertube.tor],
|
||||
simpleertubeTorCustomRedirects: [],
|
||||
|
||||
peertubeTargetsProtocol: "normal",
|
||||
peertubeTargetsProtocol: "normal",
|
||||
})
|
||||
resolve();
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
async function init() {
|
||||
await browser.storage.local.get(
|
||||
[
|
||||
"disablePeertubeTargets",
|
||||
"simpleertubeNormalRedirectsChecks",
|
||||
"simpleertubeNormalCustomRedirects",
|
||||
|
||||
"simpleertubeTorRedirectsChecks",
|
||||
"simpleertubeTorCustomRedirects",
|
||||
|
||||
"peerTubeTargets",
|
||||
"peertubeTargetsProtocol"
|
||||
],
|
||||
r => {
|
||||
disable = r.disablePeertubeTargets;
|
||||
protocol = r.peertubeTargetsProtocol;
|
||||
targets = r.peerTubeTargets;
|
||||
|
||||
simpleertubeNormalRedirectsChecks = r.simpleertubeNormalRedirectsChecks;
|
||||
simpleertubeNormalCustomRedirects = r.simpleertubeNormalCustomRedirects;
|
||||
|
||||
simpleertubeTorRedirectsChecks = r.simpleertubeTorRedirectsChecks;
|
||||
simpleertubeTorCustomRedirects = r.simpleertubeTorCustomRedirects;
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
export default {
|
||||
setRedirects,
|
||||
|
||||
switchInstance,
|
||||
|
||||
redirect,
|
||||
initDefaults,
|
||||
init,
|
||||
};
|
||||
|
@ -16,50 +16,29 @@ let redirects = {
|
||||
"tor": []
|
||||
},
|
||||
};
|
||||
function setLibredditRedirects(val) {
|
||||
redirects.libreddit = val;
|
||||
browser.storage.local.set({ redditRedirects: redirects })
|
||||
console.log("libredditRedirects:", val)
|
||||
for (const item of libredditNormalRedirectsChecks)
|
||||
if (!redirects.libreddit.normal.includes(item)) {
|
||||
var index = libredditNormalRedirectsChecks.indexOf(item);
|
||||
if (index !== -1) libredditNormalRedirectsChecks.splice(index, 1);
|
||||
}
|
||||
browser.storage.local.set({ libredditNormalRedirectsChecks })
|
||||
function setRedirects(val) {
|
||||
browser.storage.local.get('cloudflareList', r => {
|
||||
redirects = val;
|
||||
libredditNormalRedirectsChecks = [...redirects.libreddit.normal];
|
||||
tedditNormalRedirectsChecks = [...redirects.teddit.normal]
|
||||
for (const instance of r.cloudflareList) {
|
||||
const a = libredditNormalRedirectsChecks.indexOf(instance);
|
||||
if (a > -1) libredditNormalRedirectsChecks.splice(a, 1);
|
||||
|
||||
for (const item of libredditTorRedirectsChecks)
|
||||
if (!redirects.libreddit.normal.includes(item)) {
|
||||
var index = libredditTorRedirectsChecks.indexOf(item);
|
||||
if (index !== -1) libredditTorRedirectsChecks.splice(index, 1);
|
||||
const b = tedditNormalRedirectsChecks.indexOf(instance);
|
||||
if (b > -1) tedditNormalRedirectsChecks.splice(b, 1);
|
||||
}
|
||||
browser.storage.local.set({ libredditTorRedirectsChecks })
|
||||
}
|
||||
|
||||
function setTedditRedirects(val) {
|
||||
redirects.teddit = val;
|
||||
browser.storage.local.set({ redditRedirects: redirects })
|
||||
console.log("tedditRedirects:", val)
|
||||
for (const item of tedditNormalRedirectsChecks)
|
||||
if (!redirects.teddit.normal.includes(item)) {
|
||||
var index = tedditNormalRedirectsChecks.indexOf(item);
|
||||
if (index !== -1) tedditNormalRedirectsChecks.splice(index, 1);
|
||||
}
|
||||
browser.storage.local.set({ tedditNormalRedirectsChecks })
|
||||
|
||||
for (const item of tedditTorRedirectsChecks)
|
||||
if (!redirects.teddit.normal.includes(item)) {
|
||||
var index = tedditTorRedirectsChecks.indexOf(item);
|
||||
if (index !== -1) tedditTorRedirectsChecks.splice(index, 1);
|
||||
}
|
||||
browser.storage.local.set({ tedditTorRedirectsChecks })
|
||||
browser.storage.local.set({
|
||||
redditRedirects: redirects,
|
||||
libredditNormalRedirectsChecks,
|
||||
tedditNormalRedirectsChecks
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
let
|
||||
libredditNormalRedirectsChecks,
|
||||
libredditTorRedirectsChecks,
|
||||
|
||||
tedditNormalRedirectsChecks,
|
||||
tedditTorRedirectsChecks;
|
||||
tedditNormalRedirectsChecks;
|
||||
|
||||
function initLibredditCookies(test, from) {
|
||||
return new Promise(resolve => {
|
||||
@ -105,35 +84,38 @@ function initLibredditCookies(test, from) {
|
||||
}
|
||||
|
||||
function setLibredditCookies() {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"redditProtocol",
|
||||
"disableReddit",
|
||||
"redditFrontend",
|
||||
"libredditNormalRedirectsChecks",
|
||||
"libredditNormalCustomRedirects",
|
||||
"libredditTorRedirectsChecks",
|
||||
"libredditTorCustomRedirects",
|
||||
],
|
||||
r => {
|
||||
if (r.disableReddit || r.redditFrontend != 'libreddit' || r.redditProtocol === undefined) return;
|
||||
let checkedInstances;
|
||||
if (r.redditProtocol == 'normal') checkedInstances = [...r.libredditNormalRedirectsChecks, ...r.libredditNormalCustomRedirects]
|
||||
else if (r.redditProtocol == 'tor') checkedInstances = [...r.libredditTorRedirectsChecks, ...r.libredditTorCustomRedirects]
|
||||
for (const to of checkedInstances) {
|
||||
utils.getCookiesFromStorage('libreddit', to, "theme");
|
||||
utils.getCookiesFromStorage('libreddit', to, "front_page");
|
||||
utils.getCookiesFromStorage('libreddit', to, "layout");
|
||||
utils.getCookiesFromStorage('libreddit', to, "wide");
|
||||
utils.getCookiesFromStorage('libreddit', to, "post_sort");
|
||||
utils.getCookiesFromStorage('libreddit', to, "comment_sort");
|
||||
utils.getCookiesFromStorage('libreddit', to, "show_nsfw");
|
||||
utils.getCookiesFromStorage('libreddit', to, "autoplay_videos");
|
||||
utils.getCookiesFromStorage('libreddit', to, "use_hls");
|
||||
utils.getCookiesFromStorage('libreddit', to, "hide_hls_notification");
|
||||
return new Promise(resolve => {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"redditProtocol",
|
||||
"disableReddit",
|
||||
"redditFrontend",
|
||||
"libredditNormalRedirectsChecks",
|
||||
"libredditNormalCustomRedirects",
|
||||
"libredditTorRedirectsChecks",
|
||||
"libredditTorCustomRedirects",
|
||||
],
|
||||
r => {
|
||||
if (r.disableReddit || r.redditFrontend != 'libreddit' || r.redditProtocol === undefined) { resolve(); return; }
|
||||
let checkedInstances;
|
||||
if (r.redditProtocol == 'normal') checkedInstances = [...r.libredditNormalRedirectsChecks, ...r.libredditNormalCustomRedirects]
|
||||
else if (r.redditProtocol == 'tor') checkedInstances = [...r.libredditTorRedirectsChecks, ...r.libredditTorCustomRedirects]
|
||||
for (const to of checkedInstances) {
|
||||
utils.getCookiesFromStorage('libreddit', to, "theme");
|
||||
utils.getCookiesFromStorage('libreddit', to, "front_page");
|
||||
utils.getCookiesFromStorage('libreddit', to, "layout");
|
||||
utils.getCookiesFromStorage('libreddit', to, "wide");
|
||||
utils.getCookiesFromStorage('libreddit', to, "post_sort");
|
||||
utils.getCookiesFromStorage('libreddit', to, "comment_sort");
|
||||
utils.getCookiesFromStorage('libreddit', to, "show_nsfw");
|
||||
utils.getCookiesFromStorage('libreddit', to, "autoplay_videos");
|
||||
utils.getCookiesFromStorage('libreddit', to, "use_hls");
|
||||
utils.getCookiesFromStorage('libreddit', to, "hide_hls_notification");
|
||||
}
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
function initTedditCookies(test, from) {
|
||||
@ -181,37 +163,40 @@ function initTedditCookies(test, from) {
|
||||
}
|
||||
|
||||
function setTedditCookies() {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"redditProtocol",
|
||||
"disableReddit",
|
||||
"redditFrontend",
|
||||
"tedditNormalRedirectsChecks",
|
||||
"tedditNormalCustomRedirects",
|
||||
"tedditTorRedirectsChecks",
|
||||
"tedditTorCustomRedirects",
|
||||
],
|
||||
r => {
|
||||
if (r.disableReddit || r.redditFrontend != 'teddit' || r.redditProtocol === undefined) return;
|
||||
let checkedInstances;
|
||||
if (r.redditProtocol == 'normal') checkedInstances = [...r.tedditNormalRedirectsChecks, ...r.tedditNormalCustomRedirects]
|
||||
else if (r.redditProtocol == 'tor') checkedInstances = [...r.tedditTorRedirectsChecks, ...r.tedditTorCustomRedirects]
|
||||
for (const to of checkedInstances) {
|
||||
utils.getCookiesFromStorage('teddit', to, 'collapse_child_comments')
|
||||
utils.getCookiesFromStorage('teddit', to, 'domain_instagram')
|
||||
utils.getCookiesFromStorage('teddit', to, 'domain_twitter')
|
||||
utils.getCookiesFromStorage('teddit', to, 'domain_youtube')
|
||||
utils.getCookiesFromStorage('teddit', to, 'flairs')
|
||||
utils.getCookiesFromStorage('teddit', to, 'highlight_controversial')
|
||||
utils.getCookiesFromStorage('teddit', to, 'nsfw_enabled')
|
||||
utils.getCookiesFromStorage('teddit', to, 'post_media_max_height')
|
||||
utils.getCookiesFromStorage('teddit', to, 'show_upvoted_percentage')
|
||||
utils.getCookiesFromStorage('teddit', to, 'show_upvotes')
|
||||
utils.getCookiesFromStorage('teddit', to, 'theme')
|
||||
utils.getCookiesFromStorage('teddit', to, 'videos_muted')
|
||||
return new Promise(resolve => {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"redditProtocol",
|
||||
"disableReddit",
|
||||
"redditFrontend",
|
||||
"tedditNormalRedirectsChecks",
|
||||
"tedditNormalCustomRedirects",
|
||||
"tedditTorRedirectsChecks",
|
||||
"tedditTorCustomRedirects",
|
||||
],
|
||||
r => {
|
||||
if (r.disableReddit || r.redditFrontend != 'teddit' || r.redditProtocol === undefined) { resolve(); return; }
|
||||
let checkedInstances;
|
||||
if (r.redditProtocol == 'normal') checkedInstances = [...r.tedditNormalRedirectsChecks, ...r.tedditNormalCustomRedirects]
|
||||
else if (r.redditProtocol == 'tor') checkedInstances = [...r.tedditTorRedirectsChecks, ...r.tedditTorCustomRedirects]
|
||||
for (const to of checkedInstances) {
|
||||
utils.getCookiesFromStorage('teddit', to, 'collapse_child_comments')
|
||||
utils.getCookiesFromStorage('teddit', to, 'domain_instagram')
|
||||
utils.getCookiesFromStorage('teddit', to, 'domain_twitter')
|
||||
utils.getCookiesFromStorage('teddit', to, 'domain_youtube')
|
||||
utils.getCookiesFromStorage('teddit', to, 'flairs')
|
||||
utils.getCookiesFromStorage('teddit', to, 'highlight_controversial')
|
||||
utils.getCookiesFromStorage('teddit', to, 'nsfw_enabled')
|
||||
utils.getCookiesFromStorage('teddit', to, 'post_media_max_height')
|
||||
utils.getCookiesFromStorage('teddit', to, 'show_upvoted_percentage')
|
||||
utils.getCookiesFromStorage('teddit', to, 'show_upvotes')
|
||||
utils.getCookiesFromStorage('teddit', to, 'theme')
|
||||
utils.getCookiesFromStorage('teddit', to, 'videos_muted')
|
||||
}
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
function redirect(url, type, initiator) {
|
||||
@ -403,48 +388,49 @@ function switchInstance(url) {
|
||||
}
|
||||
|
||||
function initDefaults() {
|
||||
fetch('/instances/data.json').then(response => response.text()).then(async data => {
|
||||
let dataJson = JSON.parse(data);
|
||||
redirects.teddit = dataJson.teddit;
|
||||
redirects.libreddit = dataJson.libreddit;
|
||||
browser.storage.local.get('cloudflareList', async r => {
|
||||
libredditNormalRedirectsChecks = [...redirects.libreddit.normal];
|
||||
tedditNormalRedirectsChecks = [...redirects.teddit.normal]
|
||||
for (const instance of r.cloudflareList) {
|
||||
let i;
|
||||
return new Promise(resolve => {
|
||||
fetch('/instances/data.json').then(response => response.text()).then(async data => {
|
||||
let dataJson = JSON.parse(data);
|
||||
redirects.teddit = dataJson.teddit;
|
||||
redirects.libreddit = dataJson.libreddit;
|
||||
browser.storage.local.get('cloudflareList', async r => {
|
||||
libredditNormalRedirectsChecks = [...redirects.libreddit.normal];
|
||||
tedditNormalRedirectsChecks = [...redirects.teddit.normal]
|
||||
for (const instance of r.cloudflareList) {
|
||||
let i;
|
||||
|
||||
i = libredditNormalRedirectsChecks.indexOf(instance);
|
||||
if (i > -1) libredditNormalRedirectsChecks.splice(i, 1);
|
||||
i = libredditNormalRedirectsChecks.indexOf(instance);
|
||||
if (i > -1) libredditNormalRedirectsChecks.splice(i, 1);
|
||||
|
||||
i = tedditNormalRedirectsChecks.indexOf(instance);
|
||||
if (i > -1) tedditNormalRedirectsChecks.splice(i, 1);
|
||||
}
|
||||
await browser.storage.local.set({
|
||||
disableReddit: false,
|
||||
redditProtocol: 'normal',
|
||||
redditFrontend: 'libreddit',
|
||||
redditRedirects: redirects,
|
||||
i = tedditNormalRedirectsChecks.indexOf(instance);
|
||||
if (i > -1) tedditNormalRedirectsChecks.splice(i, 1);
|
||||
}
|
||||
await browser.storage.local.set({
|
||||
disableReddit: false,
|
||||
redditProtocol: 'normal',
|
||||
redditFrontend: 'libreddit',
|
||||
redditRedirects: redirects,
|
||||
|
||||
libredditNormalRedirectsChecks: libredditNormalRedirectsChecks,
|
||||
libredditNormalCustomRedirects: [],
|
||||
libredditNormalRedirectsChecks: libredditNormalRedirectsChecks,
|
||||
libredditNormalCustomRedirects: [],
|
||||
|
||||
libredditTorRedirectsChecks: [...redirects.libreddit.tor],
|
||||
libredditTorCustomRedirects: [],
|
||||
libredditTorRedirectsChecks: [...redirects.libreddit.tor],
|
||||
libredditTorCustomRedirects: [],
|
||||
|
||||
tedditNormalRedirectsChecks: tedditNormalRedirectsChecks,
|
||||
tedditNormalCustomRedirects: [],
|
||||
tedditNormalRedirectsChecks: tedditNormalRedirectsChecks,
|
||||
tedditNormalCustomRedirects: [],
|
||||
|
||||
tedditTorRedirectsChecks: [...redirects.teddit.tor],
|
||||
tedditTorCustomRedirects: [],
|
||||
tedditTorRedirectsChecks: [...redirects.teddit.tor],
|
||||
tedditTorCustomRedirects: [],
|
||||
});
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export default {
|
||||
setTedditRedirects,
|
||||
setLibredditRedirects,
|
||||
|
||||
setRedirects,
|
||||
initLibredditCookies,
|
||||
setLibredditCookies,
|
||||
initTedditCookies,
|
||||
|
@ -8,7 +8,7 @@ const targets = [
|
||||
|
||||
/^https?:\/{2}yandex(\.[a-z]{2,3}){1,2}/,
|
||||
|
||||
/^https?:\/{2}libredirect\.invalid/,
|
||||
/^https?:\/{2}search\.libredirect\.invalid/,
|
||||
];
|
||||
let redirects = {
|
||||
"searx": {
|
||||
@ -28,87 +28,35 @@ let redirects = {
|
||||
}
|
||||
};
|
||||
|
||||
function setSearxRedirects(val) {
|
||||
redirects.searx = val;
|
||||
browser.storage.local.set({ searchRedirects: redirects })
|
||||
console.log("searxRedirects:", val)
|
||||
for (const item of searxNormalRedirectsChecks) if (!redirects.searx.normal.includes(item)) {
|
||||
var index = searxNormalRedirectsChecks.indexOf(item);
|
||||
if (index !== -1) searxNormalRedirectsChecks.splice(index, 1);
|
||||
}
|
||||
browser.storage.local.set({ searxNormalRedirectsChecks });
|
||||
function setRedirects(val) {
|
||||
browser.storage.local.get('cloudflareList', r => {
|
||||
redirects = val;
|
||||
searxNormalRedirectsChecks = [...redirects.searx.normal];
|
||||
searxngNormalRedirectsChecks = [...redirects.searxng.normal];
|
||||
whoogleNormalRedirectsChecks = [...redirects.whoogle.normal];
|
||||
for (const instance of r.cloudflareList) {
|
||||
const a = searxNormalRedirectsChecks.indexOf(instance);
|
||||
if (a > -1) searxNormalRedirectsChecks.splice(a, 1);
|
||||
|
||||
for (const item of searxTorRedirectsChecks) if (!redirects.searx.tor.includes(item)) {
|
||||
var index = searxTorRedirectsChecks.indexOf(item);
|
||||
if (index !== -1) searxTorRedirectsChecks.splice(index, 1);
|
||||
}
|
||||
browser.storage.local.set({ searxTorRedirectsChecks })
|
||||
const b = searxngNormalRedirectsChecks.indexOf(instance);
|
||||
if (b > -1) searxngNormalRedirectsChecks.splice(b, 1);
|
||||
|
||||
for (const item of searxI2pRedirectsChecks) if (!redirects.searx.i2p.includes(item)) {
|
||||
var index = searxI2pRedirectsChecks.indexOf(item);
|
||||
if (index !== -1) searxI2pRedirectsChecks.splice(index, 1);
|
||||
}
|
||||
browser.storage.local.set({ searxI2pRedirectsChecks });
|
||||
}
|
||||
|
||||
function setSearxngRedirects(val) {
|
||||
redirects.searxng = val;
|
||||
browser.storage.local.set({ searchRedirects: redirects })
|
||||
console.log("searxngRedirects:", val)
|
||||
for (const item of searxngNormalRedirectsChecks) if (!redirects.searxng.normal.includes(item)) {
|
||||
var index = searxngNormalRedirectsChecks.indexOf(item);
|
||||
if (index !== -1) searxngNormalRedirectsChecks.splice(index, 1);
|
||||
}
|
||||
browser.storage.local.set({ searxngNormalRedirectsChecks })
|
||||
|
||||
for (const item of searxngTorRedirectsChecks) if (!redirects.searxng.tor.includes(item)) {
|
||||
var index = searxngTorRedirectsChecks.indexOf(item);
|
||||
if (index !== -1) searxngTorRedirectsChecks.splice(index, 1);
|
||||
}
|
||||
browser.storage.local.set({ searxngTorRedirectsChecks });
|
||||
|
||||
for (const item of searxngI2pRedirectsChecks) if (!redirects.searxng.i2p.includes(item)) {
|
||||
var index = searxngI2pRedirectsChecks.indexOf(item);
|
||||
if (index !== -1) searxngI2pRedirectsChecks.splice(index, 1);
|
||||
}
|
||||
browser.storage.local.set({ searxngI2pRedirectsChecks })
|
||||
}
|
||||
|
||||
function setWhoogleRedirects(val) {
|
||||
redirects.whoogle = val;
|
||||
browser.storage.local.set({ searchRedirects: redirects })
|
||||
console.log("whoogleRedirects:", val)
|
||||
for (const item of whoogleNormalRedirectsChecks) if (!redirects.whoogle.normal.includes(item)) {
|
||||
var index = whoogleNormalRedirectsChecks.indexOf(item);
|
||||
if (index !== -1) whoogleNormalRedirectsChecks.splice(index, 1);
|
||||
}
|
||||
browser.storage.local.set({ whoogleNormalRedirectsChecks })
|
||||
|
||||
for (const item of whoogleTorRedirectsChecks) if (!redirects.whoogle.tor.includes(item)) {
|
||||
var index = whoogleTorRedirectsChecks.indexOf(item);
|
||||
if (index !== -1) whoogleTorRedirectsChecks.splice(index, 1);
|
||||
}
|
||||
browser.storage.local.set({ whoogleTorRedirectsChecks })
|
||||
|
||||
for (const item of whoogleI2pRedirectsChecks) if (!redirects.whoogle.i2p.includes(item)) {
|
||||
var index = whoogleI2pRedirectsChecks.indexOf(item);
|
||||
if (index !== -1) whoogleI2pRedirectsChecks.splice(index, 1);
|
||||
}
|
||||
browser.storage.local.set({ whoogleI2pRedirectsChecks })
|
||||
const c = whoogleNormalRedirectsChecks.indexOf(instance);
|
||||
if (c > -1) whoogleNormalRedirectsChecks.splice(c, 1);
|
||||
}
|
||||
browser.storage.local.set({
|
||||
searchRedirects: redirects,
|
||||
searxNormalRedirectsChecks,
|
||||
searxngNormalRedirectsChecks,
|
||||
whoogleNormalRedirectsChecks,
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
let
|
||||
searxNormalRedirectsChecks,
|
||||
searxI2pRedirectsChecks,
|
||||
searxTorRedirectsChecks,
|
||||
|
||||
searxngNormalRedirectsChecks,
|
||||
searxngI2pRedirectsChecks,
|
||||
searxngTorRedirectsChecks,
|
||||
|
||||
whoogleNormalRedirectsChecks,
|
||||
whoogleI2pRedirectsChecks,
|
||||
whoogleTorRedirectsChecks;
|
||||
whoogleNormalRedirectsChecks;
|
||||
|
||||
function initSearxCookies(test, from) {
|
||||
return new Promise(resolve => {
|
||||
@ -165,42 +113,45 @@ function initSearxCookies(test, from) {
|
||||
}
|
||||
|
||||
function setSearxCookies() {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"disableSearch",
|
||||
"searchProtocol",
|
||||
"searchFrontend",
|
||||
"searxNormalRedirectsChecks",
|
||||
"searxNormalCustomRedirects",
|
||||
"searxTorRedirectsChecks",
|
||||
"searxTorCustomRedirects",
|
||||
],
|
||||
r => {
|
||||
if (r.disableSearch || r.searchFrontend != 'searx', r.searchProtocol === undefined) return;
|
||||
let checkedInstances;
|
||||
if (r.searchProtocol == 'normal') checkedInstances = [...r.searxNormalRedirectsChecks, ...r.searxNormalCustomRedirects]
|
||||
else if (r.searchProtocol == 'tor') checkedInstances = [...r.searxTorRedirectsChecks, ...r.searxTorCustomRedirects]
|
||||
for (const to of checkedInstances) {
|
||||
utils.getCookiesFromStorage('searx', to, 'advanced_search');
|
||||
utils.getCookiesFromStorage('searx', to, 'autocomplete');
|
||||
utils.getCookiesFromStorage('searx', to, 'categories');
|
||||
utils.getCookiesFromStorage('searx', to, 'disabled_engines');
|
||||
utils.getCookiesFromStorage('searx', to, 'disabled_plugins');
|
||||
utils.getCookiesFromStorage('searx', to, 'doi_resolver');
|
||||
utils.getCookiesFromStorage('searx', to, 'enabled_engines');
|
||||
utils.getCookiesFromStorage('searx', to, 'enabled_plugins');
|
||||
utils.getCookiesFromStorage('searx', to, 'image_proxy');
|
||||
utils.getCookiesFromStorage('searx', to, 'language');
|
||||
utils.getCookiesFromStorage('searx', to, 'locale');
|
||||
utils.getCookiesFromStorage('searx', to, 'method');
|
||||
utils.getCookiesFromStorage('searx', to, 'oscar-style');
|
||||
utils.getCookiesFromStorage('searx', to, 'results_on_new_tab');
|
||||
utils.getCookiesFromStorage('searx', to, 'safesearch');
|
||||
utils.getCookiesFromStorage('searx', to, 'theme');
|
||||
utils.getCookiesFromStorage('searx', to, 'tokens');
|
||||
return new Promise(resolve => {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"disableSearch",
|
||||
"searchProtocol",
|
||||
"searchFrontend",
|
||||
"searxNormalRedirectsChecks",
|
||||
"searxNormalCustomRedirects",
|
||||
"searxTorRedirectsChecks",
|
||||
"searxTorCustomRedirects",
|
||||
],
|
||||
r => {
|
||||
if (r.disableSearch || r.searchFrontend != 'searx', r.searchProtocol === undefined) { resolve(); return; }
|
||||
let checkedInstances;
|
||||
if (r.searchProtocol == 'normal') checkedInstances = [...r.searxNormalRedirectsChecks, ...r.searxNormalCustomRedirects]
|
||||
else if (r.searchProtocol == 'tor') checkedInstances = [...r.searxTorRedirectsChecks, ...r.searxTorCustomRedirects]
|
||||
for (const to of checkedInstances) {
|
||||
utils.getCookiesFromStorage('searx', to, 'advanced_search');
|
||||
utils.getCookiesFromStorage('searx', to, 'autocomplete');
|
||||
utils.getCookiesFromStorage('searx', to, 'categories');
|
||||
utils.getCookiesFromStorage('searx', to, 'disabled_engines');
|
||||
utils.getCookiesFromStorage('searx', to, 'disabled_plugins');
|
||||
utils.getCookiesFromStorage('searx', to, 'doi_resolver');
|
||||
utils.getCookiesFromStorage('searx', to, 'enabled_engines');
|
||||
utils.getCookiesFromStorage('searx', to, 'enabled_plugins');
|
||||
utils.getCookiesFromStorage('searx', to, 'image_proxy');
|
||||
utils.getCookiesFromStorage('searx', to, 'language');
|
||||
utils.getCookiesFromStorage('searx', to, 'locale');
|
||||
utils.getCookiesFromStorage('searx', to, 'method');
|
||||
utils.getCookiesFromStorage('searx', to, 'oscar-style');
|
||||
utils.getCookiesFromStorage('searx', to, 'results_on_new_tab');
|
||||
utils.getCookiesFromStorage('searx', to, 'safesearch');
|
||||
utils.getCookiesFromStorage('searx', to, 'theme');
|
||||
utils.getCookiesFromStorage('searx', to, 'tokens');
|
||||
}
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
function initSearxngCookies(test, from) {
|
||||
@ -260,44 +211,47 @@ function initSearxngCookies(test, from) {
|
||||
}
|
||||
|
||||
function setSearxngCookies() {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"searchProtocol",
|
||||
"disableSearch",
|
||||
"searchFrontend",
|
||||
"searxngNormalRedirectsChecks",
|
||||
"searxngNormalCustomRedirects",
|
||||
"searxngTorRedirectsChecks",
|
||||
"searxngTorCustomRedirects",
|
||||
],
|
||||
r => {
|
||||
if (r.disableSearch || r.searchFrontend != 'searxng', r.searchProtocol === undefined) return;
|
||||
let checkedInstances;
|
||||
if (r.searchProtocol == 'normal') checkedInstances = [...r.searxngNormalRedirectsChecks, ...r.searxngNormalCustomRedirects]
|
||||
else if (r.searchProtocol == 'tor') checkedInstances = [...r.searxngTorRedirectsChecks, ...r.searxngTorCustomRedirects]
|
||||
for (const to of checkedInstances) {
|
||||
utils.getCookiesFromStorage('searxng', to, 'autocomplete');
|
||||
utils.getCookiesFromStorage('searxng', to, 'categories');
|
||||
utils.getCookiesFromStorage('searxng', to, 'disabled_engines');
|
||||
utils.getCookiesFromStorage('searxng', to, 'disabled_plugins');
|
||||
utils.getCookiesFromStorage('searxng', to, 'doi_resolver');
|
||||
utils.getCookiesFromStorage('searxng', to, 'enabled_plugins');
|
||||
utils.getCookiesFromStorage('searxng', to, 'enabled_engines');
|
||||
utils.getCookiesFromStorage('searxng', to, 'image_proxy');
|
||||
utils.getCookiesFromStorage('searxng', to, 'infinite_scroll');
|
||||
utils.getCookiesFromStorage('searxng', to, 'language');
|
||||
utils.getCookiesFromStorage('searxng', to, 'locale');
|
||||
utils.getCookiesFromStorage('searxng', to, 'maintab');
|
||||
utils.getCookiesFromStorage('searxng', to, 'method');
|
||||
utils.getCookiesFromStorage('searxng', to, 'query_in_title');
|
||||
utils.getCookiesFromStorage('searxng', to, 'results_on_new_tab');
|
||||
utils.getCookiesFromStorage('searxng', to, 'safesearch');
|
||||
utils.getCookiesFromStorage('searxng', to, 'simple_style');
|
||||
utils.getCookiesFromStorage('searxng', to, 'theme');
|
||||
utils.getCookiesFromStorage('searxng', to, 'tokens');
|
||||
return new Promise(resolve => {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"searchProtocol",
|
||||
"disableSearch",
|
||||
"searchFrontend",
|
||||
"searxngNormalRedirectsChecks",
|
||||
"searxngNormalCustomRedirects",
|
||||
"searxngTorRedirectsChecks",
|
||||
"searxngTorCustomRedirects",
|
||||
],
|
||||
r => {
|
||||
if (r.disableSearch || r.searchFrontend != 'searxng', r.searchProtocol === undefined) { resolve(); return; }
|
||||
let checkedInstances;
|
||||
if (r.searchProtocol == 'normal') checkedInstances = [...r.searxngNormalRedirectsChecks, ...r.searxngNormalCustomRedirects]
|
||||
else if (r.searchProtocol == 'tor') checkedInstances = [...r.searxngTorRedirectsChecks, ...r.searxngTorCustomRedirects]
|
||||
for (const to of checkedInstances) {
|
||||
utils.getCookiesFromStorage('searxng', to, 'autocomplete');
|
||||
utils.getCookiesFromStorage('searxng', to, 'categories');
|
||||
utils.getCookiesFromStorage('searxng', to, 'disabled_engines');
|
||||
utils.getCookiesFromStorage('searxng', to, 'disabled_plugins');
|
||||
utils.getCookiesFromStorage('searxng', to, 'doi_resolver');
|
||||
utils.getCookiesFromStorage('searxng', to, 'enabled_plugins');
|
||||
utils.getCookiesFromStorage('searxng', to, 'enabled_engines');
|
||||
utils.getCookiesFromStorage('searxng', to, 'image_proxy');
|
||||
utils.getCookiesFromStorage('searxng', to, 'infinite_scroll');
|
||||
utils.getCookiesFromStorage('searxng', to, 'language');
|
||||
utils.getCookiesFromStorage('searxng', to, 'locale');
|
||||
utils.getCookiesFromStorage('searxng', to, 'maintab');
|
||||
utils.getCookiesFromStorage('searxng', to, 'method');
|
||||
utils.getCookiesFromStorage('searxng', to, 'query_in_title');
|
||||
utils.getCookiesFromStorage('searxng', to, 'results_on_new_tab');
|
||||
utils.getCookiesFromStorage('searxng', to, 'safesearch');
|
||||
utils.getCookiesFromStorage('searxng', to, 'simple_style');
|
||||
utils.getCookiesFromStorage('searxng', to, 'theme');
|
||||
utils.getCookiesFromStorage('searxng', to, 'tokens');
|
||||
}
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
function redirect(url) {
|
||||
@ -381,7 +335,7 @@ function redirect(url) {
|
||||
(
|
||||
url.hostname.includes('google') ||
|
||||
url.hostname.includes('bing') ||
|
||||
url.hostname.includes('libredirect.invalid')
|
||||
url.hostname.includes('search.libredirect.invalid')
|
||||
) &&
|
||||
url.searchParams.has('q')
|
||||
) searchQuery = `?q=${url.searchParams.get('q')}`;
|
||||
@ -485,71 +439,72 @@ async function switchInstance(url) {
|
||||
})
|
||||
}
|
||||
|
||||
async function initDefaults() {
|
||||
await fetch('/instances/data.json').then(response => response.text()).then(async data => {
|
||||
let dataJson = JSON.parse(data);
|
||||
redirects.searx = dataJson.searx;
|
||||
redirects.searxng = dataJson.searxng;
|
||||
redirects.whoogle = dataJson.whoogle;
|
||||
function initDefaults() {
|
||||
return new Promise(async resolve => {
|
||||
fetch('/instances/data.json').then(response => response.text()).then(async data => {
|
||||
let dataJson = JSON.parse(data);
|
||||
redirects.searx = dataJson.searx;
|
||||
redirects.searxng = dataJson.searxng;
|
||||
redirects.whoogle = dataJson.whoogle;
|
||||
|
||||
browser.storage.local.get('cloudflareList', async r => {
|
||||
whoogleNormalRedirectsChecks = [...redirects.whoogle.normal];
|
||||
searxNormalRedirectsChecks = [...redirects.searx.normal];
|
||||
searxngNormalRedirectsChecks = [...redirects.searxng.normal];
|
||||
for (const instance of r.cloudflareList) {
|
||||
let i;
|
||||
browser.storage.local.get('cloudflareList', async r => {
|
||||
whoogleNormalRedirectsChecks = [...redirects.whoogle.normal];
|
||||
searxNormalRedirectsChecks = [...redirects.searx.normal];
|
||||
searxngNormalRedirectsChecks = [...redirects.searxng.normal];
|
||||
for (const instance of r.cloudflareList) {
|
||||
let i;
|
||||
|
||||
i = whoogleNormalRedirectsChecks.indexOf(instance);
|
||||
if (i > -1) whoogleNormalRedirectsChecks.splice(i, 1);
|
||||
i = whoogleNormalRedirectsChecks.indexOf(instance);
|
||||
if (i > -1) whoogleNormalRedirectsChecks.splice(i, 1);
|
||||
|
||||
i = searxNormalRedirectsChecks.indexOf(instance);
|
||||
if (i > -1) searxNormalRedirectsChecks.splice(i, 1);
|
||||
i = searxNormalRedirectsChecks.indexOf(instance);
|
||||
if (i > -1) searxNormalRedirectsChecks.splice(i, 1);
|
||||
|
||||
i = searxngNormalRedirectsChecks.indexOf(instance);
|
||||
if (i > -1) searxngNormalRedirectsChecks.splice(i, 1);
|
||||
}
|
||||
await browser.storage.local.set({
|
||||
disableSearch: false,
|
||||
searchFrontend: 'searxng',
|
||||
searchRedirects: redirects,
|
||||
searxngCustomSettings: false,
|
||||
searchProtocol: 'normal',
|
||||
i = searxngNormalRedirectsChecks.indexOf(instance);
|
||||
if (i > -1) searxngNormalRedirectsChecks.splice(i, 1);
|
||||
}
|
||||
await browser.storage.local.set({
|
||||
disableSearch: false,
|
||||
searchFrontend: 'searxng',
|
||||
searchRedirects: redirects,
|
||||
searxngCustomSettings: false,
|
||||
searchProtocol: 'normal',
|
||||
|
||||
whoogleNormalRedirectsChecks: whoogleNormalRedirectsChecks,
|
||||
whoogleNormalCustomRedirects: [],
|
||||
whoogleNormalRedirectsChecks: whoogleNormalRedirectsChecks,
|
||||
whoogleNormalCustomRedirects: [],
|
||||
|
||||
whoogleTorRedirectsChecks: [...redirects.whoogle.tor],
|
||||
whoogleTorCustomRedirects: [],
|
||||
whoogleTorRedirectsChecks: [...redirects.whoogle.tor],
|
||||
whoogleTorCustomRedirects: [],
|
||||
|
||||
whoogleI2pRedirectsChecks: [...redirects.whoogle.i2p],
|
||||
whoogleI2pCustomRedirects: [],
|
||||
whoogleI2pRedirectsChecks: [...redirects.whoogle.i2p],
|
||||
whoogleI2pCustomRedirects: [],
|
||||
|
||||
searxNormalRedirectsChecks: searxNormalRedirectsChecks,
|
||||
searxNormalCustomRedirects: [],
|
||||
searxNormalRedirectsChecks: searxNormalRedirectsChecks,
|
||||
searxNormalCustomRedirects: [],
|
||||
|
||||
searxTorRedirectsChecks: [...redirects.searx.tor],
|
||||
searxTorCustomRedirects: [],
|
||||
searxTorRedirectsChecks: [...redirects.searx.tor],
|
||||
searxTorCustomRedirects: [],
|
||||
|
||||
searxI2pRedirectsChecks: [...redirects.searx.i2p],
|
||||
searxI2pCustomRedirects: [],
|
||||
searxI2pRedirectsChecks: [...redirects.searx.i2p],
|
||||
searxI2pCustomRedirects: [],
|
||||
|
||||
searxngNormalRedirectsChecks: searxngNormalRedirectsChecks,
|
||||
searxngNormalCustomRedirects: [],
|
||||
searxngNormalRedirectsChecks: searxngNormalRedirectsChecks,
|
||||
searxngNormalCustomRedirects: [],
|
||||
|
||||
searxngTorRedirectsChecks: [...redirects.searxng.tor],
|
||||
searxngTorCustomRedirects: [],
|
||||
searxngTorRedirectsChecks: [...redirects.searxng.tor],
|
||||
searxngTorCustomRedirects: [],
|
||||
|
||||
searxngI2pRedirectsChecks: [...redirects.searxng.i2p],
|
||||
searxngI2pCustomRedirects: [],
|
||||
searxngI2pRedirectsChecks: [...redirects.searxng.i2p],
|
||||
searxngI2pCustomRedirects: [],
|
||||
})
|
||||
resolve();
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export default {
|
||||
setSearxRedirects,
|
||||
setSearxngRedirects,
|
||||
setWhoogleRedirects,
|
||||
setRedirects,
|
||||
|
||||
initSearxCookies,
|
||||
setSearxCookies,
|
||||
|
@ -3,7 +3,7 @@ window.browser = window.browser || window.chrome;
|
||||
import utils from './utils.js'
|
||||
|
||||
const targets = [
|
||||
/^https?:\/{2}send.invalid\/$/,
|
||||
/^https?:\/{2}send\.libredirect\.invalid\/$/,
|
||||
/^ https ?: \/\/send\.firefox\.com\/$/,
|
||||
/^https?:\/{2}sendfiles\.online\/$/
|
||||
];
|
||||
@ -15,33 +15,23 @@ let redirects = {
|
||||
}
|
||||
}
|
||||
function setRedirects(val) {
|
||||
redirects.send = val;
|
||||
browser.storage.local.set({ sendTargetsRedirects: redirects })
|
||||
console.log("sendTargetsRedirects: ", val)
|
||||
for (const item of sendNormalRedirectsChecks)
|
||||
if (!redirects.send.normal.includes(item)) {
|
||||
var index = sendNormalRedirectsChecks.indexOf(item);
|
||||
if (index !== -1) sendNormalRedirectsChecks.splice(index, 1);
|
||||
browser.storage.local.get('cloudflareList', r => {
|
||||
redirects.send = val;
|
||||
sendNormalRedirectsChecks = [...redirects.send.normal];
|
||||
for (const instance of r.cloudflareList) {
|
||||
const a = sendNormalRedirectsChecks.indexOf(instance);
|
||||
if (a > -1) sendNormalRedirectsChecks.splice(a, 1);
|
||||
}
|
||||
browser.storage.local.set({ sendNormalRedirectsChecks })
|
||||
|
||||
for (const item of sendTorRedirectsChecks)
|
||||
if (!redirects.send.normal.includes(item)) {
|
||||
var index = sendTorRedirectsChecks.indexOf(item);
|
||||
if (index !== -1) sendTorRedirectsChecks.splice(index, 1);
|
||||
}
|
||||
browser.storage.local.set({ sendTorRedirectsChecks })
|
||||
browser.storage.local.set({
|
||||
sendTargetsRedirects: redirects,
|
||||
sendNormalRedirectsChecks,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
let sendNormalRedirectsChecks;
|
||||
let sendTorRedirectsChecks;
|
||||
let sendNormalCustomRedirects = [];
|
||||
let sendTorCustomRedirects = [];
|
||||
|
||||
let disable; // disableSendTarget
|
||||
let protocol; // sendTargetsProtocol
|
||||
|
||||
async function switchInstance(url) {
|
||||
function switchInstance(url) {
|
||||
return new Promise(resolve => {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
@ -82,85 +72,80 @@ async function switchInstance(url) {
|
||||
}
|
||||
|
||||
function redirect(url, type, initiator) {
|
||||
if (disable) return null;
|
||||
if (type != "main_frame") return null;
|
||||
if (initiator && (
|
||||
[...redirects.send.normal,
|
||||
...sendNormalCustomRedirects
|
||||
].includes(initiator.origin) ||
|
||||
targets.includes(initiator.host)
|
||||
)) return null;
|
||||
if (!targets.some(rx => rx.test(url.href))) return null;
|
||||
return new Promise(resolve => {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"disableSendTarget",
|
||||
"sendTargetsRedirects",
|
||||
|
||||
let instancesList;
|
||||
if (protocol == 'normal') instancesList = [...sendNormalRedirectsChecks, ...sendNormalCustomRedirects];
|
||||
if (protocol == 'tor') instancesList = [...sendTorRedirectsChecks, ...sendTorCustomRedirects];
|
||||
if (instancesList.length === 0) return null;
|
||||
let randomInstance = utils.getRandomInstance(instancesList);
|
||||
"sendNormalRedirectsChecks",
|
||||
"sendNormalCustomRedirects",
|
||||
|
||||
return randomInstance;
|
||||
"sendTorRedirectsChecks",
|
||||
"sendTorCustomRedirects",
|
||||
|
||||
"sendTargetsProtocol"
|
||||
],
|
||||
r => {
|
||||
if (r.disableSendTarget) { resolve(); return; }
|
||||
if (type != "main_frame") { resolve(); return; }
|
||||
if (
|
||||
initiator && (
|
||||
[
|
||||
...r.sendTargetsRedirects.send.normal,
|
||||
...r.sendTargetsRedirects.send.tor,
|
||||
...r.sendNormalCustomRedirects,
|
||||
...r.sendTorRedirectsChecks
|
||||
].includes(initiator.origin) ||
|
||||
targets.includes(initiator.host)
|
||||
)
|
||||
) { resolve(); return; }
|
||||
if (!targets.some(rx => rx.test(url.href))) { resolve(); return; }
|
||||
|
||||
let instancesList;
|
||||
if (r.sendTargetsProtocol == 'normal') instancesList = [...r.sendNormalRedirectsChecks, ...r.sendNormalCustomRedirects];
|
||||
if (r.sendTargetsProtocol == 'tor') instancesList = [...r.sendTorRedirectsChecks, ...r.sendTorCustomRedirects];
|
||||
if (instancesList.length === 0) { resolve(); return; }
|
||||
|
||||
let randomInstance = utils.getRandomInstance(instancesList);
|
||||
resolve(randomInstance);
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
async function initDefaults() {
|
||||
fetch('/instances/data.json').then(response => response.text()).then(async data => {
|
||||
let dataJson = JSON.parse(data);
|
||||
redirects.send = dataJson.send;
|
||||
browser.storage.local.get('cloudflareList', async r => {
|
||||
sendNormalRedirectsChecks = [...redirects.send.normal];
|
||||
for (const instance of r.cloudflareList) {
|
||||
let i = sendNormalRedirectsChecks.indexOf(instance);
|
||||
if (i > -1) sendNormalRedirectsChecks.splice(i, 1);
|
||||
}
|
||||
await browser.storage.local.set({
|
||||
disableSendTarget: false,
|
||||
sendTargetsRedirects: redirects,
|
||||
function initDefaults() {
|
||||
return new Promise(resolve => {
|
||||
fetch('/instances/data.json').then(response => response.text()).then(async data => {
|
||||
let dataJson = JSON.parse(data);
|
||||
redirects.send = dataJson.send;
|
||||
browser.storage.local.get('cloudflareList', async r => {
|
||||
sendNormalRedirectsChecks = [...redirects.send.normal];
|
||||
for (const instance of r.cloudflareList) {
|
||||
let i = sendNormalRedirectsChecks.indexOf(instance);
|
||||
if (i > -1) sendNormalRedirectsChecks.splice(i, 1);
|
||||
}
|
||||
await browser.storage.local.set({
|
||||
disableSendTarget: false,
|
||||
sendTargetsRedirects: redirects,
|
||||
|
||||
sendNormalRedirectsChecks: sendNormalRedirectsChecks,
|
||||
sendNormalCustomRedirects: [],
|
||||
sendNormalRedirectsChecks: sendNormalRedirectsChecks,
|
||||
sendNormalCustomRedirects: [],
|
||||
|
||||
sendTorRedirectsChecks: [...redirects.send.tor],
|
||||
sendTorCustomRedirects: [],
|
||||
sendTorRedirectsChecks: [...redirects.send.tor],
|
||||
sendTorCustomRedirects: [],
|
||||
|
||||
sendTargetsProtocol: "normal",
|
||||
sendTargetsProtocol: "normal",
|
||||
})
|
||||
resolve();
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
async function init() {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"disableSendTarget",
|
||||
"sendTargetsRedirects",
|
||||
|
||||
"sendNormalRedirectsChecks",
|
||||
"sendNormalCustomRedirects",
|
||||
|
||||
"sendTorRedirectsChecks",
|
||||
"sendTorCustomRedirects",
|
||||
|
||||
"sendTargetsProtocol"
|
||||
],
|
||||
r => {
|
||||
disable = r.disableSendTarget;
|
||||
protocol = r.sendTargetsProtocol;
|
||||
redirects = r.sendTargetsRedirects;
|
||||
|
||||
sendNormalRedirectsChecks = r.sendNormalRedirectsChecks;
|
||||
sendNormalCustomRedirects = r.sendNormalCustomRedirects;
|
||||
|
||||
sendTorRedirectsChecks = r.sendTorRedirectsChecks;
|
||||
sendTorCustomRedirects = r.sendTorCustomRedirects;
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
export default {
|
||||
setRedirects,
|
||||
|
||||
redirect,
|
||||
switchInstance,
|
||||
|
||||
initDefaults,
|
||||
init,
|
||||
};
|
||||
|
@ -13,22 +13,18 @@ let redirects = {
|
||||
}
|
||||
}
|
||||
function setRedirects(val) {
|
||||
redirects.proxiTok = val;
|
||||
browser.storage.local.set({ tiktokRedirects: redirects })
|
||||
console.log("tiktokRedirects: ", val)
|
||||
for (const item of proxiTokNormalRedirectsChecks)
|
||||
if (!redirects.proxiTok.normal.includes(item)) {
|
||||
var index = proxiTokNormalRedirectsChecks.indexOf(item);
|
||||
if (index !== -1) proxiTokNormalRedirectsChecks.splice(index, 1);
|
||||
browser.storage.local.get('cloudflareList', r => {
|
||||
redirects.proxiTok = val;
|
||||
proxiTokNormalRedirectsChecks = [...redirects.proxiTok.normal];
|
||||
for (const instance of r.cloudflareList) {
|
||||
const a = proxiTokNormalRedirectsChecks.indexOf(instance);
|
||||
if (a > -1) proxiTokNormalRedirectsChecks.splice(a, 1);
|
||||
}
|
||||
browser.storage.local.set({ proxiTokNormalRedirectsChecks })
|
||||
|
||||
for (const item of proxiTokTorRedirectsChecks)
|
||||
if (!redirects.proxiTok.normal.includes(item)) {
|
||||
var index = proxiTokTorRedirectsChecks.indexOf(item);
|
||||
if (index !== -1) proxiTokTorRedirectsChecks.splice(index, 1);
|
||||
}
|
||||
browser.storage.local.set({ proxiTokTorRedirectsChecks })
|
||||
browser.storage.local.set({
|
||||
tiktokRedirects: redirects,
|
||||
proxiTokNormalRedirectsChecks
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
let proxiTokNormalRedirectsChecks;
|
||||
@ -57,7 +53,7 @@ function initProxiTokCookies(test, from) {
|
||||
...r.proxiTokTorRedirectsChecks,
|
||||
...r.proxiTokTorCustomRedirects,
|
||||
].includes(protocolHost)) resolve();
|
||||
|
||||
|
||||
if (!test) {
|
||||
let checkedInstances;
|
||||
if (r.tiktokProtocol == 'normal') checkedInstances = [...r.proxiTokNormalRedirectsChecks, ...r.proxiTokNormalCustomRedirects]
|
||||
@ -74,26 +70,29 @@ function initProxiTokCookies(test, from) {
|
||||
}
|
||||
|
||||
function setProxiTokCookies() {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"tiktokProtocol",
|
||||
"disableTiktok",
|
||||
"proxiTokNormalRedirectsChecks",
|
||||
"proxiTokNormalCustomRedirects",
|
||||
"proxiTokTorRedirectsChecks",
|
||||
"proxiTokTorCustomRedirects",
|
||||
],
|
||||
r => {
|
||||
if (r.disableTiktok || r.tiktokProtocol === undefined) return;
|
||||
let checkedInstances;
|
||||
if (r.tiktokProtocol == 'normal') checkedInstances = [...r.proxiTokNormalRedirectsChecks, ...r.proxiTokNormalCustomRedirects]
|
||||
else if (r.tiktokProtocol == 'tor') checkedInstances = [...r.proxiTokTorRedirectsChecks, ...r.proxiTokTorCustomRedirects]
|
||||
for (const to of checkedInstances) {
|
||||
utils.getCookiesFromStorage('proxitok', to, 'theme');
|
||||
utils.getCookiesFromStorage('proxitok', to, 'api-legacy');
|
||||
return new Promise(resolve => {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"tiktokProtocol",
|
||||
"disableTiktok",
|
||||
"proxiTokNormalRedirectsChecks",
|
||||
"proxiTokNormalCustomRedirects",
|
||||
"proxiTokTorRedirectsChecks",
|
||||
"proxiTokTorCustomRedirects",
|
||||
],
|
||||
r => {
|
||||
if (r.disableTiktok || r.tiktokProtocol === undefined) { resolve(); return; }
|
||||
let checkedInstances;
|
||||
if (r.tiktokProtocol == 'normal') checkedInstances = [...r.proxiTokNormalRedirectsChecks, ...r.proxiTokNormalCustomRedirects]
|
||||
else if (r.tiktokProtocol == 'tor') checkedInstances = [...r.proxiTokTorRedirectsChecks, ...r.proxiTokTorCustomRedirects]
|
||||
for (const to of checkedInstances) {
|
||||
utils.getCookiesFromStorage('proxitok', to, 'theme');
|
||||
utils.getCookiesFromStorage('proxitok', to, 'api-legacy');
|
||||
}
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
function redirect(url, type, initiator) {
|
||||
@ -163,7 +162,7 @@ async function reverse(url) {
|
||||
})
|
||||
}
|
||||
|
||||
async function initDefaults() {
|
||||
function initDefaults() {
|
||||
return new Promise(async resolve => {
|
||||
fetch('/instances/data.json').then(response => response.text()).then(async data => {
|
||||
let dataJson = JSON.parse(data);
|
||||
|
@ -22,12 +22,11 @@ let
|
||||
lingvaNormalRedirectsChecks;
|
||||
|
||||
function setRedirects(val) {
|
||||
browser.storage.local.get('cloudflareList', async r => {
|
||||
browser.storage.local.get('cloudflareList', r => {
|
||||
redirects = val;
|
||||
simplyTranslateNormalRedirectsChecks = [...redirects.simplyTranslate.normal];
|
||||
lingvaNormalRedirectsChecks = [...redirects.lingva.normal]
|
||||
for (const instance of r.cloudflareList) {
|
||||
let i;
|
||||
const a = simplyTranslateNormalRedirectsChecks.indexOf(instance);
|
||||
if (a > -1) simplyTranslateNormalRedirectsChecks.splice(a, 1);
|
||||
|
||||
@ -149,29 +148,32 @@ function initSimplyTranslateCookies(test, from) {
|
||||
}
|
||||
|
||||
function setSimplyTranslateCookies() {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"translateProtocol",
|
||||
"translateDisable",
|
||||
"translateFrontend",
|
||||
"simplyTranslateNormalRedirectsChecks",
|
||||
"simplyTranslateNormalCustomRedirects",
|
||||
"simplyTranslateTorRedirectsChecks",
|
||||
"simplyTranslateTorCustomRedirects",
|
||||
],
|
||||
r => {
|
||||
if (r.translateDisable || r.translateFrontend != 'simplyTranslate') return;
|
||||
let checkedInstances;
|
||||
if (r.translateProtocol == 'normal') checkedInstances = [...r.simplyTranslateNormalRedirectsChecks, ...r.simplyTranslateNormalCustomRedirects]
|
||||
else if (r.translateProtocol == 'tor') checkedInstances = [...r.simplyTranslateTorRedirectsChecks, ...r.simplyTranslateTorCustomRedirects]
|
||||
for (const to of checkedInstances) {
|
||||
utils.getCookiesFromStorage('simplyTranslate', to, 'from_lang');
|
||||
utils.getCookiesFromStorage('simplyTranslate', to, 'to_lang');
|
||||
utils.getCookiesFromStorage('simplyTranslate', to, 'tts_enabled');
|
||||
utils.getCookiesFromStorage('simplyTranslate', to, 'use_text_fields');
|
||||
return new Promise(resolve => {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"translateProtocol",
|
||||
"translateDisable",
|
||||
"translateFrontend",
|
||||
"simplyTranslateNormalRedirectsChecks",
|
||||
"simplyTranslateNormalCustomRedirects",
|
||||
"simplyTranslateTorRedirectsChecks",
|
||||
"simplyTranslateTorCustomRedirects",
|
||||
],
|
||||
r => {
|
||||
if (r.translateDisable || r.translateFrontend != 'simplyTranslate') { resolve(); return; }
|
||||
let checkedInstances;
|
||||
if (r.translateProtocol == 'normal') checkedInstances = [...r.simplyTranslateNormalRedirectsChecks, ...r.simplyTranslateNormalCustomRedirects]
|
||||
else if (r.translateProtocol == 'tor') checkedInstances = [...r.simplyTranslateTorRedirectsChecks, ...r.simplyTranslateTorCustomRedirects]
|
||||
for (const to of checkedInstances) {
|
||||
utils.getCookiesFromStorage('simplyTranslate', to, 'from_lang');
|
||||
utils.getCookiesFromStorage('simplyTranslate', to, 'to_lang');
|
||||
utils.getCookiesFromStorage('simplyTranslate', to, 'tts_enabled');
|
||||
utils.getCookiesFromStorage('simplyTranslate', to, 'use_text_fields');
|
||||
}
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
function redirect(url) {
|
||||
@ -285,39 +287,41 @@ function switchInstance(url) {
|
||||
}
|
||||
|
||||
function initDefaults() {
|
||||
fetch('/instances/data.json').then(response => response.text()).then(data => {
|
||||
let dataJson = JSON.parse(data);
|
||||
redirects.simplyTranslate = dataJson.simplyTranslate;
|
||||
redirects.lingva = dataJson.lingva;
|
||||
browser.storage.local.get(
|
||||
'cloudflareList',
|
||||
r => {
|
||||
simplyTranslateNormalRedirectsChecks = [...redirects.simplyTranslate.normal];
|
||||
lingvaNormalRedirectsChecks = [...redirects.lingva.normal]
|
||||
for (const instance of r.cloudflareList) {
|
||||
const a = simplyTranslateNormalRedirectsChecks.indexOf(instance);
|
||||
if (a > -1) simplyTranslateNormalRedirectsChecks.splice(a, 1);
|
||||
return new Promise(async resolve => {
|
||||
fetch('/instances/data.json').then(response => response.text()).then(data => {
|
||||
let dataJson = JSON.parse(data);
|
||||
redirects.simplyTranslate = dataJson.simplyTranslate;
|
||||
redirects.lingva = dataJson.lingva;
|
||||
browser.storage.local.get('cloudflareList',
|
||||
async r => {
|
||||
simplyTranslateNormalRedirectsChecks = [...redirects.simplyTranslate.normal];
|
||||
lingvaNormalRedirectsChecks = [...redirects.lingva.normal]
|
||||
for (const instance of r.cloudflareList) {
|
||||
const a = simplyTranslateNormalRedirectsChecks.indexOf(instance);
|
||||
if (a > -1) simplyTranslateNormalRedirectsChecks.splice(a, 1);
|
||||
|
||||
const b = lingvaNormalRedirectsChecks.indexOf(instance);
|
||||
if (b > -1) lingvaNormalRedirectsChecks.splice(b, 1);
|
||||
}
|
||||
browser.storage.local.set({
|
||||
translateDisable: false,
|
||||
translateFrontend: "simplyTranslate",
|
||||
translateProtocol: 'normal',
|
||||
translateRedirects: redirects,
|
||||
const b = lingvaNormalRedirectsChecks.indexOf(instance);
|
||||
if (b > -1) lingvaNormalRedirectsChecks.splice(b, 1);
|
||||
}
|
||||
await browser.storage.local.set({
|
||||
translateDisable: false,
|
||||
translateFrontend: "simplyTranslate",
|
||||
translateProtocol: 'normal',
|
||||
translateRedirects: redirects,
|
||||
|
||||
simplyTranslateNormalRedirectsChecks: simplyTranslateNormalRedirectsChecks,
|
||||
simplyTranslateNormalCustomRedirects: [],
|
||||
simplyTranslateTorRedirectsChecks: [...redirects.simplyTranslate.tor],
|
||||
simplyTranslateTorCustomRedirects: [],
|
||||
simplyTranslateNormalRedirectsChecks: simplyTranslateNormalRedirectsChecks,
|
||||
simplyTranslateNormalCustomRedirects: [],
|
||||
simplyTranslateTorRedirectsChecks: [...redirects.simplyTranslate.tor],
|
||||
simplyTranslateTorCustomRedirects: [],
|
||||
|
||||
lingvaNormalRedirectsChecks: lingvaNormalRedirectsChecks,
|
||||
lingvaNormalCustomRedirects: [],
|
||||
lingvaTorRedirectsChecks: [...redirects.lingva.tor],
|
||||
lingvaTorCustomRedirects: [],
|
||||
lingvaNormalRedirectsChecks: lingvaNormalRedirectsChecks,
|
||||
lingvaNormalCustomRedirects: [],
|
||||
lingvaTorRedirectsChecks: [...redirects.lingva.tor],
|
||||
lingvaTorCustomRedirects: [],
|
||||
})
|
||||
resolve();
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -56,10 +56,11 @@ async function redirect(url, initiator) {
|
||||
|
||||
if (
|
||||
initiator &&
|
||||
[...r.twitterRedirects.nitter.normal,
|
||||
...r.twitterRedirects.nitter.tor,
|
||||
...r.nitterTorCustomRedirects,
|
||||
...r.nitterNormalCustomRedirects
|
||||
[
|
||||
...r.twitterRedirects.nitter.normal,
|
||||
...r.twitterRedirects.nitter.tor,
|
||||
...r.nitterTorCustomRedirects,
|
||||
...r.nitterNormalCustomRedirects
|
||||
].includes(initiator.origin)
|
||||
) { resolve('BYPASSTAB'); return; }
|
||||
|
||||
@ -228,61 +229,67 @@ function initNitterCookies(test, from) {
|
||||
}
|
||||
|
||||
function setNitterCookies() {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"twitterProtocol",
|
||||
"disableTwitter",
|
||||
"youtubeFrontend",
|
||||
"nitterNormalRedirectsChecks",
|
||||
"nitterNormalCustomRedirects",
|
||||
"nitterTorRedirectsChecks",
|
||||
"nitterTorCustomRedirects",
|
||||
],
|
||||
r => {
|
||||
if (r.disableYoutube || r.youtubeFrontend != 'nitter' || r.twitterProtocol === undefined) return;
|
||||
let checkedInstances;
|
||||
if (r.youtubeProtocol == 'normal') checkedInstances = [...r.nitterNormalRedirectsChecks, ...r.nitterNormalCustomRedirects]
|
||||
else if (r.youtubeProtocol == 'tor') checkedInstances = [...r.nitterTorRedirectsChecks, ...r.nitterTorCustomRedirects]
|
||||
for (const to of checkedInstances) {
|
||||
utils.getCookiesFromStorage('nitter', to, 'theme');
|
||||
utils.getCookiesFromStorage('nitter', to, 'infiniteScroll');
|
||||
utils.getCookiesFromStorage('nitter', to, 'stickyProfile');
|
||||
utils.getCookiesFromStorage('nitter', to, 'bidiSupport');
|
||||
utils.getCookiesFromStorage('nitter', to, 'hideTweetStats');
|
||||
utils.getCookiesFromStorage('nitter', to, 'hideBanner');
|
||||
utils.getCookiesFromStorage('nitter', to, 'hidePins');
|
||||
utils.getCookiesFromStorage('nitter', to, 'hideReplies');
|
||||
utils.getCookiesFromStorage('nitter', to, 'squareAvatars');
|
||||
utils.getCookiesFromStorage('nitter', to, 'mp4Playback');
|
||||
utils.getCookiesFromStorage('nitter', to, 'hlsPlayback');
|
||||
utils.getCookiesFromStorage('nitter', to, 'proxyVideos');
|
||||
utils.getCookiesFromStorage('nitter', to, 'muteVideos');
|
||||
utils.getCookiesFromStorage('nitter', to, 'autoplayGifs');
|
||||
return new Promise(resolve => {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"twitterProtocol",
|
||||
"disableTwitter",
|
||||
"youtubeFrontend",
|
||||
"nitterNormalRedirectsChecks",
|
||||
"nitterNormalCustomRedirects",
|
||||
"nitterTorRedirectsChecks",
|
||||
"nitterTorCustomRedirects",
|
||||
],
|
||||
r => {
|
||||
if (r.disableYoutube || r.youtubeFrontend != 'nitter' || r.twitterProtocol === undefined) { resolve(); return; }
|
||||
let checkedInstances;
|
||||
if (r.youtubeProtocol == 'normal') checkedInstances = [...r.nitterNormalRedirectsChecks, ...r.nitterNormalCustomRedirects]
|
||||
else if (r.youtubeProtocol == 'tor') checkedInstances = [...r.nitterTorRedirectsChecks, ...r.nitterTorCustomRedirects]
|
||||
for (const to of checkedInstances) {
|
||||
utils.getCookiesFromStorage('nitter', to, 'theme');
|
||||
utils.getCookiesFromStorage('nitter', to, 'infiniteScroll');
|
||||
utils.getCookiesFromStorage('nitter', to, 'stickyProfile');
|
||||
utils.getCookiesFromStorage('nitter', to, 'bidiSupport');
|
||||
utils.getCookiesFromStorage('nitter', to, 'hideTweetStats');
|
||||
utils.getCookiesFromStorage('nitter', to, 'hideBanner');
|
||||
utils.getCookiesFromStorage('nitter', to, 'hidePins');
|
||||
utils.getCookiesFromStorage('nitter', to, 'hideReplies');
|
||||
utils.getCookiesFromStorage('nitter', to, 'squareAvatars');
|
||||
utils.getCookiesFromStorage('nitter', to, 'mp4Playback');
|
||||
utils.getCookiesFromStorage('nitter', to, 'hlsPlayback');
|
||||
utils.getCookiesFromStorage('nitter', to, 'proxyVideos');
|
||||
utils.getCookiesFromStorage('nitter', to, 'muteVideos');
|
||||
utils.getCookiesFromStorage('nitter', to, 'autoplayGifs');
|
||||
}
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
function initDefaults() {
|
||||
fetch('/instances/data.json').then(response => response.text()).then(data => {
|
||||
let dataJson = JSON.parse(data);
|
||||
redirects.nitter = dataJson.nitter;
|
||||
browser.storage.local.get('cloudflareList', r => {
|
||||
nitterNormalRedirectsChecks = [...redirects.nitter.normal];
|
||||
for (const instance of r.cloudflareList) {
|
||||
let i = nitterNormalRedirectsChecks.indexOf(instance);
|
||||
if (i > -1) nitterNormalRedirectsChecks.splice(i, 1);
|
||||
}
|
||||
browser.storage.local.set({
|
||||
disableTwitter: false,
|
||||
twitterRedirects: redirects,
|
||||
twitterProtocol: "normal",
|
||||
return new Promise(resolve => {
|
||||
fetch('/instances/data.json').then(response => response.text()).then(data => {
|
||||
let dataJson = JSON.parse(data);
|
||||
redirects.nitter = dataJson.nitter;
|
||||
browser.storage.local.get('cloudflareList', async r => {
|
||||
nitterNormalRedirectsChecks = [...redirects.nitter.normal];
|
||||
for (const instance of r.cloudflareList) {
|
||||
let i = nitterNormalRedirectsChecks.indexOf(instance);
|
||||
if (i > -1) nitterNormalRedirectsChecks.splice(i, 1);
|
||||
}
|
||||
await browser.storage.local.set({
|
||||
disableTwitter: false,
|
||||
twitterRedirects: redirects,
|
||||
twitterProtocol: "normal",
|
||||
|
||||
nitterNormalRedirectsChecks,
|
||||
nitterNormalCustomRedirects: [],
|
||||
nitterNormalRedirectsChecks,
|
||||
nitterNormalCustomRedirects: [],
|
||||
|
||||
nitterTorRedirectsChecks: [...redirects.nitter.tor],
|
||||
nitterTorCustomRedirects: [],
|
||||
nitterTorRedirectsChecks: [...redirects.nitter.tor],
|
||||
nitterTorCustomRedirects: [],
|
||||
})
|
||||
resolve();
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -28,60 +28,31 @@ async function initCloudflareList() {
|
||||
});
|
||||
}
|
||||
|
||||
async function wholeInit() {
|
||||
await sendTargetsHelper.init();
|
||||
await tiktokHelper.init();
|
||||
await initCloudflareList();
|
||||
}
|
||||
function updateInstances() {
|
||||
return new Promise(async resolve => {
|
||||
let http = new XMLHttpRequest();
|
||||
http.open('GET', 'https://raw.githubusercontent.com/libredirect/libredirect/master/src/instances/data.json', false);
|
||||
http.send(null);
|
||||
if (http.status === 200) {
|
||||
await initCloudflareList();
|
||||
const instances = JSON.parse(http.responseText);
|
||||
|
||||
async function updateInstances() {
|
||||
let http = new XMLHttpRequest();
|
||||
http.open('GET', 'https://raw.githubusercontent.com/libredirect/libredirect/master/src/instances/data.json', false);
|
||||
http.send(null);
|
||||
youtubeHelper.setRedirects({ 'invidious': instances.invidious, 'piped': instances.piped, })
|
||||
twitterHelper.setRedirects(instances.nitter);
|
||||
instagramHelper.setRedirects(instances.bibliogram);
|
||||
redditHelper.setRedirects({ 'libreddit': instances.libreddit, 'teddit': instances.teddit });
|
||||
translateHelper.setRedirects({ "simplyTranslate": instances.simplyTranslate, "lingva": instances.lingva });
|
||||
searchHelper.setRedirects({ 'searx': instances.searx, 'searxng': instances.searxng, 'whoogle': instances.whoogle });
|
||||
wikipediaHelper.setRedirects(instances.wikiless);
|
||||
mediumHelper.setRedirects(instances.scribe);
|
||||
sendTargetsHelper.setRedirects(instances.send);
|
||||
tiktokHelper.setRedirects(instances.proxiTok);
|
||||
|
||||
if (http.status === 200) {
|
||||
await wholeInit();
|
||||
const instances = JSON.parse(http.responseText);
|
||||
|
||||
browser.storage.local.get(
|
||||
[
|
||||
'youtubeRedirects'
|
||||
],
|
||||
r =>
|
||||
brwoser.storage.local.set({
|
||||
youtubeRedirects: {
|
||||
'invidious': instances.invidious,
|
||||
'piped': r.youtubeRedirects.piped,
|
||||
'pipedMaterial': r.youtubeRedirects.pipedMaterial
|
||||
},
|
||||
})
|
||||
)
|
||||
|
||||
twitterHelper.setRedirects(instances.nitter);
|
||||
|
||||
instagramHelper.setRedirects(instances.bibliogram);
|
||||
|
||||
redditHelper.setTedditRedirects(instances.teddit);
|
||||
redditHelper.setLibredditRedirects(instances.libreddit);
|
||||
|
||||
translateHelper.setRedirects({ "simplyTranslate": instances.simplyTranslate, "lingva": instances.lingva });
|
||||
|
||||
searchHelper.setSearxRedirects(instances.searx);
|
||||
searchHelper.setSearxngRedirects(instances.searxng);
|
||||
searchHelper.setWhoogleRedirects(instances.whoogle);
|
||||
|
||||
wikipediaHelper.setRedirects(instances.wikiless);
|
||||
|
||||
mediumHelper.setRedirects(instances.scribe);
|
||||
|
||||
sendTargetsHelper.setRedirects(instances.send);
|
||||
|
||||
tiktokHelper.setRedirects(instances.proxiTok);
|
||||
|
||||
console.info("Successfully updated Instances");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
console.info("Successfully updated Instances");
|
||||
resolve(true); return;
|
||||
}
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
|
||||
function protocolHost(url) {
|
||||
@ -436,8 +407,6 @@ function switchInstance(test) {
|
||||
if (!newUrl) newUrl = await imgurHelper.switchInstance(url);
|
||||
if (!newUrl) newUrl = await wikipediaHelper.switchInstance(url);
|
||||
|
||||
console.log('newUrl', newUrl);
|
||||
console.log('test');
|
||||
if (newUrl) {
|
||||
if (!test)
|
||||
browser.tabs.update({ url: newUrl });
|
||||
@ -446,7 +415,6 @@ function switchInstance(test) {
|
||||
}
|
||||
})
|
||||
})
|
||||
return false;
|
||||
}
|
||||
|
||||
function latency(name, frontend, document, location, splitNames) {
|
||||
|
@ -12,35 +12,21 @@ let redirects = {
|
||||
}
|
||||
};
|
||||
function setRedirects(val) {
|
||||
redirects.wikiless = val;
|
||||
browser.storage.local.set({ wikipediaRedirects: redirects })
|
||||
console.log("wikipediaRedirects: ", val)
|
||||
for (const item of wikilessNormalRedirectsChecks)
|
||||
if (!redirects.wikiless.normal.includes(item)) {
|
||||
var index = wikilessNormalRedirectsChecks.indexOf(item);
|
||||
if (index !== -1) wikilessNormalRedirectsChecks.splice(index, 1);
|
||||
browser.storage.local.get('cloudflareList', r => {
|
||||
redirects.wikiless = val;
|
||||
wikilessNormalRedirectsChecks = [...redirects.wikiless.normal];
|
||||
for (const instance of r.cloudflareList) {
|
||||
const a = wikilessNormalRedirectsChecks.indexOf(instance);
|
||||
if (a > -1) wikilessNormalRedirectsChecks.splice(a, 1);
|
||||
}
|
||||
browser.storage.local.set({ wikilessNormalRedirectsChecks })
|
||||
|
||||
for (const item of wikilessTorRedirectsChecks)
|
||||
if (!redirects.wikiless.tor.includes(item)) {
|
||||
var index = wikilessTorRedirectsChecks.indexOf(item);
|
||||
if (index !== -1) wikilessTorRedirectsChecks.splice(index, 1);
|
||||
}
|
||||
browser.storage.local.set({ wikilessTorRedirectsChecks })
|
||||
|
||||
for (const item of wikilessI2pRedirectsChecks)
|
||||
if (!redirects.wikiless.i2p.includes(item)) {
|
||||
var index = wikilessI2pRedirectsChecks.indexOf(item);
|
||||
if (index !== -1) wikilessI2pRedirectsChecks.splice(index, 1);
|
||||
}
|
||||
browser.storage.local.set({ wikilessI2pRedirectsChecks })
|
||||
browser.storage.local.set({
|
||||
wikipediaRedirects: redirects,
|
||||
wikilessNormalRedirectsChecks
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
let
|
||||
wikilessNormalRedirectsChecks,
|
||||
wikilessTorRedirectsChecks,
|
||||
wikilessI2pRedirectsChecks;
|
||||
let wikilessNormalRedirectsChecks;
|
||||
|
||||
function initWikilessCookies(test, from) {
|
||||
return new Promise(resolve => {
|
||||
@ -83,26 +69,29 @@ function initWikilessCookies(test, from) {
|
||||
}
|
||||
|
||||
function setWikilessCookies() {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"disableWikipedia",
|
||||
"wikipediaProtocol",
|
||||
"wikilessNormalRedirectsChecks",
|
||||
"wikilessNormalCustomRedirects",
|
||||
"wikilessTorRedirectsChecks",
|
||||
"wikilessTorCustomRedirects",
|
||||
],
|
||||
r => {
|
||||
if (r.disableWikipedia || r.wikipediaProtocol === undefined) return;
|
||||
let checkedInstances;
|
||||
if (r.wikipediaProtocol == 'normal') checkedInstances = [...r.wikilessNormalRedirectsChecks, ...r.wikilessNormalCustomRedirects]
|
||||
else if (r.wikipediaProtocol == 'tor') checkedInstances = [...r.wikilessTorRedirectsChecks, ...r.wikilessTorCustomRedirects]
|
||||
for (const to of checkedInstances) {
|
||||
utils.getCookiesFromStorage('wikiless', to, 'theme');
|
||||
utils.getCookiesFromStorage('wikiless', to, 'default_lang');
|
||||
return new Promise(resolve => {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"disableWikipedia",
|
||||
"wikipediaProtocol",
|
||||
"wikilessNormalRedirectsChecks",
|
||||
"wikilessNormalCustomRedirects",
|
||||
"wikilessTorRedirectsChecks",
|
||||
"wikilessTorCustomRedirects",
|
||||
],
|
||||
r => {
|
||||
if (r.disableWikipedia || r.wikipediaProtocol === undefined) { resolve(); return; }
|
||||
let checkedInstances;
|
||||
if (r.wikipediaProtocol == 'normal') checkedInstances = [...r.wikilessNormalRedirectsChecks, ...r.wikilessNormalCustomRedirects]
|
||||
else if (r.wikipediaProtocol == 'tor') checkedInstances = [...r.wikilessTorRedirectsChecks, ...r.wikilessTorCustomRedirects]
|
||||
for (const to of checkedInstances) {
|
||||
utils.getCookiesFromStorage('wikiless', to, 'theme');
|
||||
utils.getCookiesFromStorage('wikiless', to, 'default_lang');
|
||||
}
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
function redirect(url) {
|
||||
@ -206,26 +195,29 @@ function switchInstance(url) {
|
||||
})
|
||||
}
|
||||
|
||||
async function initDefaults() {
|
||||
fetch('/instances/data.json').then(response => response.text()).then(async data => {
|
||||
let dataJson = JSON.parse(data);
|
||||
redirects.wikiless = dataJson.wikiless;
|
||||
browser.storage.local.get('cloudflareList', async r => {
|
||||
wikilessNormalRedirectsChecks = [...redirects.wikiless.normal];
|
||||
for (const instance of r.cloudflareList) {
|
||||
let i = wikilessNormalRedirectsChecks.indexOf(instance);
|
||||
if (i > -1) wikilessNormalRedirectsChecks.splice(i, 1);
|
||||
}
|
||||
await browser.storage.local.set({
|
||||
disableWikipedia: true,
|
||||
wikipediaRedirects: redirects,
|
||||
wikipediaProtocol: "normal",
|
||||
wikilessNormalRedirectsChecks: wikilessNormalRedirectsChecks,
|
||||
wikilessTorRedirectsChecks: [...redirects.wikiless.tor],
|
||||
wikilessI2pRedirectsChecks: [...redirects.wikiless.i2p],
|
||||
wikilessNormalCustomRedirects: [],
|
||||
wikilessTorCustomRedirects: [],
|
||||
wikilessI2pCustomRedirects: [],
|
||||
function initDefaults() {
|
||||
return new Promise(resolve => {
|
||||
fetch('/instances/data.json').then(response => response.text()).then(async data => {
|
||||
let dataJson = JSON.parse(data);
|
||||
redirects.wikiless = dataJson.wikiless;
|
||||
browser.storage.local.get('cloudflareList', async r => {
|
||||
wikilessNormalRedirectsChecks = [...redirects.wikiless.normal];
|
||||
for (const instance of r.cloudflareList) {
|
||||
let i = wikilessNormalRedirectsChecks.indexOf(instance);
|
||||
if (i > -1) wikilessNormalRedirectsChecks.splice(i, 1);
|
||||
}
|
||||
await browser.storage.local.set({
|
||||
disableWikipedia: true,
|
||||
wikipediaRedirects: redirects,
|
||||
wikipediaProtocol: "normal",
|
||||
wikilessNormalRedirectsChecks: wikilessNormalRedirectsChecks,
|
||||
wikilessTorRedirectsChecks: [...redirects.wikiless.tor],
|
||||
wikilessI2pRedirectsChecks: [...redirects.wikiless.i2p],
|
||||
wikilessNormalCustomRedirects: [],
|
||||
wikilessTorCustomRedirects: [],
|
||||
wikilessI2pCustomRedirects: [],
|
||||
})
|
||||
resolve();
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -396,25 +396,28 @@ function initInvidiousCookies(test, from) {
|
||||
}
|
||||
|
||||
function setInvidiousCookies() {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"disableYoutube",
|
||||
"youtubeProtocol",
|
||||
"youtubeFrontend",
|
||||
"invidiousNormalRedirectsChecks",
|
||||
"invidiousNormalCustomRedirects",
|
||||
"invidiousTorRedirectsChecks",
|
||||
"invidiousTorCustomRedirects",
|
||||
],
|
||||
r => {
|
||||
if (r.disableYoutube || r.youtubeFrontend != 'invidious' || r.youtubeProtocol === undefined) return;
|
||||
let checkedInstances;
|
||||
if (r.youtubeProtocol == 'normal') checkedInstances = [...r.invidiousNormalRedirectsChecks, ...r.invidiousNormalCustomRedirects]
|
||||
else if (r.youtubeProtocol == 'tor') checkedInstances = [...r.invidiousTorRedirectsChecks, ...r.invidiousTorCustomRedirects]
|
||||
for (const to of checkedInstances)
|
||||
utils.getCookiesFromStorage('invidious', to, 'PREFS');
|
||||
}
|
||||
)
|
||||
return new Promise(resolve => {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"disableYoutube",
|
||||
"youtubeProtocol",
|
||||
"youtubeFrontend",
|
||||
"invidiousNormalRedirectsChecks",
|
||||
"invidiousNormalCustomRedirects",
|
||||
"invidiousTorRedirectsChecks",
|
||||
"invidiousTorCustomRedirects",
|
||||
],
|
||||
r => {
|
||||
if (r.disableYoutube || r.youtubeFrontend != 'invidious' || r.youtubeProtocol === undefined) { resolve(); return; }
|
||||
let checkedInstances;
|
||||
if (r.youtubeProtocol == 'normal') checkedInstances = [...r.invidiousNormalRedirectsChecks, ...r.invidiousNormalCustomRedirects]
|
||||
else if (r.youtubeProtocol == 'tor') checkedInstances = [...r.invidiousTorRedirectsChecks, ...r.invidiousTorCustomRedirects]
|
||||
for (const to of checkedInstances)
|
||||
utils.getCookiesFromStorage('invidious', to, 'PREFS');
|
||||
resolve();
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
function initPipedLocalStorage(test, url, tabId) {
|
||||
|
@ -349,7 +349,7 @@ def peertube():
|
||||
myList.append('https://'+k['host'])
|
||||
|
||||
mightyList['peertube'] = myList
|
||||
print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'Peertube')
|
||||
print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'PeerTube')
|
||||
|
||||
|
||||
def isValid(url): # This code is contributed by avanitrachhadiya2155
|
||||
|
@ -49,7 +49,7 @@
|
||||
"name": "__MSG_extensionName__",
|
||||
"keyword": "libredirect",
|
||||
"favicon_url": "https://raw.githubusercontent.com/libredirect/libredirect/master/src/assets/images/libredirect-16.png",
|
||||
"search_url": "https://libredirect.invalid/?q={searchTerms}",
|
||||
"search_url": "https://search.libredirect.invalid/?q={searchTerms}",
|
||||
"encoding": "UTF-8",
|
||||
"is_default": false
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
import generalHelper from "../../assets/javascripts/helpers/general.js";
|
||||
import utils from "../../assets/javascripts/helpers/utils.js";
|
||||
|
||||
import youtubeHelper from "../../assets/javascripts/helpers/youtube/youtube.js";
|
||||
import youtubeMusicHelper from "../../assets/javascripts/helpers/youtubeMusic.js";
|
||||
import twitterHelper from "../../assets/javascripts/helpers/twitter.js";
|
||||
@ -16,7 +18,7 @@ import tiktokHelper from "../../assets/javascripts/helpers/tiktok.js";
|
||||
import sendTargetsHelper from "../../assets/javascripts/helpers/sendTargets.js";
|
||||
import peertubeHelper from "../../assets/javascripts/helpers/peertube.js";
|
||||
import lbryHelper from "../../assets/javascripts/helpers/lbry.js";
|
||||
import utils from "../../assets/javascripts/helpers/utils.js";
|
||||
|
||||
|
||||
window.browser = window.browser || window.chrome;
|
||||
|
||||
@ -35,6 +37,7 @@ browser.runtime.onInstalled.addListener(
|
||||
if (details.reason == 'install') {
|
||||
fetch('/instances/blocklist.json').then(response => response.text()).then(async data => {
|
||||
await browser.storage.local.set({ cloudflareList: JSON.parse(data) })
|
||||
generalHelper.initDefaults();
|
||||
youtubeHelper.initDefaults();
|
||||
youtubeMusicHelper.initDefaults();
|
||||
twitterHelper.initDefaults();
|
||||
@ -56,10 +59,6 @@ browser.runtime.onInstalled.addListener(
|
||||
)
|
||||
|
||||
async function wholeInit() {
|
||||
await mapsHelper.init();
|
||||
await sendTargetsHelper.init();
|
||||
await peertubeHelper.init();
|
||||
await generalHelper.init();
|
||||
}
|
||||
|
||||
let incognitoInit = false;
|
||||
@ -104,10 +103,10 @@ browser.webRequest.onBeforeRequest.addListener(
|
||||
|
||||
if (
|
||||
details.frameAncestors && details.frameAncestors.length > 0 &&
|
||||
generalHelper.isException(new URL(details.frameAncestors[0].url))
|
||||
await generalHelper.isException(new URL(details.frameAncestors[0].url))
|
||||
) newUrl = null;
|
||||
|
||||
if (generalHelper.isException(url)) newUrl = 'BYPASSTAB';
|
||||
if (await generalHelper.isException(url)) newUrl = 'BYPASSTAB';
|
||||
|
||||
if (BYPASSTABs.includes(details.tabId)) newUrl = null;
|
||||
|
||||
@ -117,7 +116,7 @@ browser.webRequest.onBeforeRequest.addListener(
|
||||
return { cancel: true };
|
||||
}
|
||||
else if (newUrl === 'BYPASSTAB') {
|
||||
console.log(`Bybassed ${details.tabId} ${url}`);
|
||||
console.log(`Bypassed ${details.tabId} ${url}`);
|
||||
if (!BYPASSTABs.includes(details.tabId)) BYPASSTABs.push(details.tabId);
|
||||
return null;
|
||||
}
|
||||
@ -180,9 +179,21 @@ async function redirectOfflineInstance(url, tabId) {
|
||||
}
|
||||
}
|
||||
let counter = 0;
|
||||
|
||||
function isAutoRedirect() {
|
||||
return new Promise(resolve => {
|
||||
browser.storage.local.get('autoRedirect',
|
||||
r => {
|
||||
if (r.autoRedirect == true) resolve(true)
|
||||
else resolve(false)
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
browser.webRequest.onResponseStarted.addListener(
|
||||
details => {
|
||||
if (!generalHelper.getAutoRedirect()) return null;
|
||||
async details => {
|
||||
if (!await isAutoRedirect()) return null;
|
||||
|
||||
if (details.type == 'main_frame' && (details.statusCode == 502 || details.statusCode == 503 || details.statusCode == 504)) {
|
||||
// if (details.type == 'main_frame' && details.statusCode >= 200) {
|
||||
@ -195,8 +206,8 @@ browser.webRequest.onResponseStarted.addListener(
|
||||
)
|
||||
|
||||
browser.webRequest.onErrorOccurred.addListener(
|
||||
details => {
|
||||
if (!generalHelper.getAutoRedirect()) return;
|
||||
async details => {
|
||||
if (!await isAutoRedirect()) return;
|
||||
if (details.type == 'main_frame') {
|
||||
const url = new URL(details.url);
|
||||
redirectOfflineInstance(url, details.tabId);
|
||||
|
@ -3,7 +3,35 @@
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<script type="module" src="incognito.js"></script>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title data-localise="__MSG_instanceIsOff__">Initializing Cookies</title>
|
||||
<link href="../stylesheets/styles.css" rel="stylesheet" />
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
height: 100vh;
|
||||
width: 100vw;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
font-size: 30px;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
div {
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div>
|
||||
<p>Initializing Cookies</p>
|
||||
</div>
|
||||
<script type="module" src="incognito.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
@ -1,30 +1,21 @@
|
||||
"use strict";
|
||||
|
||||
import youtubeHelper from "../../assets/javascripts/helpers/youtube/youtube.js";
|
||||
import twitterHelper from "../../assets/javascripts/helpers/twitter.js";
|
||||
import instagramHelper from "../../assets/javascripts/helpers/instagram.js";
|
||||
import redditHelper from "../../assets/javascripts/helpers/reddit.js";
|
||||
import searchHelper from "../../assets/javascripts/helpers/search.js";
|
||||
import translateHelper from "../../assets/javascripts/helpers/translate/translate.js";
|
||||
import mapsHelper from "../../assets/javascripts/helpers/maps.js";
|
||||
import wikipediaHelper from "../../assets/javascripts/helpers/wikipedia.js";
|
||||
import mediumHelper from "../../assets/javascripts/helpers/medium.js";
|
||||
import imgurHelper from "../../assets/javascripts/helpers/imgur.js";
|
||||
import tiktokHelper from "../../assets/javascripts/helpers/tiktok.js";
|
||||
import sendTargetsHelper from "../../assets/javascripts/helpers/sendTargets.js";
|
||||
import peertubeHelper from "../../assets/javascripts/helpers/peertube.js";
|
||||
import lbryHelper from "../../assets/javascripts/helpers/lbry.js";
|
||||
import generalHelper from "../../assets/javascripts/helpers/general.js";
|
||||
import youtubeMusicHelper from "../../assets/javascripts/helpers/youtubeMusic.js";
|
||||
|
||||
window.browser = window.browser || window.chrome;
|
||||
|
||||
async function wholeInit() {
|
||||
await youtubeMusicHelper.init();
|
||||
await mapsHelper.init();
|
||||
await sendTargetsHelper.init();
|
||||
await peertubeHelper.init();
|
||||
await generalHelper.init();
|
||||
}
|
||||
await wholeInit();
|
||||
await youtubeHelper.setInvidiousCookies();
|
||||
await translateHelper.setSimplyTranslateCookies();
|
||||
await twitterHelper.setNitterCookies();
|
||||
await wikipediaHelper.setWikilessCookies();
|
||||
await searchHelper.setSearxCookies();
|
||||
await searchHelper.setSearxngCookies();
|
||||
await redditHelper.setLibredditCookies();
|
||||
await redditHelper.setTedditCookies();
|
||||
await tiktokHelper.setProxiTokCookies();
|
||||
|
||||
window.close()
|
@ -30,7 +30,7 @@
|
||||
<ellipse cx="1682" cy="502" rx="88" ry="424"></ellipse>
|
||||
</svg><a href="../medium/medium.html" data-localise="__MSG_medium__">Medium</a>
|
||||
</div>
|
||||
<div class="title"> <img src="../../../assets/images/peertube-icon.svg"><a href="../peertube/peertube.html" data-localise="__MSG_peertube__">Peertube</a></div>
|
||||
<div class="title"> <img src="../../../assets/images/peertube-icon.svg"><a href="../peertube/peertube.html" data-localise="__MSG_peertube__">PeerTube</a></div>
|
||||
<div class="title"> <img src="../../../assets/images/lbry-icon.png"><a href="../lbry/lbry.html" data-localise="__MSG_lbry__">LBRY/Odysee</a></div>
|
||||
<div class="title">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
|
||||
@ -180,7 +180,7 @@
|
||||
<input id="medium" type="checkbox">
|
||||
</div>
|
||||
<div>
|
||||
<div> <img src="../../../assets/images/peertube-icon.svg">Peertube</div>
|
||||
<div> <img src="../../../assets/images/peertube-icon.svg">PeerTube</div>
|
||||
<input id="peertube" type="checkbox">
|
||||
</div>
|
||||
<div>
|
||||
|
@ -4,7 +4,21 @@ window.browser = window.browser || window.chrome;
|
||||
import utils from "../../../assets/javascripts/helpers/utils.js";
|
||||
import generalHelper from "../../../assets/javascripts/helpers/general.js";
|
||||
|
||||
|
||||
import youtubeHelper from "../../../assets/javascripts/helpers/youtube/youtube.js";
|
||||
import youtubeMusicHelper from "../../../assets/javascripts/helpers/youtubeMusic.js";
|
||||
import twitterHelper from "../../../assets/javascripts/helpers/twitter.js";
|
||||
import instagramHelper from "../../../assets/javascripts/helpers/instagram.js";
|
||||
import redditHelper from "../../../assets/javascripts/helpers/reddit.js";
|
||||
import searchHelper from "../../../assets/javascripts/helpers/search.js";
|
||||
import translateHelper from "../../../assets/javascripts/helpers/translate/translate.js";
|
||||
import mapsHelper from "../../../assets/javascripts/helpers/maps.js";
|
||||
import wikipediaHelper from "../../../assets/javascripts/helpers/wikipedia.js";
|
||||
import mediumHelper from "../../../assets/javascripts/helpers/medium.js";
|
||||
import imgurHelper from "../../../assets/javascripts/helpers/imgur.js";
|
||||
import tiktokHelper from "../../../assets/javascripts/helpers/tiktok.js";
|
||||
import sendTargetsHelper from "../../../assets/javascripts/helpers/sendTargets.js";
|
||||
import peertubeHelper from "../../../assets/javascripts/helpers/peertube.js";
|
||||
import lbryHelper from "../../../assets/javascripts/helpers/lbry.js";
|
||||
|
||||
let updateInstancesElement = document.getElementById("update-instances");
|
||||
updateInstancesElement.addEventListener("click", () => {
|
||||
@ -68,21 +82,41 @@ function importError() {
|
||||
|
||||
let resetSettingsElement = document.getElementById("reset-settings");
|
||||
resetSettingsElement.addEventListener("click",
|
||||
() => {
|
||||
async () => {
|
||||
console.log("reset");
|
||||
browser.storage.local.clear();
|
||||
location.reload();
|
||||
await browser.storage.local.clear();
|
||||
fetch('/instances/blocklist.json').then(response => response.text()).then(async data => {
|
||||
await browser.storage.local.set({ cloudflareList: JSON.parse(data) })
|
||||
await generalHelper.initDefaults();
|
||||
await youtubeHelper.initDefaults();
|
||||
await youtubeMusicHelper.initDefaults();
|
||||
await twitterHelper.initDefaults();
|
||||
await instagramHelper.initDefaults();
|
||||
await mapsHelper.initDefaults();
|
||||
await searchHelper.initDefaults();
|
||||
await translateHelper.initDefaults();
|
||||
await mediumHelper.initDefaults();
|
||||
await redditHelper.initDefaults();
|
||||
await wikipediaHelper.initDefaults();
|
||||
await imgurHelper.initDefaults();
|
||||
await tiktokHelper.initDefaults();
|
||||
await sendTargetsHelper.initDefaults();
|
||||
await peertubeHelper.initDefaults();
|
||||
await lbryHelper.initDefaults();
|
||||
location.reload();
|
||||
})
|
||||
}
|
||||
);
|
||||
|
||||
let autoRedirectElement = document.getElementById("auto-redirect")
|
||||
autoRedirectElement.addEventListener("change",
|
||||
event => generalHelper.setAutoRedirect(event.target.checked)
|
||||
event => browser.storage.local.set({ autoRedirect: event.target.checked })
|
||||
);
|
||||
|
||||
let themeElement = document.getElementById("theme");
|
||||
themeElement.addEventListener("change", event => {
|
||||
const value = event.target.options[theme.selectedIndex].value;
|
||||
generalHelper.setTheme(value);
|
||||
browser.storage.local.set({ theme: value });
|
||||
})
|
||||
|
||||
let nameCustomInstanceInput = document.getElementById("exceptions-custom-instance");
|
||||
@ -99,84 +133,94 @@ for (const frontend of generalHelper.allPopupFrontends)
|
||||
var index = popupFrontends.indexOf(frontend);
|
||||
if (index !== -1) popupFrontends.splice(index, 1);
|
||||
}
|
||||
generalHelper.setPopupFrontends(popupFrontends);
|
||||
browser.storage.local.set({ popupFrontends })
|
||||
}
|
||||
)
|
||||
|
||||
generalHelper.init().then(() => {
|
||||
autoRedirectElement.checked = generalHelper.getAutoRedirect();
|
||||
themeElement.value = generalHelper.getTheme();
|
||||
instanceTypeElement.addEventListener("change",
|
||||
event => {
|
||||
instanceType = event.target.options[instanceTypeElement.selectedIndex].value
|
||||
if (instanceType == 'url') {
|
||||
nameCustomInstanceInput.setAttribute("type", "url");
|
||||
nameCustomInstanceInput.setAttribute("placeholder", "https://www.google.com");
|
||||
}
|
||||
else if (instanceType == 'regex') {
|
||||
nameCustomInstanceInput.setAttribute("type", "text");
|
||||
nameCustomInstanceInput.setAttribute("placeholder", "https?:\/\/(www\.|)youtube\.com\/");
|
||||
}
|
||||
}
|
||||
)
|
||||
let exceptionsCustomInstances = generalHelper.getExceptions();
|
||||
function calcExceptionsCustomInstances() {
|
||||
document.getElementById("exceptions-custom-checklist").innerHTML =
|
||||
[...exceptionsCustomInstances.url, ...exceptionsCustomInstances.regex].map(
|
||||
(x) => `<div>
|
||||
${x}
|
||||
<button class="add" id="clear-${x}">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px"
|
||||
fill="currentColor">
|
||||
<path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z" />
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
<hr>`
|
||||
).join('\n');
|
||||
|
||||
for (const x of [...exceptionsCustomInstances.url, ...exceptionsCustomInstances.regex]) {
|
||||
document.getElementById(`clear-${x}`).addEventListener("click",
|
||||
() => {
|
||||
console.log(x);
|
||||
let index;
|
||||
index = exceptionsCustomInstances.url.indexOf(x);
|
||||
if (index > -1)
|
||||
exceptionsCustomInstances.url.splice(index, 1);
|
||||
else {
|
||||
index = exceptionsCustomInstances.regex.indexOf(x);
|
||||
browser.storage.local.get(
|
||||
[
|
||||
'theme',
|
||||
'autoRedirect',
|
||||
'exceptions'
|
||||
],
|
||||
r => {
|
||||
autoRedirectElement.checked = r.autoRedirect;
|
||||
themeElement.value = r.theme;
|
||||
instanceTypeElement.addEventListener("change",
|
||||
event => {
|
||||
instanceType = event.target.options[instanceTypeElement.selectedIndex].value
|
||||
if (instanceType == 'url') {
|
||||
nameCustomInstanceInput.setAttribute("type", "url");
|
||||
nameCustomInstanceInput.setAttribute("placeholder", "https://www.google.com");
|
||||
}
|
||||
else if (instanceType == 'regex') {
|
||||
nameCustomInstanceInput.setAttribute("type", "text");
|
||||
nameCustomInstanceInput.setAttribute("placeholder", "https?:\/\/(www\.|)youtube\.com\/");
|
||||
}
|
||||
}
|
||||
)
|
||||
let exceptionsCustomInstances = r.exceptions;
|
||||
function calcExceptionsCustomInstances() {
|
||||
document.getElementById("exceptions-custom-checklist").innerHTML =
|
||||
[...exceptionsCustomInstances.url, ...exceptionsCustomInstances.regex].map(
|
||||
(x) => `<div>
|
||||
${x}
|
||||
<button class="add" id="clear-${x}">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px"
|
||||
fill="currentColor">
|
||||
<path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z" />
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
<hr>`
|
||||
).join('\n');
|
||||
|
||||
for (const x of [...exceptionsCustomInstances.url, ...exceptionsCustomInstances.regex]) {
|
||||
document.getElementById(`clear-${x}`).addEventListener("click",
|
||||
() => {
|
||||
console.log(x);
|
||||
let index;
|
||||
index = exceptionsCustomInstances.url.indexOf(x);
|
||||
if (index > -1)
|
||||
exceptionsCustomInstances.regex.splice(index, 1);
|
||||
}
|
||||
generalHelper.setExceptions(exceptionsCustomInstances);
|
||||
calcExceptionsCustomInstances();
|
||||
});
|
||||
}
|
||||
}
|
||||
calcExceptionsCustomInstances();
|
||||
document.getElementById("custom-exceptions-instance-form").addEventListener("submit", (event) => {
|
||||
event.preventDefault();
|
||||
|
||||
let val
|
||||
if (instanceType == 'url') {
|
||||
if (nameCustomInstanceInput.validity.valid) {
|
||||
let url = new URL(nameCustomInstanceInput.value);
|
||||
val = `${url.protocol}//${url.host}`
|
||||
if (!exceptionsCustomInstances.url.includes(val)) exceptionsCustomInstances.url.push(val)
|
||||
exceptionsCustomInstances.url.splice(index, 1);
|
||||
else {
|
||||
index = exceptionsCustomInstances.regex.indexOf(x);
|
||||
if (index > -1)
|
||||
exceptionsCustomInstances.regex.splice(index, 1);
|
||||
}
|
||||
browser.storage.local.set({ exceptions: exceptionsCustomInstances })
|
||||
calcExceptionsCustomInstances();
|
||||
});
|
||||
}
|
||||
} else if (instanceType == 'regex') {
|
||||
val = nameCustomInstanceInput.value
|
||||
if (val.trim() != '' && !exceptionsCustomInstances.regex.includes(val)) exceptionsCustomInstances.regex.push(val)
|
||||
}
|
||||
if (val) {
|
||||
generalHelper.setExceptions(exceptionsCustomInstances);
|
||||
console.log("exceptionsCustomInstances", exceptionsCustomInstances)
|
||||
nameCustomInstanceInput.value = '';
|
||||
}
|
||||
calcExceptionsCustomInstances();
|
||||
})
|
||||
document.getElementById("custom-exceptions-instance-form").addEventListener("submit", (event) => {
|
||||
event.preventDefault();
|
||||
|
||||
popupFrontends = generalHelper.getPopupFrontends();
|
||||
for (const frontend of generalHelper.allPopupFrontends)
|
||||
document.getElementById(frontend).checked = popupFrontends.includes(frontend);
|
||||
})
|
||||
let val
|
||||
if (instanceType == 'url') {
|
||||
if (nameCustomInstanceInput.validity.valid) {
|
||||
let url = new URL(nameCustomInstanceInput.value);
|
||||
val = `${url.protocol}//${url.host}`
|
||||
if (!exceptionsCustomInstances.url.includes(val)) exceptionsCustomInstances.url.push(val)
|
||||
}
|
||||
} else if (instanceType == 'regex') {
|
||||
val = nameCustomInstanceInput.value
|
||||
if (val.trim() != '' && !exceptionsCustomInstances.regex.includes(val)) exceptionsCustomInstances.regex.push(val)
|
||||
}
|
||||
if (val) {
|
||||
browser.storage.local.set({ exceptions: exceptionsCustomInstances })
|
||||
nameCustomInstanceInput.value = '';
|
||||
}
|
||||
calcExceptionsCustomInstances();
|
||||
})
|
||||
|
||||
browser.storage.local.get('popupFrontends',
|
||||
r => {
|
||||
popupFrontends = r.popupFrontends;
|
||||
for (const frontend of generalHelper.allPopupFrontends)
|
||||
document.getElementById(frontend).checked = popupFrontends.includes(frontend);
|
||||
}
|
||||
)
|
||||
})
|
||||
|
@ -151,7 +151,7 @@ body.option(dir="auto")
|
||||
div
|
||||
div
|
||||
img(src="../../../assets/images/peertube-icon.svg")
|
||||
|Peertube
|
||||
|PeerTube
|
||||
input#peertube(type="checkbox")
|
||||
|
||||
div
|
||||
|
@ -31,7 +31,7 @@
|
||||
<ellipse cx="1682" cy="502" rx="88" ry="424"></ellipse>
|
||||
</svg><a href="../medium/medium.html" data-localise="__MSG_medium__">Medium</a>
|
||||
</div>
|
||||
<div class="title"> <img src="../../../assets/images/peertube-icon.svg"><a href="../peertube/peertube.html" data-localise="__MSG_peertube__">Peertube</a></div>
|
||||
<div class="title"> <img src="../../../assets/images/peertube-icon.svg"><a href="../peertube/peertube.html" data-localise="__MSG_peertube__">PeerTube</a></div>
|
||||
<div class="title"> <img src="../../../assets/images/lbry-icon.png"><a href="../lbry/lbry.html" data-localise="__MSG_lbry__">LBRY/Odysee</a></div>
|
||||
<div class="title">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
|
||||
|
@ -31,7 +31,7 @@
|
||||
<ellipse cx="1682" cy="502" rx="88" ry="424"></ellipse>
|
||||
</svg><a href="../medium/medium.html" data-localise="__MSG_medium__">Medium</a>
|
||||
</div>
|
||||
<div class="title"> <img src="../../../assets/images/peertube-icon.svg"><a href="../peertube/peertube.html" data-localise="__MSG_peertube__">Peertube</a></div>
|
||||
<div class="title"> <img src="../../../assets/images/peertube-icon.svg"><a href="../peertube/peertube.html" data-localise="__MSG_peertube__">PeerTube</a></div>
|
||||
<div class="title"> <img src="../../../assets/images/lbry-icon.png"><a href="../lbry/lbry.html" data-localise="__MSG_lbry__">LBRY/Odysee</a></div>
|
||||
<div class="title">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
|
||||
|
@ -31,7 +31,7 @@
|
||||
<ellipse cx="1682" cy="502" rx="88" ry="424"></ellipse>
|
||||
</svg><a href="../medium/medium.html" data-localise="__MSG_medium__">Medium</a>
|
||||
</div>
|
||||
<div class="title"> <img src="../../../assets/images/peertube-icon.svg"><a href="../peertube/peertube.html" data-localise="__MSG_peertube__">Peertube</a></div>
|
||||
<div class="title"> <img src="../../../assets/images/peertube-icon.svg"><a href="../peertube/peertube.html" data-localise="__MSG_peertube__">PeerTube</a></div>
|
||||
<div class="title"> <img src="../../../assets/images/lbry-icon.png"><a class="selected" href="../lbry/lbry.html" data-localise="__MSG_lbry__">LBRY/Odysee</a></div>
|
||||
<div class="title">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
|
||||
|
@ -31,7 +31,7 @@
|
||||
<ellipse cx="1682" cy="502" rx="88" ry="424"></ellipse>
|
||||
</svg><a href="../medium/medium.html" data-localise="__MSG_medium__">Medium</a>
|
||||
</div>
|
||||
<div class="title"> <img src="../../../assets/images/peertube-icon.svg"><a href="../peertube/peertube.html" data-localise="__MSG_peertube__">Peertube</a></div>
|
||||
<div class="title"> <img src="../../../assets/images/peertube-icon.svg"><a href="../peertube/peertube.html" data-localise="__MSG_peertube__">PeerTube</a></div>
|
||||
<div class="title"> <img src="../../../assets/images/lbry-icon.png"><a href="../lbry/lbry.html" data-localise="__MSG_lbry__">LBRY/Odysee</a></div>
|
||||
<div class="title">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
|
||||
|
@ -31,7 +31,7 @@
|
||||
<ellipse cx="1682" cy="502" rx="88" ry="424"></ellipse>
|
||||
</svg><a class="selected" href="../medium/medium.html" data-localise="__MSG_medium__">Medium</a>
|
||||
</div>
|
||||
<div class="title"> <img src="../../../assets/images/peertube-icon.svg"><a href="../peertube/peertube.html" data-localise="__MSG_peertube__">Peertube</a></div>
|
||||
<div class="title"> <img src="../../../assets/images/peertube-icon.svg"><a href="../peertube/peertube.html" data-localise="__MSG_peertube__">PeerTube</a></div>
|
||||
<div class="title"> <img src="../../../assets/images/lbry-icon.png"><a href="../lbry/lbry.html" data-localise="__MSG_lbry__">LBRY/Odysee</a></div>
|
||||
<div class="title">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
|
||||
|
@ -31,7 +31,7 @@
|
||||
<ellipse cx="1682" cy="502" rx="88" ry="424"></ellipse>
|
||||
</svg><a href="../medium/medium.html" data-localise="__MSG_medium__">Medium</a>
|
||||
</div>
|
||||
<div class="title"> <img src="../../../assets/images/peertube-icon.svg"><a class="selected" href="../peertube/peertube.html" data-localise="__MSG_peertube__">Peertube</a></div>
|
||||
<div class="title"> <img src="../../../assets/images/peertube-icon.svg"><a class="selected" href="../peertube/peertube.html" data-localise="__MSG_peertube__">PeerTube</a></div>
|
||||
<div class="title"> <img src="../../../assets/images/lbry-icon.png"><a href="../lbry/lbry.html" data-localise="__MSG_lbry__">LBRY/Odysee</a></div>
|
||||
<div class="title">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
|
||||
|
@ -31,7 +31,7 @@
|
||||
<ellipse cx="1682" cy="502" rx="88" ry="424"></ellipse>
|
||||
</svg><a href="../medium/medium.html" data-localise="__MSG_medium__">Medium</a>
|
||||
</div>
|
||||
<div class="title"> <img src="../../../assets/images/peertube-icon.svg"><a href="../peertube/peertube.html" data-localise="__MSG_peertube__">Peertube</a></div>
|
||||
<div class="title"> <img src="../../../assets/images/peertube-icon.svg"><a href="../peertube/peertube.html" data-localise="__MSG_peertube__">PeerTube</a></div>
|
||||
<div class="title"> <img src="../../../assets/images/lbry-icon.png"><a href="../lbry/lbry.html" data-localise="__MSG_lbry__">LBRY/Odysee</a></div>
|
||||
<div class="title">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
|
||||
|
@ -31,7 +31,7 @@
|
||||
<ellipse cx="1682" cy="502" rx="88" ry="424"></ellipse>
|
||||
</svg><a href="../medium/medium.html" data-localise="__MSG_medium__">Medium</a>
|
||||
</div>
|
||||
<div class="title"> <img src="../../../assets/images/peertube-icon.svg"><a href="../peertube/peertube.html" data-localise="__MSG_peertube__">Peertube</a></div>
|
||||
<div class="title"> <img src="../../../assets/images/peertube-icon.svg"><a href="../peertube/peertube.html" data-localise="__MSG_peertube__">PeerTube</a></div>
|
||||
<div class="title"> <img src="../../../assets/images/lbry-icon.png"><a href="../lbry/lbry.html" data-localise="__MSG_lbry__">LBRY/Odysee</a></div>
|
||||
<div class="title">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
|
||||
|
@ -31,7 +31,7 @@
|
||||
<ellipse cx="1682" cy="502" rx="88" ry="424"></ellipse>
|
||||
</svg><a href="../medium/medium.html" data-localise="__MSG_medium__">Medium</a>
|
||||
</div>
|
||||
<div class="title"> <img src="../../../assets/images/peertube-icon.svg"><a href="../peertube/peertube.html" data-localise="__MSG_peertube__">Peertube</a></div>
|
||||
<div class="title"> <img src="../../../assets/images/peertube-icon.svg"><a href="../peertube/peertube.html" data-localise="__MSG_peertube__">PeerTube</a></div>
|
||||
<div class="title"> <img src="../../../assets/images/lbry-icon.png"><a href="../lbry/lbry.html" data-localise="__MSG_lbry__">LBRY/Odysee</a></div>
|
||||
<div class="title">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
|
||||
|
@ -31,7 +31,7 @@
|
||||
<ellipse cx="1682" cy="502" rx="88" ry="424"></ellipse>
|
||||
</svg><a href="../medium/medium.html" data-localise="__MSG_medium__">Medium</a>
|
||||
</div>
|
||||
<div class="title"> <img src="../../../assets/images/peertube-icon.svg"><a href="../peertube/peertube.html" data-localise="__MSG_peertube__">Peertube</a></div>
|
||||
<div class="title"> <img src="../../../assets/images/peertube-icon.svg"><a href="../peertube/peertube.html" data-localise="__MSG_peertube__">PeerTube</a></div>
|
||||
<div class="title"> <img src="../../../assets/images/lbry-icon.png"><a href="../lbry/lbry.html" data-localise="__MSG_lbry__">LBRY/Odysee</a></div>
|
||||
<div class="title">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
|
||||
|
@ -31,7 +31,7 @@
|
||||
<ellipse cx="1682" cy="502" rx="88" ry="424"></ellipse>
|
||||
</svg><a href="../medium/medium.html" data-localise="__MSG_medium__">Medium</a>
|
||||
</div>
|
||||
<div class="title"> <img src="../../../assets/images/peertube-icon.svg"><a href="../peertube/peertube.html" data-localise="__MSG_peertube__">Peertube</a></div>
|
||||
<div class="title"> <img src="../../../assets/images/peertube-icon.svg"><a href="../peertube/peertube.html" data-localise="__MSG_peertube__">PeerTube</a></div>
|
||||
<div class="title"> <img src="../../../assets/images/lbry-icon.png"><a href="../lbry/lbry.html" data-localise="__MSG_lbry__">LBRY/Odysee</a></div>
|
||||
<div class="title">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
|
||||
|
@ -31,7 +31,7 @@
|
||||
<ellipse cx="1682" cy="502" rx="88" ry="424"></ellipse>
|
||||
</svg><a href="../medium/medium.html" data-localise="__MSG_medium__">Medium</a>
|
||||
</div>
|
||||
<div class="title"> <img src="../../../assets/images/peertube-icon.svg"><a href="../peertube/peertube.html" data-localise="__MSG_peertube__">Peertube</a></div>
|
||||
<div class="title"> <img src="../../../assets/images/peertube-icon.svg"><a href="../peertube/peertube.html" data-localise="__MSG_peertube__">PeerTube</a></div>
|
||||
<div class="title"> <img src="../../../assets/images/lbry-icon.png"><a href="../lbry/lbry.html" data-localise="__MSG_lbry__">LBRY/Odysee</a></div>
|
||||
<div class="title">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
|
||||
|
@ -31,7 +31,7 @@
|
||||
<ellipse cx="1682" cy="502" rx="88" ry="424"></ellipse>
|
||||
</svg><a href="../medium/medium.html" data-localise="__MSG_medium__">Medium</a>
|
||||
</div>
|
||||
<div class="title"> <img src="../../../assets/images/peertube-icon.svg"><a href="../peertube/peertube.html" data-localise="__MSG_peertube__">Peertube</a></div>
|
||||
<div class="title"> <img src="../../../assets/images/peertube-icon.svg"><a href="../peertube/peertube.html" data-localise="__MSG_peertube__">PeerTube</a></div>
|
||||
<div class="title"> <img src="../../../assets/images/lbry-icon.png"><a href="../lbry/lbry.html" data-localise="__MSG_lbry__">LBRY/Odysee</a></div>
|
||||
<div class="title">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
|
||||
|
@ -31,7 +31,7 @@
|
||||
<ellipse cx="1682" cy="502" rx="88" ry="424"></ellipse>
|
||||
</svg><a href="../medium/medium.html" data-localise="__MSG_medium__">Medium</a>
|
||||
</div>
|
||||
<div class="title"> <img src="../../../assets/images/peertube-icon.svg"><a href="../peertube/peertube.html" data-localise="__MSG_peertube__">Peertube</a></div>
|
||||
<div class="title"> <img src="../../../assets/images/peertube-icon.svg"><a href="../peertube/peertube.html" data-localise="__MSG_peertube__">PeerTube</a></div>
|
||||
<div class="title"> <img src="../../../assets/images/lbry-icon.png"><a href="../lbry/lbry.html" data-localise="__MSG_lbry__">LBRY/Odysee</a></div>
|
||||
<div class="title">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
|
||||
|
@ -31,7 +31,7 @@
|
||||
<ellipse cx="1682" cy="502" rx="88" ry="424"></ellipse>
|
||||
</svg><a href="../medium/medium.html" data-localise="__MSG_medium__">Medium</a>
|
||||
</div>
|
||||
<div class="title"> <img src="../../../assets/images/peertube-icon.svg"><a href="../peertube/peertube.html" data-localise="__MSG_peertube__">Peertube</a></div>
|
||||
<div class="title"> <img src="../../../assets/images/peertube-icon.svg"><a href="../peertube/peertube.html" data-localise="__MSG_peertube__">PeerTube</a></div>
|
||||
<div class="title"> <img src="../../../assets/images/lbry-icon.png"><a href="../lbry/lbry.html" data-localise="__MSG_lbry__">LBRY/Odysee</a></div>
|
||||
<div class="title">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
|
||||
|
@ -35,7 +35,7 @@
|
||||
<h4>Reddit</h4></a>
|
||||
<input id="disable-reddit" type="checkbox">
|
||||
</div>
|
||||
<div class="some-block" id="wikipedia"><a class="title" href="https://wikipedia.com"><img src="../../assets/images/wikipedia-icon.png">
|
||||
<div class="some-block" id="wikipedia"><a class="title" href="https://wikipedia.com"><img src="../../assets/images/wikipedia-icon.svg">
|
||||
<h4>Wikipedia</h4></a>
|
||||
<input id="disable-wikipedia" type="checkbox">
|
||||
</div>
|
||||
@ -48,15 +48,15 @@
|
||||
<h4>Medium</h4></a>
|
||||
<input id="disable-medium" type="checkbox">
|
||||
</div>
|
||||
<div class="some-block" id="peertube"><a class="title" href="https://peertube.com"><img src="../../assets/images/peertube-icon.png">
|
||||
<h4>Peertube</h4></a>
|
||||
<div class="some-block" id="peertube"><a class="title" href="https://peertube.com"><img src="../../assets/images/peertube-icon.svg">
|
||||
<h4>PeerTube</h4></a>
|
||||
<input id="disable-peertube" type="checkbox">
|
||||
</div>
|
||||
<div class="some-block" id="lbry"><a class="title" href="https://lbry.com"><img src="../../assets/images/lbry-icon.png">
|
||||
<h4>LBRY</h4></a>
|
||||
<input id="disable-lbry" type="checkbox">
|
||||
</div>
|
||||
<div class="some-block" id="search"><a class="title" href="https://libredirect.invalid">
|
||||
<div class="some-block" id="search"><a class="title" href="https://search.libredirect.invalid">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
|
||||
<path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"></path>
|
||||
</svg>
|
||||
@ -77,34 +77,35 @@
|
||||
<h4>Maps</h4></a>
|
||||
<input id="disable-osm" type="checkbox">
|
||||
</div>
|
||||
<div class="some-block" id="sendTargets"><a class="title" href="https://send.invalid">
|
||||
<div class="some-block" id="sendTargets"><a class="title" href="https://send.libredirect.invalid">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor">
|
||||
<path d="M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM14 13v4h-4v-4H7l5-5 5 5h-3z"></path>
|
||||
</svg>
|
||||
<h4>Send Files</h4></a>
|
||||
<input id="disable-sendTargets" type="checkbox">
|
||||
</div>
|
||||
<hr>
|
||||
<div class="some-block" id="change_instance_div"><a class="title button" id="change_instance">
|
||||
<h4>Change Instance</h4>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="26px" viewBox="0 0 24 24" width="26px" fill="currentColor">
|
||||
<path d="M12 4V1L8 5l4 4V6c3.31 0 6 2.69 6 6 0 1.01-.25 1.97-.7 2.8l1.46 1.46C19.54 15.03 20 13.57 20 12c0-4.42-3.58-8-8-8zm0 14c-3.31 0-6-2.69-6-6 0-1.01.25-1.97.7-2.8L5.24 7.74C4.46 8.97 4 10.43 4 12c0 4.42 3.58 8 8 8v3l4-4-4-4v3z"></path>
|
||||
</svg>
|
||||
<h4>Change Instance</h4></a></div>
|
||||
<div class="some-block"><a class="title button" id="more-options">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="26px" viewBox="0 0 24 24" width="26px" fill="currentColor">
|
||||
<path d="M19.14,12.94c0.04-0.3,0.06-0.61,0.06-0.94c0-0.32-0.02-0.64-0.07-0.94l2.03-1.58c0.18-0.14,0.23-0.41,0.12-0.61 l-1.92-3.32c-0.12-0.22-0.37-0.29-0.59-0.22l-2.39,0.96c-0.5-0.38-1.03-0.7-1.62-0.94L14.4,2.81c-0.04-0.24-0.24-0.41-0.48-0.41 h-3.84c-0.24,0-0.43,0.17-0.47,0.41L9.25,5.35C8.66,5.59,8.12,5.92,7.63,6.29L5.24,5.33c-0.22-0.08-0.47,0-0.59,0.22L2.74,8.87 C2.62,9.08,2.66,9.34,2.86,9.48l2.03,1.58C4.84,11.36,4.8,11.69,4.8,12s0.02,0.64,0.07,0.94l-2.03,1.58 c-0.18,0.14-0.23,0.41-0.12,0.61l1.92,3.32c0.12,0.22,0.37,0.29,0.59,0.22l2.39-0.96c0.5,0.38,1.03,0.7,1.62,0.94l0.36,2.54 c0.05,0.24,0.24,0.41,0.48,0.41h3.84c0.24,0,0.44-0.17,0.47-0.41l0.36-2.54c0.59-0.24,1.13-0.56,1.62-0.94l2.39,0.96 c0.22,0.08,0.47,0,0.59-0.22l1.92-3.32c0.12-0.22,0.07-0.47-0.12-0.61L19.14,12.94z M12,15.6c-1.98,0-3.6-1.62-3.6-3.6 s1.62-3.6,3.6-3.6s3.6,1.62,3.6,3.6S13.98,15.6,12,15.6z"></path>
|
||||
</svg>
|
||||
<h4>Settings</h4></a></div>
|
||||
</svg></a></div>
|
||||
<div class="some-block" id="copy_raw_div" title="Copy the original redirected link"> <a class="title button" id="copy_raw">
|
||||
<h4>Copy Raw</h4>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor">
|
||||
<path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path>
|
||||
</svg>
|
||||
<h4>Copy Raw</h4></a></div>
|
||||
</svg></a></div>
|
||||
<div class="some-block" id="unify_div" title="Unify cookies across all selected instances"><a class="title button" id="unify">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor">
|
||||
<rect fill="none" height="24" width="24"></rect>
|
||||
<path d="M18,2H9C7.9,2,7,2.9,7,4v12c0,1.1,0.9,2,2,2h9c1.1,0,2-0.9,2-2V4C20,2.9,19.1,2,18,2z M18,16H9V4h9V16z M3,15v-2h2v2H3z M3,9.5h2v2H3V9.5z M10,20h2v2h-2V20z M3,18.5v-2h2v2H3z M5,22c-1.1,0-2-0.9-2-2h2V22z M8.5,22h-2v-2h2V22z M13.5,22L13.5,22l0-2h2 v0C15.5,21.1,14.6,22,13.5,22z M5,6L5,6l0,2H3v0C3,6.9,3.9,6,5,6z"></path>
|
||||
</svg>
|
||||
<h4>Unify Settings</h4></a></div>
|
||||
<h4>Unify Settings</h4>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor">
|
||||
<path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"></path>
|
||||
</svg></a></div>
|
||||
<div class="some-block"><a class="title button" id="more-options">
|
||||
<h4>Settings</h4>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="26px" viewBox="0 0 24 24" width="26px" fill="currentColor">
|
||||
<path d="M19.14,12.94c0.04-0.3,0.06-0.61,0.06-0.94c0-0.32-0.02-0.64-0.07-0.94l2.03-1.58c0.18-0.14,0.23-0.41,0.12-0.61 l-1.92-3.32c-0.12-0.22-0.37-0.29-0.59-0.22l-2.39,0.96c-0.5-0.38-1.03-0.7-1.62-0.94L14.4,2.81c-0.04-0.24-0.24-0.41-0.48-0.41 h-3.84c-0.24,0-0.43,0.17-0.47,0.41L9.25,5.35C8.66,5.59,8.12,5.92,7.63,6.29L5.24,5.33c-0.22-0.08-0.47,0-0.59,0.22L2.74,8.87 C2.62,9.08,2.66,9.34,2.86,9.48l2.03,1.58C4.84,11.36,4.8,11.69,4.8,12s0.02,0.64,0.07,0.94l-2.03,1.58 c-0.18,0.14-0.23,0.41-0.12,0.61l1.92,3.32c0.12,0.22,0.37,0.29,0.59,0.22l2.39-0.96c0.5,0.38,1.03,0.7,1.62,0.94l0.36,2.54 c0.05,0.24,0.24,0.41,0.48,0.41h3.84c0.24,0,0.44-0.17,0.47-0.41l0.36-2.54c0.59-0.24,1.13-0.56,1.62-0.94l2.39,0.96 c0.22,0.08,0.47,0,0.59-0.22l1.92-3.32c0.12-0.22,0.07-0.47-0.12-0.61L19.14,12.94z M12,15.6c-1.98,0-3.6-1.62-3.6-3.6 s1.62-3.6,3.6-3.6s3.6,1.62,3.6,3.6S13.98,15.6,12,15.6z"></path>
|
||||
</svg></a></div>
|
||||
<div class="space"></div>
|
||||
<script type="module" src="../options/init.js"></script>
|
||||
<script type="module" src="./popup.js"></script>
|
||||
<script src="../../assets/javascripts/localise.js"></script>
|
||||
|
@ -98,14 +98,14 @@ utils.unify(true).then(r => {
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
document.getElementById("more-options").addEventListener("click", () => browser.runtime.openOptionsPage());
|
||||
|
||||
generalHelper.init().then(() => {
|
||||
let popupFrontends = generalHelper.getPopupFrontends();
|
||||
for (const frontend of generalHelper.allPopupFrontends)
|
||||
if (!popupFrontends.includes(frontend))
|
||||
document.getElementById(frontend).classList.add("hide")
|
||||
else
|
||||
document.getElementById(frontend).classList.remove("hide")
|
||||
});
|
||||
browser.storage.local.get(
|
||||
'popupFrontends',
|
||||
r => {
|
||||
for (const frontend of generalHelper.allPopupFrontends)
|
||||
if (!r.popupFrontends.includes(frontend))
|
||||
document.getElementById(frontend).classList.add("hide")
|
||||
else
|
||||
document.getElementById(frontend).classList.remove("hide")
|
||||
});
|
@ -52,7 +52,7 @@ html(lang="en")
|
||||
|
||||
#wikipedia.some-block
|
||||
a.title(href="https://wikipedia.com")
|
||||
img(src="../../assets/images/wikipedia-icon.png")
|
||||
img(src="../../assets/images/wikipedia-icon.svg")
|
||||
h4 Wikipedia
|
||||
input#disable-wikipedia(type="checkbox")
|
||||
|
||||
@ -64,8 +64,8 @@ html(lang="en")
|
||||
|
||||
#peertube.some-block
|
||||
a.title(href="https://peertube.com")
|
||||
img(src="../../assets/images/peertube-icon.png")
|
||||
h4 Peertube
|
||||
img(src="../../assets/images/peertube-icon.svg")
|
||||
h4 PeerTube
|
||||
input#disable-peertube(type="checkbox")
|
||||
|
||||
#lbry.some-block
|
||||
@ -75,7 +75,7 @@ html(lang="en")
|
||||
input#disable-lbry(type="checkbox")
|
||||
|
||||
#search.some-block
|
||||
a.title(href="https://libredirect.invalid")
|
||||
a.title(href="https://search.libredirect.invalid")
|
||||
+search
|
||||
h4 Search
|
||||
input#disable-search(type="checkbox")
|
||||
@ -93,30 +93,34 @@ html(lang="en")
|
||||
input#disable-osm(type="checkbox")
|
||||
|
||||
#sendTargets.some-block
|
||||
a.title(href="https://send.invalid")
|
||||
a.title(href="https://send.libredirect.invalid")
|
||||
+send
|
||||
h4 Send Files
|
||||
input#disable-sendTargets(type="checkbox")
|
||||
|
||||
hr
|
||||
|
||||
#change_instance_div.some-block
|
||||
a#change_instance.title.button
|
||||
+change_instance
|
||||
h4 Change Instance
|
||||
|
||||
.some-block
|
||||
a#more-options.title.button
|
||||
+settings
|
||||
h4 Settings
|
||||
+change_instance
|
||||
|
||||
#copy_raw_div.some-block(title="Copy the original redirected link")
|
||||
a#copy_raw.title.button
|
||||
+copy_raw
|
||||
h4 Copy Raw
|
||||
+copy_raw
|
||||
|
||||
#unify_div.some-block(title="Unify cookies across all selected instances")
|
||||
a#unify.title.button
|
||||
+unify
|
||||
h4 Unify Settings
|
||||
+unify
|
||||
|
||||
.some-block
|
||||
a#more-options.title.button
|
||||
h4 Settings
|
||||
+settings
|
||||
|
||||
.space
|
||||
|
||||
script(type="module" src="../options/init.js")
|
||||
script(type="module" src="./popup.js")
|
||||
|
@ -1,5 +1,5 @@
|
||||
body {
|
||||
width: 240px;
|
||||
width: 230px;
|
||||
min-height: auto;
|
||||
}
|
||||
|
||||
@ -9,4 +9,15 @@ html, body {
|
||||
|
||||
.hide {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.button {
|
||||
display: flex;
|
||||
margin: 0 auto;
|
||||
justify-content: space-between;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.space {
|
||||
height: 10px;
|
||||
}
|
@ -39,6 +39,5 @@ mixin general
|
||||
|
||||
|
||||
mixin unify
|
||||
svg(xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor")
|
||||
rect(fill="none" height="24" width="24")
|
||||
path(d="M18,2H9C7.9,2,7,2.9,7,4v12c0,1.1,0.9,2,2,2h9c1.1,0,2-0.9,2-2V4C20,2.9,19.1,2,18,2z M18,16H9V4h9V16z M3,15v-2h2v2H3z M3,9.5h2v2H3V9.5z M10,20h2v2h-2V20z M3,18.5v-2h2v2H3z M5,22c-1.1,0-2-0.9-2-2h2V22z M8.5,22h-2v-2h2V22z M13.5,22L13.5,22l0-2h2 v0C15.5,21.1,14.6,22,13.5,22z M5,6L5,6l0,2H3v0C3,6.9,3.9,6,5,6z")
|
||||
svg(xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor")
|
||||
path(d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z")
|
@ -44,7 +44,7 @@ mixin links(service)
|
||||
|
||||
.title
|
||||
img(src="../../../assets/images/peertube-icon.svg")
|
||||
a(href="../peertube/peertube.html" data-localise="__MSG_peertube__" class=service == "peertube" ? "selected" : "") Peertube
|
||||
a(href="../peertube/peertube.html" data-localise="__MSG_peertube__" class=service == "peertube" ? "selected" : "") PeerTube
|
||||
|
||||
.title
|
||||
img(src="../../../assets/images/lbry-icon.png")
|
||||
|
Loading…
x
Reference in New Issue
Block a user