diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index de199a2..c63281a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -29,7 +29,6 @@ jobs: run: | git config --local user.email "action@github.com" git config --local user.name "GitHub Action" - git add -f src/instances git commit -am "update instances" || : - name: push changes uses: ad-m/github-push-action@v0.6.0 diff --git a/.gitignore b/.gitignore index 7696212..f6fc62d 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,3 @@ web-ext-artifacts/ nod node_modules package-lock.json -src/instances/blacklist.json -src/instances/data.json diff --git a/src/assets/javascripts/imdb.js b/src/assets/javascripts/imdb.js index de1293a..681f675 100644 --- a/src/assets/javascripts/imdb.js +++ b/src/assets/javascripts/imdb.js @@ -41,7 +41,9 @@ let libremdbNormalRedirectsChecks, libremdbNormalCustomRedirects, libremdbTorRedirectsChecks, - libremdbTorCustomRedirects; + libremdbTorCustomRedirects, + libremdbI2pCustomRedirects, + libremdbLokiCustomRedirects; function init() { return new Promise(async resolve => { @@ -55,6 +57,8 @@ function init() { "libremdbNormalCustomRedirects", "libremdbTorRedirectsChecks", "libremdbTorCustomRedirects", + "libremdbI2pCustomRedirects", + "libremdbLokiCustomRedirects" ], r => { disableImdb = r.disableImdb; @@ -65,6 +69,8 @@ function init() { libremdbNormalCustomRedirects = r.libremdbNormalCustomRedirects; libremdbTorRedirectsChecks = r.libremdbTorRedirectsChecks; libremdbTorCustomRedirects = r.libremdbTorCustomRedirects; + libremdbI2pCustomRedirects = r.libremdbI2pCustomRedirects; + libremdbLokiCustomRedirects = r.libremdbLokiCustomRedirects; resolve(); } ) @@ -86,7 +92,9 @@ function redirect(url, type, initiator, disableOverride) { if (!targets.some(rx => rx.test(url.href))) return; let instancesList = []; - if (protocol == 'tor') instancesList = [...libremdbTorRedirectsChecks, ...libremdbTorCustomRedirects]; + if (protocol == 'loki') instancesList = [...libremdbLokiCustomRedirects]; + else if (protocol == 'i2p') instancesList = [...libremdbI2pCustomRedirects]; + else if (protocol == 'tor') instancesList = [...libremdbTorRedirectsChecks, ...libremdbTorCustomRedirects]; if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { instancesList = [...libremdbNormalRedirectsChecks, ...libremdbNormalCustomRedirects]; } @@ -104,7 +112,9 @@ function reverse(url) { ...imdbRedirects.libremdb.normal, ...imdbRedirects.libremdb.tor, ...libremdbNormalCustomRedirects, - ...libremdbTorCustomRedirects + ...libremdbTorCustomRedirects, + ...libremdbI2pCustomRedirects, + ...libremdbLokiCustomRedirects ]; if (!all.includes(protocolHost)) { resolve(); return; } @@ -123,11 +133,15 @@ function switchInstance(url, disableOverride) { ...libremdbNormalCustomRedirects, ...libremdbTorCustomRedirects, + ...libremdbI2pCustomRedirects, + ...libremdbLokiCustomRedirects ]; if (!all.includes(protocolHost)) { resolve(); return; } let instancesList = []; - if (protocol == 'tor') instancesList = [...libremdbTorRedirectsChecks, ...libremdbTorCustomRedirects]; + if (protocol == 'loki') instancesList = [...libremdbLokiCustomRedirects]; + else if (protocol == 'i2p') instancesList = [...libremdbI2pCustomRedirects]; + else if (protocol == 'tor') instancesList = [...libremdbTorRedirectsChecks, ...libremdbTorCustomRedirects]; if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { instancesList = [...libremdbNormalRedirectsChecks, ...libremdbNormalCustomRedirects]; } @@ -157,6 +171,10 @@ function initDefaults() { libremdbTorRedirectsChecks: [...redirects.libremdb.tor], libremdbTorCustomRedirects: [], + + libremdbI2pCustomRedirects: [], + + libremdbLokiCustomRedirects: [] }, () => resolve()); }); }) diff --git a/src/assets/javascripts/imgur.js b/src/assets/javascripts/imgur.js index dafebb9..f76679a 100644 --- a/src/assets/javascripts/imgur.js +++ b/src/assets/javascripts/imgur.js @@ -57,7 +57,8 @@ let rimgoTorRedirectsChecks, rimgoTorCustomRedirects, rimgoI2pRedirectsChecks, - rimgoI2pCustomRedirects; + rimgoI2pCustomRedirects, + rimgoLokiCustomRedirects; function init() { return new Promise(async resolve => { @@ -73,6 +74,7 @@ function init() { "rimgoTorCustomRedirects", "rimgoI2pRedirectsChecks", "rimgoI2pCustomRedirects", + "rimgoLokiCustomRedirects" ], r => { disableImgur = r.disableImgur; @@ -85,6 +87,7 @@ function init() { rimgoTorCustomRedirects = r.rimgoTorCustomRedirects; rimgoI2pRedirectsChecks = r.rimgoI2pRedirectsChecks; rimgoI2pCustomRedirects = r.rimgoI2pCustomRedirects; + rimgoLokiCustomRedirects = r.rimgoLokiCustomRedirects; resolve(); } ) @@ -108,6 +111,7 @@ function all() { ...rimgoNormalCustomRedirects, ...rimgoTorCustomRedirects, ...rimgoI2pCustomRedirects, + ...rimgoLokiCustomRedirects ]; } @@ -120,8 +124,9 @@ function redirect(url, type, initiator, disableOverride) { if (url.pathname.includes("delete/")) return; let instancesList = []; - if (protocol == 'i2p') instancesList = [...rimgoI2pCustomRedirects, ...rimgoI2pRedirectsChecks]; - if (protocol == 'tor') instancesList = [...rimgoTorRedirectsChecks, ...rimgoTorCustomRedirects]; + if (protocol == 'loki') instancesList = [...rimgoLokiCustomRedirects]; + else if (protocol == 'i2p') instancesList = [...rimgoI2pCustomRedirects, ...rimgoI2pRedirectsChecks]; + else if (protocol == 'tor') instancesList = [...rimgoTorRedirectsChecks, ...rimgoTorCustomRedirects]; if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { instancesList = [...rimgoNormalRedirectsChecks, ...rimgoNormalCustomRedirects]; } @@ -147,8 +152,9 @@ function switchInstance(url, disableOverride) { let protocolHost = utils.protocolHost(url); if (!all().includes(protocolHost)) { resolve(); return; } let instancesList = []; - if (protocol == 'i2p') instancesList = [...rimgoI2pCustomRedirects, ...rimgoI2pRedirectsChecks]; - if (protocol == 'tor') instancesList = [...rimgoTorRedirectsChecks, ...rimgoTorCustomRedirects]; + if (protocol == 'loki') instancesList = [...rimgoLokiCustomRedirects]; + else if (protocol == 'i2p') instancesList = [...rimgoI2pCustomRedirects, ...rimgoI2pRedirectsChecks]; + else if (protocol == 'tor') instancesList = [...rimgoTorRedirectsChecks, ...rimgoTorCustomRedirects]; if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { instancesList = [...rimgoNormalRedirectsChecks, ...rimgoNormalCustomRedirects]; } @@ -187,6 +193,8 @@ function initDefaults() { rimgoI2pRedirectsChecks: [...redirects.rimgo.i2p], rimgoI2pCustomRedirects: [], + + rimgoLokiCustomRedirects: [] }, () => resolve()); }); }); diff --git a/src/assets/javascripts/instagram.js b/src/assets/javascripts/instagram.js index e1c4061..7c816b4 100644 --- a/src/assets/javascripts/instagram.js +++ b/src/assets/javascripts/instagram.js @@ -41,7 +41,9 @@ let bibliogramNormalRedirectsChecks, bibliogramTorRedirectsChecks, bibliogramNormalCustomRedirects, - bibliogramTorCustomRedirects; + bibliogramTorCustomRedirects, + bibliogramI2pCustomRedirects, + bibliogramLokiCustomRedirects; function init() { return new Promise(async resolve => { @@ -55,6 +57,8 @@ function init() { "bibliogramTorRedirectsChecks", "bibliogramNormalCustomRedirects", "bibliogramTorCustomRedirects", + "bibliogramI2pCustomRedirects", + "bibliogramLokiCustomRedirects" ], r => { disableInstagram = r.disableInstagram; @@ -65,6 +69,8 @@ function init() { bibliogramTorRedirectsChecks = r.bibliogramTorRedirectsChecks; bibliogramNormalCustomRedirects = r.bibliogramNormalCustomRedirects; bibliogramTorCustomRedirects = r.bibliogramTorCustomRedirects; + bibliogramI2pCustomRedirects = r.bibliogramI2pCustomRedirects; + bibliogramLokiCustomRedirects = r.bibliogramLokiCustomRedirects resolve(); } ) @@ -80,6 +86,8 @@ function all() { ...instagramRedirects.bibliogram.tor, ...bibliogramNormalCustomRedirects, ...bibliogramTorCustomRedirects, + ...bibliogramI2pCustomRedirects, + ...bibliogramLokiCustomRedirects ] } @@ -93,7 +101,9 @@ function redirect(url, type, initiator, disableOverride) { if (bypassPaths.some(rx => rx.test(url.pathname))) return; let instancesList = []; - if (protocol == 'tor') instancesList = [...bibliogramTorRedirectsChecks, ...bibliogramTorCustomRedirects]; + if (protocol == 'loki') instancesList = [...bibliogramLokiCustomRedirects]; + else if (protocol == 'i2p') instancesList = [...bibliogramI2pCustomRedirects]; + else if (protocol == 'tor') instancesList = [...bibliogramTorRedirectsChecks, ...bibliogramTorCustomRedirects]; if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { instancesList = [...bibliogramNormalRedirectsChecks, ...bibliogramNormalCustomRedirects]; } @@ -129,7 +139,9 @@ function switchInstance(url, disableOverride) { if (!all().includes(protocolHost)) { resolve(); return; } let instancesList = []; - if (protocol == 'tor') instancesList = [...bibliogramTorRedirectsChecks, ...bibliogramTorCustomRedirects]; + if (protocol == 'loki') instancesList = [...bibliogramLokiCustomRedirects]; + else if (protocol == 'i2p') instancesList = [...bibliogramI2pCustomRedirects]; + else if (protocol == 'tor') instancesList = [...bibliogramTorRedirectsChecks, ...bibliogramTorCustomRedirects]; if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { instancesList = [...bibliogramNormalRedirectsChecks, ...bibliogramNormalCustomRedirects]; } @@ -164,7 +176,11 @@ function initDefaults() { bibliogramTorRedirectsChecks: [], bibliogramNormalCustomRedirects: [...redirects.bibliogram.tor], - bibliogramTorCustomRedirects: [] + bibliogramTorCustomRedirects: [], + + bibliogramI2pCustomRedirects: [], + + bibliogramLokiCustomRedirects: [] }) resolve(); } diff --git a/src/assets/javascripts/lbry.js b/src/assets/javascripts/lbry.js index 7a298fb..6e2bd35 100644 --- a/src/assets/javascripts/lbry.js +++ b/src/assets/javascripts/lbry.js @@ -34,11 +34,14 @@ function setRedirects(val) { let disableLbryTargets, protocol, + protocolFallback, lbryTargetsRedirects, librarianNormalRedirectsChecks, librarianNormalCustomRedirects, librarianTorRedirectsChecks, - librarianTorCustomRedirects; + librarianTorCustomRedirects, + librarianI2pCustomRedirects, + librarianLokiCustomRedirects; function init() { return new Promise(resolve => { @@ -46,20 +49,26 @@ function init() { [ "disableLbryTargets", "protocol", + "protocolFallback", "lbryTargetsRedirects", "librarianNormalRedirectsChecks", "librarianNormalCustomRedirects", "librarianTorRedirectsChecks", "librarianTorCustomRedirects", + "librarianI2pCustomRedirects", + "librarianLokiCustomRedirects" ], r => { disableLbryTargets = r.disableLbryTargets; protocol = r.protocol; + protocolFallback = r.protocolFallback; lbryTargetsRedirects = r.lbryTargetsRedirects; librarianNormalRedirectsChecks = r.librarianNormalRedirectsChecks; librarianNormalCustomRedirects = r.librarianNormalCustomRedirects; librarianTorRedirectsChecks = r.librarianTorRedirectsChecks; librarianTorCustomRedirects = r.librarianTorCustomRedirects; + librarianI2pCustomRedirects = r.librarianI2pCustomRedirects; + librarianLokiCustomRedirects = r.librarianLokiCustomRedirects; resolve(); } ) @@ -74,6 +83,8 @@ function all() { ...redirects.librarian.tor, ...librarianNormalCustomRedirects, ...librarianTorCustomRedirects, + ...librarianI2pCustomRedirects, + ...librarianLokiCustomRedirects ]; } @@ -85,7 +96,9 @@ function switchInstance(url, disableOverride) { if (!all().includes(protocolHost)) { resolve(); return; } let instancesList = []; - if (protocol == 'tor') instancesList = [...librarianTorRedirectsChecks, ...librarianTorCustomRedirects]; + if (protocol == 'loki') instancesList = [...librarianLokiCustomRedirects]; + else if (protocol == 'i2p') instancesList = [...librarianI2pCustomRedirects]; + else if (protocol == 'tor') instancesList = [...librarianTorRedirectsChecks, ...librarianTorCustomRedirects]; if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { instancesList = [...librarianNormalRedirectsChecks, ...librarianNormalCustomRedirects]; } @@ -106,7 +119,9 @@ function redirect(url, type, initiator, disableOverride) { if (type != "main_frame") return; let instancesList = []; - if (protocol == 'tor') instancesList = [...librarianTorRedirectsChecks, ...librarianTorCustomRedirects]; + if (protocol == 'loki') instancesList = [...librarianLokiCustomRedirects]; + else if (protocol == 'i2p') instancesList = [...librarianI2pCustomRedirects]; + else if (protocol == 'tor') instancesList = [...librarianTorRedirectsChecks, ...librarianTorCustomRedirects]; if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { instancesList = [...librarianNormalRedirectsChecks, ...librarianNormalCustomRedirects]; } @@ -133,6 +148,10 @@ function initDefaults() { librarianTorRedirectsChecks: [...redirects.librarian.tor], librarianTorCustomRedirects: [], + + librarianI2pCustomRedirects: [], + + librarianLokiCustomRedirects: [] }, () => resolve()); }); }) diff --git a/src/assets/javascripts/maps.js b/src/assets/javascripts/maps.js index 57add6f..7714e17 100644 --- a/src/assets/javascripts/maps.js +++ b/src/assets/javascripts/maps.js @@ -14,7 +14,10 @@ let redirects = { 'facil': { "normal": [ "https://facilmap.org" - ] + ], + "tor": [], + "i2p": [], + "loki": [] } }; @@ -22,22 +25,37 @@ let redirects = { let disableMaps, mapsFrontend, + protocol, + protocolFallback, facilNormalRedirectsChecks, - facilNormalCustomRedirects; + facilNormalCustomRedirects, + facilTorCustomRedirects, + facilI2pCustomRedirects, + facilLokiCustomRedirects; function init() { browser.storage.local.get( [ "disableMaps", "mapsFrontend", + "protocol", + "protocolFallback", "facilNormalRedirectsChecks", "facilNormalCustomRedirects", + "facilTorCustomRedirects", + "facilI2pCustomRedirects", + "facilLokiCustomRedirects" ], r => { disableMaps = r.disableMaps; mapsFrontend = r.mapsFrontend; + protocol = r.protocol; + protocolFallback = r.protocolFallback; facilNormalRedirectsChecks = r.facilNormalRedirectsChecks; facilNormalCustomRedirects = r.facilNormalCustomRedirects; + facilTorCustomRedirects = r.facilTorCustomRedirects; + facilI2pCustomRedirects = r.facilI2pCustomRedirects; + facilLokiCustomRedirects = r.facilLokiCustomRedirects; } ) } @@ -89,7 +107,15 @@ function redirect(url, initiator) { let randomInstance; if (mapsFrontend == 'osm') randomInstance = utils.getRandomInstance(redirects.osm.normal); - if (mapsFrontend == 'facil') randomInstance = utils.getRandomInstance([...facilNormalRedirectsChecks, ...facilNormalCustomRedirects]); + + if (mapsFrontend == 'facil') { + if (protocol == 'loki') randomInstance = utils.getRandomInstance(...facilLokiCustomRedirects); + else if (protocol == 'i2p') randomInstance = utils.getRandomInstance(...facilI2pCustomRedirects); + else if (protocol == 'tor') randomInstance = utils.getRandomInstance(...facilTorCustomRedirects); + if ((randomInstance == "" && protocolFallback) || protocol == 'normal') { + randomInstance = utils.getRandomInstance([...facilNormalRedirectsChecks, ...facilNormalCustomRedirects]); + } + } let mapCentre = "#"; let prefs = {}; @@ -201,6 +227,12 @@ async function initDefaults() { mapsRedirects: redirects, facilNormalRedirectsChecks: [...redirects.facil.normal], facilNormalCustomRedirects: [], + + facilTorCustomRedirects: [], + + facilI2pCustomRedirects: [], + + facilLokiCustomRedirects: [] }, () => resolve()) ) diff --git a/src/assets/javascripts/medium.js b/src/assets/javascripts/medium.js index 37a8a3d..d4c81ba 100644 --- a/src/assets/javascripts/medium.js +++ b/src/assets/javascripts/medium.js @@ -61,6 +61,8 @@ let scribeNormalCustomRedirects, scribeTorRedirectsChecks, scribeTorCustomRedirects, + scribeI2pCustomRedirects, + scribeLokiCustomRedirects, protocol, protocolFallback; @@ -74,6 +76,8 @@ function init() { "scribeNormalCustomRedirects", "scribeTorRedirectsChecks", "scribeTorCustomRedirects", + "scribeI2pCustomRedirects", + "scribeLokiCustomRedirects", "protocol", "protocolFallback" ], @@ -84,6 +88,8 @@ function init() { scribeNormalCustomRedirects = r.scribeNormalCustomRedirects; scribeTorRedirectsChecks = r.scribeTorRedirectsChecks; scribeTorCustomRedirects = r.scribeTorCustomRedirects; + scribeI2pCustomRedirects = r.scribeI2pCustomRedirects; + scribeLokiCustomRedirects = r.scribeLokiCustomRedirects; protocol = r.protocol; protocolFallback = r.protocolFallback; resolve(); @@ -105,13 +111,17 @@ function redirect(url, type, initiator, disableOverride) { ...mediumRedirects.scribe.tor, ...scribeNormalCustomRedirects, ...scribeTorCustomRedirects, + ...scribeI2pCustomRedirects, + ...scribeLokiCustomRedirects ].includes(initiator.origin))) return; if (!targets.some(rx => rx.test(url.host))) return; if (/^\/(@[a-zA-Z.]{0,}(\/|)$)/.test(url.pathname)) return; let instancesList = []; - if (protocol == 'tor') instancesList = [...scribeTorRedirectsChecks, ...scribeTorCustomRedirects]; + if (protocol == 'loki') instancesList = [...scribeLokiCustomRedirects]; + else if (protocol == 'i2p') instancesList = [...scribeI2pCustomRedirects]; + else if (protocol == 'tor') instancesList = [...scribeTorRedirectsChecks, ...scribeTorCustomRedirects]; if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { instancesList = [...scribeNormalRedirectsChecks, ...scribeNormalCustomRedirects]; } @@ -132,11 +142,15 @@ function switchInstance(url, disableOverride) { ...scribeNormalCustomRedirects, ...scribeTorCustomRedirects, + ...scribeI2pCustomRedirects, + ...scribeLokiCustomRedirects ]; if (!all.includes(protocolHost)) { resolve(); return; } let instancesList = []; - if (protocol == 'tor') instancesList = [...scribeTorRedirectsChecks, ...scribeTorCustomRedirects]; + if (protocol == 'loki') instancesList = [...scribeLokiCustomRedirects]; + else if (protocol == 'i2p') instancesList = [...scribeI2pCustomRedirects]; + else if (protocol == 'tor') instancesList = [...scribeTorRedirectsChecks, ...scribeTorCustomRedirects]; if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { instancesList = [...scribeNormalRedirectsChecks, ...scribeNormalCustomRedirects]; } @@ -173,6 +187,10 @@ function initDefaults() { scribeTorRedirectsChecks: [...redirects.scribe.tor], scribeTorCustomRedirects: [], + + scribeI2pCustomRedirects: [], + + scribeLokiCustomRedirects: [] }, () => resolve()) }) }) diff --git a/src/assets/javascripts/peertube.js b/src/assets/javascripts/peertube.js index b397f97..8299394 100644 --- a/src/assets/javascripts/peertube.js +++ b/src/assets/javascripts/peertube.js @@ -39,6 +39,8 @@ let simpleertubeNormalCustomRedirects, simpleertubeTorRedirectsChecks, simpleertubeTorCustomRedirects, + simpleertubeI2pCustomRedirects, + simpleertubeLokiCustomRedirects, peerTubeTargets, protocol, protocolFallback; @@ -53,6 +55,8 @@ function init() { "simpleertubeNormalCustomRedirects", "simpleertubeTorRedirectsChecks", "simpleertubeTorCustomRedirects", + "simpleertubeI2pCustomRedirects", + "simpleertubeLokiCustomRedirects", "peerTubeTargets", "protocol", "protocolFallback" @@ -64,6 +68,8 @@ function init() { simpleertubeNormalCustomRedirects = r.simpleertubeNormalCustomRedirects; simpleertubeTorRedirectsChecks = r.simpleertubeTorRedirectsChecks; simpleertubeTorCustomRedirects = r.simpleertubeTorCustomRedirects; + simpleertubeI2pCustomRedirects = r.simpleertubeI2pCustomRedirects; + simpleertubeLokiCustomRedirects = r.simpleertubeLokiCustomRedirects; peerTubeTargets = r.peerTubeTargets; protocol = r.protocol; protocolFallback = r.protocolFallback; @@ -82,6 +88,8 @@ function all() { ...redirects.simpleertube.tor, ...simpleertubeNormalCustomRedirects, ...simpleertubeTorCustomRedirects, + ...simpleertubeI2pCustomRedirects, + ...simpleertubeLokiCustomRedirects ]; } @@ -93,7 +101,9 @@ function redirect(url, type, initiator, disableOverride) { if (type != "main_frame") return; let instancesList = []; - if (protocol == 'tor') instancesList = [...simpleertubeTorRedirectsChecks, ...simpleertubeTorCustomRedirects]; + if (protocol == 'loki') instancesList = [...simpleertubeLokiCustomRedirects]; + else if (protocol == 'i2p') instancesList = [...simpleertubeI2pCustomRedirects]; + else if (protocol == 'tor') instancesList = [...simpleertubeTorRedirectsChecks, ...simpleertubeTorCustomRedirects]; if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { instancesList = [...simpleertubeNormalRedirectsChecks, ...simpleertubeNormalCustomRedirects]; } @@ -112,7 +122,9 @@ function switchInstance(url, disableOverride) { if (!all().includes(protocolHost)) { resolve(); return; } let instancesList = []; - if (protocol == 'tor') instancesList = [...simpleertubeTorRedirectsChecks, ...simpleertubeTorCustomRedirects]; + if (protocol == 'loki') instancesList = [...simpleertubeLokiCustomRedirects]; + else if (protocol == 'i2p') instancesList = [...simpleertubeI2pCustomRedirects]; + else if (protocol == 'tor') instancesList = [...simpleertubeTorRedirectsChecks, ...simpleertubeTorCustomRedirects]; if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { instancesList = [...simpleertubeNormalRedirectsChecks, ...simpleertubeNormalCustomRedirects]; } @@ -145,7 +157,11 @@ function initDefaults() { simpleertubeNormalCustomRedirects: [], simpleertubeTorRedirectsChecks: [...redirects.simpleertube.tor], - simpleertubeTorCustomRedirects: [] + simpleertubeTorCustomRedirects: [], + + simpleertubeI2pCustomRedirects: [], + + simpleertubeLokiCustomRedirects: [] }, () => resolve()); }) }) diff --git a/src/assets/javascripts/quora.js b/src/assets/javascripts/quora.js index aa90736..db2cff8 100644 --- a/src/assets/javascripts/quora.js +++ b/src/assets/javascripts/quora.js @@ -41,7 +41,9 @@ let quetreNormalRedirectsChecks, quetreNormalCustomRedirects, quetreTorRedirectsChecks, - quetreTorCustomRedirects; + quetreTorCustomRedirects, + quetreI2pCustomRedirects, + quetreLokiCustomRedirects; function init() { return new Promise(async resolve => { @@ -55,6 +57,8 @@ function init() { "quetreNormalCustomRedirects", "quetreTorRedirectsChecks", "quetreTorCustomRedirects", + "quetreI2pCustomRedirects", + "quetreLokiCustomRedirects" ], r => { disableQuora = r.disableQuora; @@ -65,6 +69,8 @@ function init() { quetreNormalCustomRedirects = r.quetreNormalCustomRedirects; quetreTorRedirectsChecks = r.quetreTorRedirectsChecks; quetreTorCustomRedirects = r.quetreTorCustomRedirects; + quetreI2pCustomRedirects = r.quetreI2pCustomRedirects; + quetreLokiCustomRedirects = r.quetreLokiCustomRedirects; resolve(); } ) @@ -86,7 +92,9 @@ function redirect(url, type, initiator, disableOverride) { if (!targets.some(rx => rx.test(url.href))) return; let instancesList = []; - if (protocol == 'tor') instancesList = [...quetreTorRedirectsChecks, ...quetreTorCustomRedirects]; + if (protocol == 'loki') instancesList = [...quetreLokiCustomRedirects]; + else if (protocol == 'i2p') instancesList = [...quetreI2pCustomRedirects]; + else if (protocol == 'tor') instancesList = [...quetreTorRedirectsChecks, ...quetreTorCustomRedirects]; if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { instancesList = [...quetreNormalRedirectsChecks, ...quetreNormalCustomRedirects]; } @@ -104,7 +112,9 @@ function reverse(url) { ...quoraRedirects.quetre.normal, ...quoraRedirects.quetre.tor, ...quetreNormalCustomRedirects, - ...quetreTorCustomRedirects + ...quetreTorCustomRedirects, + ...quetreI2pCustomRedirects, + ...quetreLokiCustomRedirects ]; if (!all.includes(protocolHost)) { resolve(); return; } @@ -123,11 +133,15 @@ function switchInstance(url, disableOverride) { ...quetreNormalCustomRedirects, ...quetreTorCustomRedirects, + ...quetreI2pCustomRedirects, + ...quetreLokiCustomRedirects ]; if (!all.includes(protocolHost)) { resolve(); return; } let instancesList = []; - if (protocol == 'tor') instancesList = [...quetreTorRedirectsChecks, ...quetreTorCustomRedirects]; + if (protocol == 'loki') instancesList = [...quetreLokiCustomRedirects]; + else if (protocol == 'i2p') instancesList = [...quetreI2pCustomRedirects]; + else if (protocol == 'tor') instancesList = [...quetreTorRedirectsChecks, ...quetreTorCustomRedirects]; if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { instancesList = [...quetreNormalRedirectsChecks, ...quetreNormalCustomRedirects]; } @@ -158,6 +172,10 @@ function initDefaults() { quetreTorRedirectsChecks: [...redirects.quetre.tor], quetreTorCustomRedirects: [], + + quetreI2pCustomRedirects: [], + + quetreLokiCustomRedirects: [] }, () => resolve()); }); }) diff --git a/src/assets/javascripts/reddit.js b/src/assets/javascripts/reddit.js index f43d88d..510ec46 100644 --- a/src/assets/javascripts/reddit.js +++ b/src/assets/javascripts/reddit.js @@ -43,14 +43,19 @@ let redditFrontend, redditRedirects, protocol, + protocolFallback, libredditNormalRedirectsChecks, libredditNormalCustomRedirects, libredditTorRedirectsChecks, libredditTorCustomRedirects, + libredditI2pCustomRedirects, + libredditLokiCustomRedirects, tedditNormalRedirectsChecks, tedditNormalCustomRedirects, tedditTorRedirectsChecks, - tedditTorCustomRedirects; + tedditTorCustomRedirects, + tedditI2pCustomRedirects, + tedditLokiCustomRedirects; function init() { return new Promise(resolve => { @@ -60,28 +65,38 @@ function init() { "redditFrontend", "redditRedirects", "protocol", + "protocolFallback", "libredditNormalRedirectsChecks", "libredditNormalCustomRedirects", "libredditTorRedirectsChecks", "libredditTorCustomRedirects", + "libredditI2pCustomRedirects", + "libredditLokiCustomRedirects", "tedditNormalRedirectsChecks", "tedditNormalCustomRedirects", "tedditTorRedirectsChecks", "tedditTorCustomRedirects", + "tedditI2pCustomRedirects", + "tedditLokiCustomRedirects" ], r => { disableReddit = r.disableReddit; redditFrontend = r.redditFrontend; redditRedirects = r.redditRedirects; protocol = r.protocol; + protocolFallback = r.protocolFallback; libredditNormalRedirectsChecks = r.libredditNormalRedirectsChecks; libredditNormalCustomRedirects = r.libredditNormalCustomRedirects; libredditTorRedirectsChecks = r.libredditTorRedirectsChecks; libredditTorCustomRedirects = r.libredditTorCustomRedirects; + libredditI2pCustomRedirects = r.libredditI2pCustomRedirects; + libredditLokiCustomRedirects = r.libredditLokiCustomRedirects; tedditNormalRedirectsChecks = r.tedditNormalRedirectsChecks; tedditNormalCustomRedirects = r.tedditNormalCustomRedirects; tedditTorRedirectsChecks = r.tedditTorRedirectsChecks; tedditTorCustomRedirects = r.tedditTorCustomRedirects; + tedditI2pCustomRedirects = r.tedditI2pCustomRedirects; + tedditLokiCustomRedirects = r.tedditLokiCustomRedirects; resolve(); } ) @@ -100,12 +115,18 @@ function initLibredditCookies(test, from) { ...libredditTorRedirectsChecks, ...libredditNormalCustomRedirects, ...libredditTorCustomRedirects, + ...libredditI2pCustomRedirects, + ...libredditLokiCustomRedirects ].includes(protocolHost)) { resolve(); return; } if (!test) { - let checkedInstances; - if (protocol == 'normal') checkedInstances = [...libredditNormalRedirectsChecks, ...libredditNormalCustomRedirects]; + let checkedInstances = []; + if (protocol == 'loki') checkedInstances = [...libredditLokiCustomRedirects]; + else if (protocol == 'i2p') checkedInstances = [...libredditI2pCustomRedirects]; else if (protocol == 'tor') checkedInstances = [...libredditTorRedirectsChecks, ...libredditTorCustomRedirects]; + if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') { + checkedInstances = [...libredditNormalRedirectsChecks, ...libredditNormalCustomRedirects]; + } await utils.copyCookie('libreddit', from, checkedInstances, "theme"); await utils.copyCookie('libreddit', from, checkedInstances, "front_page"); await utils.copyCookie('libreddit', from, checkedInstances, "layout"); @@ -127,9 +148,13 @@ function pasteLibredditCookies() { return new Promise(async resolve => { await init(); if (disableReddit || redditFrontend != 'libreddit' || protocol === undefined) { resolve(); return; } - let checkedInstances; - if (protocol == 'normal') checkedInstances = [...libredditNormalRedirectsChecks, ...libredditNormalCustomRedirects] - else if (protocol == 'tor') checkedInstances = [...libredditTorRedirectsChecks, ...libredditTorCustomRedirects] + let checkedInstances = []; + if (protocol == 'loki') checkedInstances = [...libredditLokiCustomRedirects]; + else if (protocol == 'i2p') checkedInstances = [...libredditI2pCustomRedirects]; + else if (protocol == 'tor') checkedInstances = [...libredditTorRedirectsChecks, ...libredditTorCustomRedirects]; + if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') { + checkedInstances = [...libredditNormalRedirectsChecks, ...libredditNormalCustomRedirects]; + } utils.getCookiesFromStorage('libreddit', checkedInstances, "theme"); utils.getCookiesFromStorage('libreddit', checkedInstances, "front_page"); utils.getCookiesFromStorage('libreddit', checkedInstances, "layout"); @@ -155,12 +180,19 @@ function initTedditCookies(test, from) { ...tedditTorRedirectsChecks, ...tedditNormalCustomRedirects, ...tedditTorCustomRedirects, + ...tedditI2pCustomRedirects, + ...tedditI2pCustomRedirects + ].includes(protocolHost)) resolve(); if (!test) { - let checkedInstances; - if (protocol == 'normal') checkedInstances = [...tedditNormalRedirectsChecks, ...tedditNormalCustomRedirects] - else if (protocol == 'tor') checkedInstances = [...tedditTorRedirectsChecks, ...tedditTorCustomRedirects] + let checkedInstances = []; + if (protocol == 'loki') checkedInstances = [...tedditLokiCustomRedirects]; + else if (protocol == 'i2p') checkedInstances = [...tedditI2pCustomRedirects]; + else if (protocol == 'tor') checkedInstances = [...tedditTorRedirectsChecks, ...tedditTorCustomRedirects]; + if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') { + checkedInstances = [...tedditNormalRedirectsChecks, ...tedditNormalCustomRedirects]; + } await utils.copyCookie('teddit', from, checkedInstances, 'collapse_child_comments') await utils.copyCookie('teddit', from, checkedInstances, 'domain_instagram') await utils.copyCookie('teddit', from, checkedInstances, 'domain_twitter') @@ -182,9 +214,13 @@ function pasteTedditCookies() { return new Promise(async resolve => { await init(); if (disableReddit || redditFrontend != 'teddit' || protocol === undefined) { resolve(); return; } - let checkedInstances; - if (protocol == 'normal') checkedInstances = [...tedditNormalRedirectsChecks, ...tedditNormalCustomRedirects] - else if (protocol == 'tor') checkedInstances = [...tedditTorRedirectsChecks, ...tedditTorCustomRedirects] + let checkedInstances = []; + if (protocol == 'loki') checkedInstances = [...tedditLokiCustomRedirects]; + else if (protocol == 'i2p') checkedInstances = [...tedditI2pCustomRedirects]; + else if (protocol == 'tor') checkedInstances = [...tedditTorRedirectsChecks, ...tedditTorCustomRedirects]; + if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') { + checkedInstances = [...tedditNormalRedirectsChecks, ...tedditNormalCustomRedirects]; + } utils.getCookiesFromStorage('teddit', checkedInstances, 'collapse_child_comments') utils.getCookiesFromStorage('teddit', checkedInstances, 'domain_instagram') utils.getCookiesFromStorage('teddit', checkedInstances, 'domain_twitter') @@ -209,8 +245,12 @@ function all() { ...redditRedirects.teddit.tor, ...libredditNormalCustomRedirects, ...libredditTorCustomRedirects, + ...libredditI2pCustomRedirects, + ...libredditLokiCustomRedirects, ...tedditNormalCustomRedirects, ...tedditTorCustomRedirects, + ...tedditI2pCustomRedirects, + ...tedditLokiCustomRedirects ]; } @@ -235,14 +275,22 @@ function redirect(url, type, initiator, disableOverride) { let libredditInstancesList = []; let tedditInstancesList = []; - if (protocol == 'tor') { - libredditInstancesList = [...libredditTorRedirectsChecks, ...libredditTorCustomRedirects]; - tedditInstancesList = [...tedditTorRedirectsChecks, ...tedditTorCustomRedirects]; - } - if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { - libredditInstancesList = [...libredditNormalRedirectsChecks, ...libredditNormalCustomRedirects]; - tedditInstancesList = [...tedditNormalRedirectsChecks, ...tedditNormalCustomRedirects]; - } + if (protocol == 'loki') { + libredditInstancesList = [...libredditLokiCustomRedirects]; + tedditInstancesList = [...tedditLokiCustomRedirects]; + } + else if (protocol == 'i2p') { + libredditInstancesList = [...libredditI2pCustomRedirects]; + tedditInstancesList = [...tedditI2pCustomRedirects]; + } + else if (protocol == 'tor') { + libredditInstancesList = [...libredditTorRedirectsChecks, ...libredditTorCustomRedirects]; + tedditInstancesList = [...tedditTorRedirectsChecks, ...tedditTorCustomRedirects]; + } + if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { + libredditInstancesList = [...libredditNormalRedirectsChecks, ...libredditNormalCustomRedirects]; + tedditInstancesList = [...tedditNormalRedirectsChecks, ...tedditNormalCustomRedirects]; + } if (url.host === "i.redd.it") { if (redditFrontend == 'teddit') { @@ -299,7 +347,9 @@ function switchInstance(url, disableOverride) { if (!all().includes(protocolHost)) { resolve(); return; } let instancesList = []; if (redditFrontend == 'libreddit') { - if (protocol == 'tor') instancesList = [...libredditTorRedirectsChecks, ...libredditTorCustomRedirects]; + if (protocol == 'loki') instancesList = [...libredditLokiCustomRedirects]; + else if (protocol == 'i2p') instancesList = [...libredditI2pCustomRedirects]; + else if (protocol == 'tor') instancesList = [...libredditTorRedirectsChecks, ...libredditTorCustomRedirects]; if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { instancesList = [...libredditNormalRedirectsChecks, ...libredditNormalCustomRedirects]; } @@ -309,7 +359,9 @@ function switchInstance(url, disableOverride) { ].includes(protocolHost)) url.pathname = url.pathname.replace("/pics/w:null_", "/img/"); } else if (redditFrontend == 'teddit') { - if (protocol == 'tor') instancesList = [...tedditTorRedirectsChecks, ...tedditTorCustomRedirects]; + if (protocol == 'loki') instancesList = [...tedditLokiCustomRedirects]; + else if (protocol == 'i2p') instancesList = [...tedditI2pCustomRedirects]; + else if (protocol == 'tor') instancesList = [...tedditTorRedirectsChecks, ...tedditTorCustomRedirects]; if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { instancesList = [...tedditNormalRedirectsChecks, ...tedditNormalCustomRedirects]; } @@ -359,11 +411,19 @@ function initDefaults() { libredditTorRedirectsChecks: [...redirects.libreddit.tor], libredditTorCustomRedirects: [], + libredditI2pCustomRedirects: [], + + libredditLokiCustomRedirects: [], + tedditNormalRedirectsChecks: tedditNormalRedirectsChecks, tedditNormalCustomRedirects: [], tedditTorRedirectsChecks: [...redirects.teddit.tor], tedditTorCustomRedirects: [], + + tedditI2pCustomRedirects: [], + + tedditLokiCustomRedirects: [] }, () => resolve()); }); }); diff --git a/src/assets/javascripts/reuters.js b/src/assets/javascripts/reuters.js index ee4f227..aaae5d1 100644 --- a/src/assets/javascripts/reuters.js +++ b/src/assets/javascripts/reuters.js @@ -18,6 +18,21 @@ for (let i = 0; i < frontends.length; i++) { } } +function setRedirects(val) { + browser.storage.local.get('cloudflareBlackList', r => { + redirects.neuters = val; + neutersNormalRedirectsChecks = [...redirects.neuters.normal]; + for (const instance of r.cloudflareBlackList) { + const a = neutersNormalRedirectsChecks.indexOf(instance); + if (a > -1) neutersNormalRedirectsChecks.splice(a, 1); + } + browser.storage.local.set({ + neutersRedirects: redirects, + neutersNormalRedirectsChecks + }) + }) +} + let disableReuters, protocol, @@ -26,7 +41,9 @@ let neutersNormalRedirectsChecks, neutersNormalCustomRedirects, neutersTorRedirectsChecks, - neutersTorCustomRedirects; + neutersTorCustomRedirects, + neutersI2pCustomRedirects, + neutersLokiCustomRedirects; function init() { return new Promise(async resolve => { @@ -40,6 +57,8 @@ function init() { "neutersNormalCustomRedirects", "neutersTorRedirectsChecks", "neutersTorCustomRedirects", + "neutersI2pCustomRedirects", + "neutersLokiCustomRedirects" ], r => { disableReuters = r.disableReuters; @@ -50,6 +69,8 @@ function init() { neutersNormalCustomRedirects = r.neutersNormalCustomRedirects; neutersTorRedirectsChecks = r.neutersTorRedirectsChecks; neutersTorCustomRedirects = r.neutersTorCustomRedirects; + neutersI2pCustomRedirects = r.neutersI2pCustomRedirects; + neutersLokiCustomRedirects = r.neutersLokiCustomRedirects; resolve(); } ) @@ -70,7 +91,9 @@ function redirect(url, type, initiator, disableOverride) { if (!targets.some(rx => rx.test(url.href))) return; let instancesList = []; - if (protocol == 'tor') instancesList = [...neutersTorRedirectsChecks, ...neutersTorCustomRedirects]; + if (protocol == 'loki') instancesList = [...neutersLokiCustomRedirects]; + else if (protocol == 'i2p') instancesList = [...neutersI2pCustomRedirects]; + else if (protocol == 'tor') instancesList = [...neutersTorRedirectsChecks, ...neutersTorCustomRedirects]; if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { instancesList = [...neutersNormalRedirectsChecks, ...neutersNormalCustomRedirects]; } @@ -103,11 +126,16 @@ function initDefaults() { neutersTorRedirectsChecks: [...redirects.neuters.tor], neutersTorCustomRedirects: [], + + neutersI2pCustomRedirects: [], + + neutersLokiCustomRedirects: [] }, () => resolve()); }); } export default { + setRedirects, redirect, initDefaults }; diff --git a/src/assets/javascripts/search.js b/src/assets/javascripts/search.js index 6653d2b..571df3c 100644 --- a/src/assets/javascripts/search.js +++ b/src/assets/javascripts/search.js @@ -90,24 +90,28 @@ let whoogleTorCustomRedirects, whoogleI2pRedirectsChecks, whoogleI2pCustomRedirects, + whoogleLokiCustomRedirects, searxNormalRedirectsChecks, searxNormalCustomRedirects, searxTorRedirectsChecks, searxTorCustomRedirects, searxI2pRedirectsChecks, searxI2pCustomRedirects, + searxLokiCustomRedirects, searxngNormalRedirectsChecks, searxngNormalCustomRedirects, searxngTorRedirectsChecks, searxngTorCustomRedirects, searxngI2pRedirectsChecks, searxngI2pCustomRedirects, + searxngLokiCustomRedirects, librexNormalRedirectsChecks, librexNormalCustomRedirects, librexTorRedirectsChecks, librexTorCustomRedirects, librexI2pRedirectsChecks, - librexI2pCustomRedirects; + librexI2pCustomRedirects, + librexLokiCustomRedirects; function init() { return new Promise(async resolve => { @@ -124,24 +128,28 @@ function init() { "whoogleTorCustomRedirects", "whoogleI2pRedirectsChecks", "whoogleI2pCustomRedirects", + "whoogleLokiCustomRedirects", "searxNormalRedirectsChecks", "searxNormalCustomRedirects", "searxTorRedirectsChecks", "searxTorCustomRedirects", "searxI2pRedirectsChecks", "searxI2pCustomRedirects", + "searxLokiCustomRedirects", "searxngNormalRedirectsChecks", "searxngNormalCustomRedirects", "searxngTorRedirectsChecks", "searxngTorCustomRedirects", "searxngI2pRedirectsChecks", "searxngI2pCustomRedirects", + "searxngLokiCustomRedirects", "librexNormalRedirectsChecks", "librexNormalCustomRedirects", "librexTorRedirectsChecks", "librexTorCustomRedirects", "librexI2pRedirectsChecks", - "librexI2pCustomRedirects" + "librexI2pCustomRedirects", + "librexLokiCustomRedirects" ], r => { disableSearch = r.disableSearch; @@ -155,24 +163,28 @@ function init() { whoogleTorCustomRedirects = r.whoogleTorCustomRedirects; whoogleI2pRedirectsChecks = r.whoogleI2pRedirectsChecks; whoogleI2pCustomRedirects = r.whoogleI2pCustomRedirects; + whoogleLokiCustomRedirects = r.whoogleLokiCustomRedirects; searxNormalRedirectsChecks = r.searxNormalRedirectsChecks; searxNormalCustomRedirects = r.searxNormalCustomRedirects; searxTorRedirectsChecks = r.searxTorRedirectsChecks; searxTorCustomRedirects = r.searxTorCustomRedirects; searxI2pRedirectsChecks = r.searxI2pRedirectsChecks; searxI2pCustomRedirects = r.searxI2pCustomRedirects; + searxLokiCustomRedirects = r.searxLokiCustomRedirects; searxngNormalRedirectsChecks = r.searxngNormalRedirectsChecks; searxngNormalCustomRedirects = r.searxngNormalCustomRedirects; searxngTorRedirectsChecks = r.searxngTorRedirectsChecks; searxngTorCustomRedirects = r.searxngTorCustomRedirects; searxngI2pRedirectsChecks = r.searxngI2pRedirectsChecks; searxngI2pCustomRedirects = r.searxngI2pCustomRedirects; + searxngLokiCustomRedirects = r.searxngLokiCustomRedirects; librexNormalRedirectsChecks = r.librexNormalRedirectsChecks; librexNormalCustomRedirects = r.librexNormalCustomRedirects; librexTorRedirectsChecks = r.librexTorRedirectsChecks; librexTorCustomRedirects = r.librexTorCustomRedirects; librexI2pRedirectsChecks = r.librexI2pRedirectsChecks; librexI2pCustomRedirects = r.librexI2pCustomRedirects; + librexLokiCustomRedirects = r.librexLokiCustomRedirects; resolve(); } ) @@ -193,12 +205,14 @@ function initSearxCookies(test, from) { ...searxTorCustomRedirects, ...searxI2pRedirectsChecks, ...searxI2pCustomRedirects, + ...searxLokiCustomRedirects ].includes(protocolHost)) { resolve(); return; } if (!test) { let checkedInstances = []; - if (protocol == 'i2p') checkedInstances = [...searxI2pCustomRedirects, ...searxI2pRedirectsChecks]; - if (protocol == 'tor') checkedInstances = [...searxTorRedirectsChecks, ...searxTorCustomRedirects]; + if (protocol == 'loki') checkedInstances = [...searxLokiCustomRedirects]; + else if (protocol == 'i2p') checkedInstances = [...searxI2pCustomRedirects, ...searxI2pRedirectsChecks]; + else if (protocol == 'tor') checkedInstances = [...searxTorRedirectsChecks, ...searxTorCustomRedirects]; if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') { checkedInstances = [...searxNormalRedirectsChecks, ...searxNormalCustomRedirects]; } @@ -229,8 +243,9 @@ function pasteSearxCookies() { await init(); if (disableSearch || searchFrontend != 'searx') { resolve(); return; } let checkedInstances = []; - if (protocol == 'i2p') checkedInstances = [...searxI2pCustomRedirects, ...searxI2pRedirectsChecks]; - if (protocol == 'tor') checkedInstances = [...searxTorRedirectsChecks, ...searxTorCustomRedirects]; + if (protocol == 'loki') checkedInstances = [...searxLokiCustomRedirects]; + else if (protocol == 'i2p') checkedInstances = [...searxI2pCustomRedirects, ...searxI2pRedirectsChecks]; + else if (protocol == 'tor') checkedInstances = [...searxTorRedirectsChecks, ...searxTorCustomRedirects]; if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') { checkedInstances = [...searxNormalRedirectsChecks, ...searxNormalCustomRedirects]; } @@ -266,12 +281,14 @@ function initSearxngCookies(test, from) { ...searxngTorCustomRedirects, ...searxngI2pRedirectsChecks, ...searxngI2pCustomRedirects, + ...searxngLokiCustomRedirects, ].includes(protocolHost)) { resolve(); return; } if (!test) { let checkedInstances = []; - if (protocol == 'i2p') checkedInstances = [...searxngI2pCustomRedirects, ...searxngI2pRedirectsChecks]; - if (protocol == 'tor') checkedInstances = [...searxngTorRedirectsChecks, ...searxngTorCustomRedirects]; + if (protocol == 'loki') checkedInstances = [...searxngLokiCustomRedirects]; + else if (protocol == 'i2p') checkedInstances = [...searxngI2pCustomRedirects, ...searxngI2pRedirectsChecks]; + else if (protocol == 'tor') checkedInstances = [...searxngTorRedirectsChecks, ...searxngTorCustomRedirects]; if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') { checkedInstances = [...searxngNormalRedirectsChecks, ...searxngNormalCustomRedirects]; } @@ -304,8 +321,9 @@ function pasteSearxngCookies() { await init(); if (disableSearch || searchFrontend != 'searxng', protocol === undefined) { resolve(); return; } let checkedInstances = []; - if (protocol == 'i2p') checkedInstances = [...searxngI2pCustomRedirects, ...searxngI2pRedirectsChecks]; - if (protocol == 'tor') checkedInstances = [...searxngTorRedirectsChecks, ...searxngTorCustomRedirects]; + if (protocol == 'loki') checkedInstances = [...searxngLokiCustomRedirects]; + else if (protocol == 'i2p') checkedInstances = [...searxngI2pCustomRedirects, ...searxngI2pRedirectsChecks]; + else if (protocol == 'tor') checkedInstances = [...searxngTorRedirectsChecks, ...searxngTorCustomRedirects]; if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') { checkedInstances = [...searxngNormalRedirectsChecks, ...searxngNormalCustomRedirects]; } @@ -343,12 +361,14 @@ function initLibrexCookies(test, from) { ...librexTorCustomRedirects, ...librexI2pRedirectsChecks, ...librexI2pCustomRedirects, + ...librexLokiCustomRedirects ].includes(protocolHost)) { resolve(); return; } if(!test) { let checkedInstances = []; - if (protocol == 'i2p') checkedInstances = [...librexI2pCustomRedirects, ...librexI2pRedirectsChecks]; - if (protocol == 'tor') checkedInstances = [...librexTorRedirectsChecks, ...librexTorCustomRedirects]; + if (protocol == 'loki') checkedInstances = [...librexLokiCustomRedirects]; + else if (protocol == 'i2p') checkedInstances = [...librexI2pCustomRedirects, ...librexI2pRedirectsChecks]; + else if (protocol == 'tor') checkedInstances = [...librexTorRedirectsChecks, ...librexTorCustomRedirects]; if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') { checkedInstances = [...librexNormalRedirectsChecks, ...librexNormalCustomRedirects]; } @@ -370,8 +390,9 @@ function pasteLibrexCookies() { await init(); if (disableSearch || searchFrontend != 'librex', protocol === undefined) { resolve(); return; } let checkedInstances = []; - if (protocol == 'i2p') checkedInstances = [...librexI2pCustomRedirects, ...librexI2pRedirectsChecks]; - if (protocol == 'tor') checkedInstances = [...librexTorRedirectsChecks, ...librexTorCustomRedirects]; + if (protocol == 'loki') checkedInstances = [...librexLokiCustomRedirects]; + else if (protocol == 'i2p') checkedInstances = [...librexI2pCustomRedirects, ...librexI2pRedirectsChecks]; + else if (protocol == 'tor') checkedInstances = [...librexTorRedirectsChecks, ...librexTorCustomRedirects]; if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') { checkedInstances = [...librexNormalRedirectsChecks, ...librexNormalCustomRedirects]; } @@ -396,8 +417,9 @@ function redirect(url, disableOverride) { let path; if (searchFrontend == 'searx') { let instancesList = []; - if (protocol == 'i2p') instancesList = [...searxI2pCustomRedirects, ...searxI2pRedirectsChecks]; - if (protocol == 'tor') instancesList = [...searxTorRedirectsChecks, ...searxTorCustomRedirects]; + if (protocol == 'loki') instancesList = [...searxLokiCustomRedirects]; + else if (protocol == 'i2p') instancesList = [...searxI2pCustomRedirects, ...searxI2pRedirectsChecks]; + else if (protocol == 'tor') instancesList = [...searxTorRedirectsChecks, ...searxTorCustomRedirects]; if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { instancesList = [...searxNormalRedirectsChecks, ...searxNormalCustomRedirects]; } @@ -408,8 +430,9 @@ function redirect(url, disableOverride) { } else if (searchFrontend == 'searxng') { let instancesList = []; - if (protocol == 'i2p') instancesList = [...searxngI2pCustomRedirects, ...searxngI2pRedirectsChecks]; - if (protocol == 'tor') instancesList = [...searxngTorRedirectsChecks, ...searxngTorCustomRedirects]; + if (protocol == 'loki') instancesList = [...searxngLokiCustomRedirects]; + else if (protocol == 'i2p') instancesList = [...searxngI2pCustomRedirects, ...searxngI2pRedirectsChecks]; + else if (protocol == 'tor') instancesList = [...searxngTorRedirectsChecks, ...searxngTorCustomRedirects]; if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { instancesList = [...searxngNormalRedirectsChecks, ...searxngNormalCustomRedirects]; } @@ -420,8 +443,9 @@ function redirect(url, disableOverride) { } else if (searchFrontend == 'whoogle') { let instancesList = []; - if (protocol == 'i2p') instancesList = [...whoogleI2pCustomRedirects, ...whoogleI2pRedirectsChecks]; - if (protocol == 'tor') instancesList = [...whoogleTorRedirectsChecks, ...whoogleTorCustomRedirects]; + if (protocol == 'loki') instancesList = [...whoogleLokiCustomRedirects]; + else if (protocol == 'i2p') instancesList = [...whoogleI2pCustomRedirects, ...whoogleI2pRedirectsChecks]; + else if (protocol == 'tor') instancesList = [...whoogleTorRedirectsChecks, ...whoogleTorCustomRedirects]; if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { instancesList = [...whoogleNormalRedirectsChecks, ...whoogleNormalCustomRedirects]; } @@ -432,8 +456,9 @@ function redirect(url, disableOverride) { } else if (searchFrontend == 'librex') { let instancesList = []; - if (protocol == 'i2p') instancesList = [...librexI2pCustomRedirects, ...librexI2pRedirectsChecks]; - if (protocol == 'tor') instancesList = [...librexTorRedirectsChecks, ...librexTorCustomRedirects]; + if (protocol == 'loki') instancesList = [...librexLokiCustomRedirects]; + else if (protocol == 'i2p') instancesList = [...librexI2pCustomRedirects, ...librexI2pRedirectsChecks]; + else if (protocol == 'tor') instancesList = [...librexTorRedirectsChecks, ...librexTorCustomRedirects]; if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { instancesList = [...librexNormalRedirectsChecks, ...librexNormalCustomRedirects]; } @@ -487,23 +512,33 @@ function switchInstance(url, disableOverride) { ...searxNormalCustomRedirects, ...searxTorCustomRedirects, ...searxI2pCustomRedirects, + ...searxLokiCustomRedirects, ...searxngNormalCustomRedirects, ...searxngTorCustomRedirects, ...searxngI2pCustomRedirects, + ...searxngLokiCustomRedirects, ...whoogleNormalCustomRedirects, ...whoogleTorCustomRedirects, ...whoogleI2pCustomRedirects, + ...whoogleLokiCustomRedirects, ...librexNormalCustomRedirects, ...librexTorCustomRedirects, ...librexI2pCustomRedirects, + ...librexLokiCustomRedirects ].includes(protocolHost)) { resolve(); return; } let instancesList; - if (protocol == 'tor') { + if (protocol == 'loki') { + if (searchFrontend == 'searx') instancesList = [...searxLokiCustomRedirects]; + else if (searchFrontend == 'searxng') instancesList = [...searxngLokiCustomRedirects]; + else if (searchFrontend == 'whoogle') instancesList = [...whoogleLokiCustomRedirects]; + else if (searchFrontend == 'librex') instancesList = [...librexLokiCustomRedirects]; + } + else if (protocol == 'tor') { if (searchFrontend == 'searx') instancesList = [...searxTorRedirectsChecks, ...searxTorCustomRedirects]; else if (searchFrontend == 'searxng') instancesList = [...searxngTorRedirectsChecks, ...searxngTorCustomRedirects]; else if (searchFrontend == 'whoogle') instancesList = [...whoogleTorRedirectsChecks, ...whoogleTorCustomRedirects]; @@ -578,6 +613,8 @@ function initDefaults() { whoogleI2pRedirectsChecks: [...redirects.whoogle.i2p], whoogleI2pCustomRedirects: [], + whoogleLokiCustomRedirects: [], + searxNormalRedirectsChecks: searxNormalRedirectsChecks, searxNormalCustomRedirects: [], @@ -588,6 +625,8 @@ function initDefaults() { searxI2pRedirectsChecks: [...redirects.searx.i2p], searxI2pCustomRedirects: [], + searxLokiCustomRedirects: [], + searxngNormalRedirectsChecks: searxngNormalRedirectsChecks, searxngNormalCustomRedirects: [], @@ -598,6 +637,8 @@ function initDefaults() { searxngI2pRedirectsChecks: [...redirects.searxng.i2p], searxngI2pCustomRedirects: [], + searxngLokiCustomRedirects: [], + librexNormalRedirectsChecks: librexNormalRedirectsChecks, librexNormalCustomRedirects: [], @@ -606,7 +647,9 @@ function initDefaults() { librexTorCustomRedirects: [], librexI2pRedirectsChecks: [...redirects.librex.i2p], - librexI2pCustomRedirects: [] + librexI2pCustomRedirects: [], + + librexLokiCustomRedirects: [] }, () => resolve()) }) }) diff --git a/src/assets/javascripts/sendTargets.js b/src/assets/javascripts/sendTargets.js index cc5b348..e414298 100644 --- a/src/assets/javascripts/sendTargets.js +++ b/src/assets/javascripts/sendTargets.js @@ -42,6 +42,8 @@ let sendNormalCustomRedirects, sendTorRedirectsChecks, sendTorCustomRedirects, + sendI2pCustomRedirects, + sendLokiCustomRedirects, protocol, protocolFallback; @@ -57,6 +59,8 @@ function init() { "sendNormalCustomRedirects", "sendTorRedirectsChecks", "sendTorCustomRedirects", + "sendI2pCustomRedirects", + "sendLokiCustomRedirects" ], r => { disableSendTarget = r.disableSendTarget; @@ -65,6 +69,8 @@ function init() { sendNormalCustomRedirects = r.sendNormalCustomRedirects; sendTorRedirectsChecks = r.sendTorRedirectsChecks; sendTorCustomRedirects = r.sendTorCustomRedirects; + sendI2pCustomRedirects = r.sendI2pCustomRedirects; + sendLokiCustomRedirects = r.sendLokiCustomRedirects; protocol = r.protocol; protocolFallback = r.protocolFallback; resolve(); @@ -83,6 +89,8 @@ function all() { ...sendNormalCustomRedirects, ...sendTorRedirectsChecks, ...sendTorCustomRedirects, + ...sendI2pCustomRedirects, + ...sendLokiCustomRedirects ]; } @@ -95,7 +103,9 @@ function switchInstance(url, disableOverride) { if (url.pathname != '/') { resolve(); return; } let instancesList = []; - if (protocol == 'tor') instancesList = [...sendTorRedirectsChecks, ...sendTorCustomRedirects]; + if (protocol == 'loki') instancesList = [...sendLokiCustomRedirects]; + else if (protocol == 'i2p') instancesList = [...sendI2pCustomRedirects]; + else if (protocol == 'tor') instancesList = [...sendTorRedirectsChecks, ...sendTorCustomRedirects]; if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { instancesList = [...sendNormalRedirectsChecks, ...sendNormalCustomRedirects]; } @@ -116,7 +126,9 @@ function redirect(url, type, initiator, disableOverride) { if (!targets.some(rx => rx.test(url.href))) return; let instancesList = []; - if (protocol == 'tor') instancesList = [...sendTorRedirectsChecks, ...sendTorCustomRedirects]; + if (protocol == 'loki') instancesList = [...sendLokiCustomRedirects]; + else if (protocol == 'i2p') instancesList = [...sendI2pCustomRedirects]; + else if (protocol == 'tor') instancesList = [...sendTorRedirectsChecks, ...sendTorCustomRedirects]; if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { instancesList = [...sendNormalRedirectsChecks, ...sendNormalCustomRedirects]; } @@ -147,7 +159,11 @@ function initDefaults() { sendNormalCustomRedirects: [], sendTorRedirectsChecks: [...redirects.send.tor], - sendTorCustomRedirects: [] + sendTorCustomRedirects: [], + + sendI2pCustomRedirects: [], + + sendLokiCustomRedirects: [] }, () => resolve()) }) }) diff --git a/src/assets/javascripts/tiktok.js b/src/assets/javascripts/tiktok.js index 0bf6d59..ac35910 100644 --- a/src/assets/javascripts/tiktok.js +++ b/src/assets/javascripts/tiktok.js @@ -42,13 +42,17 @@ function initProxiTokCookies(test, from) { ...proxiTokNormalCustomRedirects, ...proxiTokTorRedirectsChecks, ...proxiTokTorCustomRedirects, + ...proxiTokI2pCustomRedirects, + ...proxiTokLokiCustomRedirects, ].includes(protocolHost)) resolve(); if (!test) { - let instancesList = []; - if (protocol == 'tor') instancesList = [...proxiTokTorRedirectsChecks, ...proxiTokTorCustomRedirects]; - if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { - instancesList = [...proxiTokNormalRedirectsChecks, ...proxiTokNormalCustomRedirects]; + let checkedInstances = []; + if (protocol == 'loki') checkedInstances = [...proxiTokI2pCustomRedirects]; + else if (protocol == 'i2p') checkedInstances = [...proxiTokLokiCustomRedirects]; + else if (protocol == 'tor') checkedInstances = [...proxiTokTorRedirectsChecks, ...proxiTokTorCustomRedirects]; + if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') { + checkedInstances = [...proxiTokNormalRedirectsChecks, ...proxiTokNormalCustomRedirects]; } await utils.copyCookie('proxitok', from, checkedInstances, 'theme'); await utils.copyCookie('proxitok', from, checkedInstances, 'api-legacy'); @@ -61,10 +65,12 @@ function pasteProxiTokCookies() { return new Promise(async resolve => { await init(); if (disableTiktok || protocol === undefined) { resolve(); return; } - let instancesList = []; - if (protocol == 'tor') instancesList = [...proxiTokTorRedirectsChecks, ...proxiTokTorCustomRedirects]; - if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { - instancesList = [...proxiTokNormalRedirectsChecks, ...proxiTokNormalCustomRedirects]; + let checkedInstances = []; + if (protocol == 'loki') checkedInstances = [...proxiTokI2pCustomRedirects]; + else if (protocol == 'i2p') checkedInstances = [...proxiTokLokiCustomRedirects]; + else if (protocol == 'tor') checkedInstances = [...proxiTokTorRedirectsChecks, ...proxiTokTorCustomRedirects]; + if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') { + checkedInstances = [...proxiTokNormalRedirectsChecks, ...proxiTokNormalCustomRedirects]; } utils.getCookiesFromStorage('proxitok', checkedInstances, 'theme'); utils.getCookiesFromStorage('proxitok', checkedInstances, 'api-legacy'); @@ -80,7 +86,9 @@ let proxiTokNormalRedirectsChecks, proxiTokNormalCustomRedirects, proxiTokTorRedirectsChecks, - proxiTokTorCustomRedirects; + proxiTokTorCustomRedirects, + proxiTokI2pCustomRedirects, + proxiTokLokiCustomRedirects; function init() { return new Promise(async resolve => { @@ -94,6 +102,8 @@ function init() { "proxiTokNormalCustomRedirects", "proxiTokTorRedirectsChecks", "proxiTokTorCustomRedirects", + "proxiTokI2pCustomRedirects", + "proxiTokLokiCustomRedirects" ], r => { disableTiktok = r.disableTiktok; @@ -104,6 +114,8 @@ function init() { proxiTokNormalCustomRedirects = r.proxiTokNormalCustomRedirects; proxiTokTorRedirectsChecks = r.proxiTokTorRedirectsChecks; proxiTokTorCustomRedirects = r.proxiTokTorCustomRedirects; + proxiTokI2pCustomRedirects = r.proxiTokI2pCustomRedirects; + proxiTokLokiCustomRedirects = r.proxiTokLokiCustomRedirects; resolve(); } ) @@ -126,7 +138,9 @@ function redirect(url, type, initiator, disableOverride) { if (!targets.some(rx => rx.test(url.href))) return; let instancesList = []; - if (protocol == 'tor') instancesList = [...proxiTokTorRedirectsChecks, ...proxiTokTorCustomRedirects]; + if (protocol == 'loki') instancesList = [...proxiTokI2pCustomRedirects]; + else if (protocol == 'i2p') instancesList = [...proxiTokLokiCustomRedirects]; + else if (protocol == 'tor') instancesList = [...proxiTokTorRedirectsChecks, ...proxiTokTorCustomRedirects]; if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { instancesList = [...proxiTokNormalRedirectsChecks, ...proxiTokNormalCustomRedirects]; } @@ -144,7 +158,9 @@ function reverse(url) { ...tiktokRedirects.proxiTok.normal, ...tiktokRedirects.proxiTok.tor, ...proxiTokNormalCustomRedirects, - ...proxiTokTorCustomRedirects + ...proxiTokTorCustomRedirects, + ...proxiTokI2pCustomRedirects, + ...proxiTokLokiCustomRedirects ]; if (!all.includes(protocolHost)) { resolve(); return; } @@ -163,11 +179,15 @@ function switchInstance(url, disableOverride) { ...proxiTokNormalCustomRedirects, ...proxiTokTorCustomRedirects, + ...proxiTokI2pCustomRedirects, + ...proxiTokLokiCustomRedirects ]; if (!all.includes(protocolHost)) { resolve(); return; } let instancesList = []; - if (protocol == 'tor') instancesList = [...proxiTokTorRedirectsChecks, ...proxiTokTorCustomRedirects]; + if (protocol == 'loki') instancesList = [...proxiTokI2pCustomRedirects]; + else if (protocol == 'i2p') instancesList = [...proxiTokLokiCustomRedirects]; + else if (protocol == 'tor') instancesList = [...proxiTokTorRedirectsChecks, ...proxiTokTorCustomRedirects]; if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { instancesList = [...proxiTokNormalRedirectsChecks, ...proxiTokNormalCustomRedirects]; } @@ -198,6 +218,10 @@ function initDefaults() { proxiTokTorRedirectsChecks: [...redirects.proxiTok.tor], proxiTokTorCustomRedirects: [], + + proxiTokI2pCustomRedirects: [], + + proxiTokLokiCustomRedirects: [] }, () => resolve()); }); }) diff --git a/src/assets/javascripts/translate/translate.js b/src/assets/javascripts/translate/translate.js index ae64f12..0dc0f73 100644 --- a/src/assets/javascripts/translate/translate.js +++ b/src/assets/javascripts/translate/translate.js @@ -31,11 +31,13 @@ let simplyTranslateI2pRedirectsChecks, simplyTranslateI2pCustomRedirects, simplyTranslateLokiRedirectsChecks, - simplyTranslateLokiCustomReidrects, + simplyTranslateLokiCustomRedirects, lingvaNormalRedirectsChecks, lingvaNormalCustomRedirects, lingvaTorRedirectsChecks, - lingvaTorCustomRedirects; + lingvaTorCustomRedirects, + lingvaI2pCustomRedirects, + lingvaLokiCustomRedirects function init() { return new Promise(resolve => { @@ -53,12 +55,14 @@ function init() { "simplyTranslateI2pRedirectsChecks", "simplyTranslateI2pCustomRedirects", "simplyTranslateLokiRedirectsChecks", - "simplyTranslateLokiCustomReidrects", + "simplyTranslateLokiCustomRedirects", "lingvaNormalRedirectsChecks", "lingvaNormalCustomRedirects", "lingvaTorRedirectsChecks", "lingvaTorCustomRedirects", + "lingvaI2pCustomRedirects", + "lingvaLokiCustomRedirects" ], r => { translateDisable = r.translateDisable; @@ -73,11 +77,13 @@ function init() { simplyTranslateI2pRedirectsChecks = r.simplyTranslateI2pRedirectsChecks; simplyTranslateI2pCustomRedirects = r.simplyTranslateI2pCustomRedirects; simplyTranslateLokiRedirectsChecks = r.simplyTranslateLokiRedirectsChecks; - simplyTranslateLokiCustomReidrects = r.simplyTranslateLokiCustomReidrects; + simplyTranslateLokiCustomRedirects = r.simplyTranslateLokiCustomRedirects; lingvaNormalRedirectsChecks = r.lingvaNormalRedirectsChecks; lingvaNormalCustomRedirects = r.lingvaNormalCustomRedirects; lingvaTorRedirectsChecks = r.lingvaTorRedirectsChecks; lingvaTorCustomRedirects = r.lingvaTorCustomRedirects; + lingvaI2pCustomRedirects = r.lingvaI2pCustomRedirects; + lingvaLokiCustomRedirects = r.lingvaLokiCustomRedirects; resolve(); } ) @@ -117,6 +123,8 @@ function copyPasteLingvaLocalStorage(test, url, tabId) { ...lingvaNormalCustomRedirects, ...lingvaTorRedirectsChecks, ...lingvaTorCustomRedirects, + ...lingvaI2pCustomRedirects, + ...lingvaLokiCustomRedirects ].includes(protocolHost)) { resolve(); return; } if (!test) { @@ -126,7 +134,9 @@ function copyPasteLingvaLocalStorage(test, url, tabId) { ); let checkedInstances = []; - if (protocol == 'tor') checkedInstances = [...lingvaTorRedirectsChecks, ...lingvaTorCustomRedirects]; + if (protocol == 'loki') checkedInstances = [...lingvaLokiCustomRedirects]; //...lingvaLokiRedirectsChecks, + else if (protocol == 'i2p') checkedInstances = [...lingvaI2pCustomRedirects]; //...lingvaI2pRedirectsChecks, + else if (protocol == 'tor') checkedInstances = [...lingvaTorRedirectsChecks, ...lingvaTorCustomRedirects]; if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') { checkedInstances = [...lingvaNormalRedirectsChecks, ...lingvaNormalCustomRedirects]; } @@ -149,7 +159,9 @@ function pasteLingvaLocalStorage() { await init(); if (translateDisable || translateFrontend != 'lingva') { resolve(); return; } let checkedInstances = []; - if (protocol == 'tor') checkedInstances = [...lingvaTorRedirectsChecks, ...lingvaTorCustomRedirects]; + if (protocol == 'loki') checkedInstances = [...lingvaLokiCustomRedirects]; //...lingvaLokiRedirectsChecks, + else if (protocol == 'i2p') checkedInstances = [...lingvaI2pCustomRedirects]; //...lingvaI2pRedirectsChecks, + else if (protocol == 'tor') checkedInstances = [...lingvaTorRedirectsChecks, ...lingvaTorCustomRedirects]; if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') { checkedInstances = [...lingvaNormalRedirectsChecks, ...lingvaNormalCustomRedirects]; } @@ -172,11 +184,11 @@ function copyPasteSimplyTranslateCookies(test, from) { ...simplyTranslateI2pRedirectsChecks, ...simplyTranslateI2pCustomRedirects, ...simplyTranslateLokiRedirectsChecks, - ...simplyTranslateLokiCustomReidrects, + ...simplyTranslateLokiCustomRedirects, ].includes(protocolHost)) { resolve(); return; } if (!test) { let checkedInstances = []; - if (protocol == 'loki') checkedInstances = [...simplyTranslateLokiRedirectsChecks, ...simplyTranslateLokiCustomReidrects] + if (protocol == 'loki') checkedInstances = [...simplyTranslateLokiRedirectsChecks, ...simplyTranslateLokiCustomRedirects] else if (protocol == 'i2p') checkedInstances = [...simplyTranslateI2pCustomRedirects, ...simplyTranslateI2pRedirectsChecks]; else if (protocol == 'tor') checkedInstances = [...simplyTranslateTorRedirectsChecks, ...simplyTranslateTorCustomRedirects]; if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') { @@ -197,7 +209,7 @@ function pasteSimplyTranslateCookies() { await init(); if (translateDisable || translateFrontend != 'simplyTranslate') { resolve(); return; } let checkedInstances = []; - if (protocol == 'loki') checkedInstances = [...simplyTranslateLokiRedirectsChecks, ...simplyTranslateLokiCustomReidrects] + if (protocol == 'loki') checkedInstances = [...simplyTranslateLokiRedirectsChecks, ...simplyTranslateLokiCustomRedirects] else if (protocol == 'i2p') checkedInstances = [...simplyTranslateI2pCustomRedirects, ...simplyTranslateI2pRedirectsChecks]; else if (protocol == 'tor') checkedInstances = [...simplyTranslateTorRedirectsChecks, ...simplyTranslateTorCustomRedirects]; if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') { @@ -218,7 +230,7 @@ function redirect(url, disableOverride) { if (translateFrontend == 'simplyTranslate') { let instancesList = []; - if (protocol == 'loki') instancesList = [...simplyTranslateLokiRedirectsChecks, ...simplyTranslateLokiCustomReidrects]; + if (protocol == 'loki') instancesList = [...simplyTranslateLokiRedirectsChecks, ...simplyTranslateLokiCustomRedirects]; else if (protocol == 'i2p') instancesList = [...simplyTranslateI2pRedirectsChecks, ...simplyTranslateI2pCustomRedirects]; else if (protocol == 'tor') instancesList = [...simplyTranslateTorRedirectsChecks, ...simplyTranslateTorCustomRedirects]; if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { @@ -238,6 +250,8 @@ function redirect(url, disableOverride) { params[pair[0]] = pair[1]; } let instancesList = []; + if (protocol == 'loki') instancesList = [...lingvaLokiCustomRedirects]; //...lingvaLokiRedirectsChecks, + else if (protocol == 'i2p') instancesList = [...lingvaI2pCustomRedirects]; //...lingvaI2pRedirectsChecks, if (protocol == 'tor') instancesList = [...lingvaTorRedirectsChecks, ...lingvaTorCustomRedirects]; if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { instancesList = [...lingvaNormalRedirectsChecks, ...lingvaNormalCustomRedirects]; @@ -266,24 +280,26 @@ function switchInstance(url, disableOverride) { ...simplyTranslateNormalCustomRedirects, ...simplyTranslateTorCustomRedirects, ...simplyTranslateI2pCustomRedirects, - ...simplyTranslateLokiCustomReidrects, + ...simplyTranslateLokiCustomRedirects, ...translateRedirects.lingva.normal, ...translateRedirects.lingva.tor, ...lingvaNormalCustomRedirects, ...lingvaTorCustomRedirects, + ...lingvaI2pCustomRedirects, + ...lingvaLokiCustomRedirects ].includes(protocolHost)) { resolve(); return; } let instancesList; if (protocol == 'loki') { - if (translateFrontend == 'simplyTranslate') instancesList = [...simplyTranslateLokiRedirectsChecks, ...simplyTranslateLokiCustomReidrects]; - //else if (translateFrontend == 'lingva') instancesList = [...lingvaLokiRedirectsChecks, ...lingvaLokiCustomRedirects]; + if (translateFrontend == 'simplyTranslate') instancesList = [...simplyTranslateLokiRedirectsChecks, ...simplyTranslateLokiCustomRedirects]; + else if (translateFrontend == 'lingva') instancesList = [...lingvaLokiCustomRedirects]; //...lingvaLokiRedirectsChecks, } else if (protocol == 'i2p') { if (translateFrontend == 'simplyTranslate') instancesList = [...simplyTranslateI2pRedirectsChecks, ...simplyTranslateI2pCustomRedirects]; - //else if (translateFrontend == 'lingva') instancesList = [...lingvaI2PRedirectsChecks, ...lingvaI2PCustomRedirects]; + else if (translateFrontend == 'lingva') instancesList = [...lingvaI2pCustomRedirects]; //...lingvaI2pRedirectsChecks, } else if (protocol == 'tor') { if (translateFrontend == 'simplyTranslate') instancesList = [...simplyTranslateTorRedirectsChecks, ...simplyTranslateTorCustomRedirects]; @@ -329,12 +345,14 @@ function initDefaults() { simplyTranslateI2pRedirectsChecks: [...redirects.simplyTranslate.i2p], simplyTranslateI2pCustomRedirects: [], simplyTranslateLokiRedirectsChecks: [...redirects.simplyTranslate.loki], - simplyTranslateLokiCustomReidrects: [], + simplyTranslateLokiCustomRedirects: [], lingvaNormalRedirectsChecks: lingvaNormalRedirectsChecks, lingvaNormalCustomRedirects: [], lingvaTorRedirectsChecks: [...redirects.lingva.tor], lingvaTorCustomRedirects: [], + lingvaI2pCustomRedirects: [], + lingvaLokiCustomRedirects: [] }, () => resolve()) }) }) diff --git a/src/assets/javascripts/twitter.js b/src/assets/javascripts/twitter.js index e69d9ab..42243a6 100644 --- a/src/assets/javascripts/twitter.js +++ b/src/assets/javascripts/twitter.js @@ -46,7 +46,9 @@ let nitterNormalRedirectsChecks, nitterNormalCustomRedirects, nitterTorRedirectsChecks, - nitterTorCustomRedirects; + nitterTorCustomRedirects, + nitterI2pCustomRedirects, + nitterLokiCustomRedirects; function init() { return new Promise(async resolve => { @@ -61,6 +63,8 @@ function init() { "nitterNormalCustomRedirects", "nitterTorRedirectsChecks", "nitterTorCustomRedirects", + "nitterI2pCustomRedirects", + "nitterLokiCustomRedirects" ], r => { disableTwitter = r.disableTwitter; @@ -72,6 +76,8 @@ function init() { nitterNormalCustomRedirects = r.nitterNormalCustomRedirects; nitterTorRedirectsChecks = r.nitterTorRedirectsChecks; nitterTorCustomRedirects = r.nitterTorCustomRedirects; + nitterI2pCustomRedirects = r.nitterI2pCustomRedirects; + nitterLokiCustomRedirects = r.nitterLokiCustomRedirects; resolve(); } ) @@ -87,6 +93,8 @@ function all() { ...nitterTorRedirectsChecks, ...nitterNormalCustomRedirects, ...nitterTorCustomRedirects, + ...nitterI2pCustomRedirects, + ...nitterLokiCustomRedirects ]; } @@ -99,7 +107,9 @@ function redirect(url, type, initiator, disableOverride) { if (twitterRedirectType == 'main_frame' && type != "main_frame") return; let instancesList = []; - if (protocol == 'tor') instancesList = [...nitterTorRedirectsChecks, ...nitterTorCustomRedirects]; + if (protocol == 'loki') instancesList = [...nitterI2pCustomRedirects]; + else if (protocol == 'i2p') instancesList = [...nitterLokiCustomRedirects]; + else if (protocol == 'tor') instancesList = [...nitterTorRedirectsChecks, ...nitterTorCustomRedirects]; if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { instancesList = [...nitterNormalRedirectsChecks, ...nitterNormalCustomRedirects]; } @@ -136,7 +146,9 @@ function switchInstance(url, disableOverride) { const protocolHost = utils.protocolHost(url); if (!all().includes(protocolHost)) { resolve(); return; } let instancesList = []; - if (protocol == 'tor') instancesList = [...nitterTorRedirectsChecks, ...nitterTorCustomRedirects]; + if (protocol == 'loki') instancesList = [...nitterI2pCustomRedirects]; + else if (protocol == 'i2p') instancesList = [...nitterLokiCustomRedirects]; + else if (protocol == 'tor') instancesList = [...nitterTorRedirectsChecks, ...nitterTorCustomRedirects]; if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { instancesList = [...nitterNormalRedirectsChecks, ...nitterNormalCustomRedirects]; } @@ -177,7 +189,9 @@ function initNitterCookies(test, from) { ) { resolve(); return; } if (!test) { let checkedInstances = []; - if (protocol == 'tor') checkedInstances = [...nitterTorRedirectsChecks, ...nitterTorCustomRedirects]; + if (protocol == 'loki') checkedInstances = [...nitterI2pCustomRedirects]; + else if (protocol == 'i2p') checkedInstances = [...nitterLokiCustomRedirects]; + else if (protocol == 'tor') checkedInstances = [...nitterTorRedirectsChecks, ...nitterTorCustomRedirects]; if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') { checkedInstances = [...nitterNormalRedirectsChecks, ...nitterNormalCustomRedirects]; } @@ -210,7 +224,9 @@ function pasteNitterCookies() { await init(); if (disableTwitter || protocol === undefined) { resolve(); return; } let checkedInstances = []; - if (protocol == 'tor') checkedInstances = [...nitterTorRedirectsChecks, ...nitterTorCustomRedirects]; + if (protocol == 'loki') checkedInstances = [...nitterI2pCustomRedirects]; + else if (protocol == 'i2p') checkedInstances = [...nitterLokiCustomRedirects]; + else if (protocol == 'tor') checkedInstances = [...nitterTorRedirectsChecks, ...nitterTorCustomRedirects]; if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') { checkedInstances = [...nitterNormalRedirectsChecks, ...nitterNormalCustomRedirects]; } @@ -261,6 +277,10 @@ function initDefaults() { nitterTorRedirectsChecks: [...redirects.nitter.tor], nitterTorCustomRedirects: [], + + nitterI2pCustomRedirects: [], + + nitterLokiCustomRedirects: [] }, () => resolve()); }) }) diff --git a/src/assets/javascripts/utils.js b/src/assets/javascripts/utils.js index f9d4827..7428a79 100644 --- a/src/assets/javascripts/utils.js +++ b/src/assets/javascripts/utils.js @@ -14,6 +14,7 @@ import tiktokHelper from "./tiktok.js"; import quoraHelper from "./quora.js" import libremdbHelper from "./imdb.js"; import imgurHelper from "./imgur.js"; +import reutersHelper from './reuters.js'; import localise from './localise.js' function getRandomInstance(instances) { @@ -41,7 +42,7 @@ function updateInstances() { await initcloudflareBlackList(); const instances = JSON.parse(http.responseText); - youtubeHelper.setRedirects({ 'invidious': instances.invidious, 'piped': instances.piped, }) + youtubeHelper.setRedirects({ 'invidious': instances.invidious, 'piped': instances.piped, 'pipedMaterial': instances.pipedMaterial }) twitterHelper.setRedirects(instances.nitter); instagramHelper.setRedirects(instances.bibliogram); redditHelper.setRedirects({ 'libreddit': instances.libreddit, 'teddit': instances.teddit }); @@ -54,6 +55,7 @@ function updateInstances() { sendTargetsHelper.setRedirects(instances.send); tiktokHelper.setRedirects(instances.proxiTok); lbryHelper.setRedirects(instances.librarian); + reutersHelper.setRedirects(instances.neuters); console.info("Successfully updated Instances"); resolve(true); return; diff --git a/src/assets/javascripts/wikipedia.js b/src/assets/javascripts/wikipedia.js index d945e22..2d9384f 100644 --- a/src/assets/javascripts/wikipedia.js +++ b/src/assets/javascripts/wikipedia.js @@ -41,7 +41,8 @@ let wikilessI2pRedirectsChecks, wikilessNormalCustomRedirects, wikilessTorCustomRedirects, - wikilessI2pCustomRedirects; + wikilessI2pCustomRedirects, + wikilessLokiCustomRedirects; function init() { return new Promise(async resolve => { @@ -57,6 +58,7 @@ function init() { "wikilessNormalCustomRedirects", "wikilessTorCustomRedirects", "wikilessI2pCustomRedirects", + "wikilessLokiCustomRedirects" ], r => { disableWikipedia = r.disableWikipedia; @@ -69,6 +71,7 @@ function init() { wikilessNormalCustomRedirects = r.wikilessNormalCustomRedirects; wikilessTorCustomRedirects = r.wikilessTorCustomRedirects; wikilessI2pCustomRedirects = r.wikilessI2pCustomRedirects; + wikilessLokiCustomRedirects = r.wikilessLokiCustomRedirects; resolve(); } ) @@ -89,13 +92,15 @@ function initWikilessCookies(test, from) { ...wikilessTorCustomRedirects, ...wikilessI2pRedirectsChecks, ...wikilessI2pCustomRedirects, + ...wikilessLokiCustomRedirects ]; if (!all.includes(protocolHost)) { resolve(); return; } if (!test) { let checkedInstances = []; - if (protocol == 'i2p') checkedInstances = [...wikilessI2pCustomRedirects, ...wikilessI2pRedirectsChecks]; - if (protocol == 'tor') checkedInstances = [...wikilessTorRedirectsChecks, ...wikilessTorCustomRedirects]; + if (protocol == 'loki') checkedInstances = [...wikilessLokiCustomRedirects]; + else if (protocol == 'i2p') checkedInstances = [...wikilessI2pCustomRedirects, ...wikilessI2pRedirectsChecks]; + else if (protocol == 'tor') checkedInstances = [...wikilessTorRedirectsChecks, ...wikilessTorCustomRedirects]; if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') { checkedInstances = [...wikilessNormalRedirectsChecks, ...wikilessNormalCustomRedirects]; } @@ -111,7 +116,8 @@ function pasteWikilessCookies() { await init(); if (disableWikipedia || protocol === undefined) { resolve(); return; } let checkedInstances = []; - if (protocol == 'i2p') checkedInstances = [...wikilessI2pCustomRedirects, ...wikilessI2pRedirectsChecks]; + if (protocol == 'loki') checkedInstances = [...wikilessLokiCustomRedirects]; + else if (protocol == 'i2p') checkedInstances = [...wikilessI2pCustomRedirects, ...wikilessI2pRedirectsChecks]; else if (protocol == 'tor') checkedInstances = [...wikilessTorRedirectsChecks, ...wikilessTorCustomRedirects]; if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') { checkedInstances = [...wikilessNormalRedirectsChecks, ...wikilessNormalCustomRedirects]; @@ -136,7 +142,8 @@ function redirect(url, disableOverride) { } } let instancesList = []; - if (protocol == 'i2p') instancesList = [...wikilessI2pCustomRedirects, ...wikilessI2pRedirectsChecks]; + if (protocol == 'loki') instancesList = [...wikilessLokiCustomRedirects]; + else if (protocol == 'i2p') instancesList = [...wikilessI2pCustomRedirects, ...wikilessI2pRedirectsChecks]; else if (protocol == 'tor') instancesList = [...wikilessTorRedirectsChecks, ...wikilessTorCustomRedirects]; if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { instancesList = [...wikilessNormalRedirectsChecks, ...wikilessNormalCustomRedirects]; @@ -172,12 +179,14 @@ function switchInstance(url, disableOverride) { ...wikilessNormalCustomRedirects, ...wikilessTorCustomRedirects, - ...wikilessI2pCustomRedirects + ...wikilessI2pCustomRedirects, + ...wikilessLokiCustomRedirects ]; if (!wikipediaList.includes(protocolHost)) { resolve(); return; } let instancesList = []; - if (protocol == 'i2p') instancesList = [...wikilessI2pCustomRedirects, ...wikilessI2pRedirectsChecks]; + if (protocol == 'loki') instancesList = [...wikilessLokiCustomRedirects]; + else if (protocol == 'i2p') instancesList = [...wikilessI2pCustomRedirects, ...wikilessI2pRedirectsChecks]; else if (protocol == 'tor') instancesList = [...wikilessTorRedirectsChecks, ...wikilessTorCustomRedirects]; if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { instancesList = [...wikilessNormalRedirectsChecks, ...wikilessNormalCustomRedirects]; @@ -214,6 +223,7 @@ function initDefaults() { wikilessNormalCustomRedirects: [], wikilessTorCustomRedirects: [], wikilessI2pCustomRedirects: [], + wikilessLokiCustomRedirects: [] }, () => resolve()); }) }) diff --git a/src/assets/javascripts/youtube/youtube.js b/src/assets/javascripts/youtube/youtube.js index feb2fc1..3d7cd89 100644 --- a/src/assets/javascripts/youtube/youtube.js +++ b/src/assets/javascripts/youtube/youtube.js @@ -33,14 +33,19 @@ function setRedirects(val) { browser.storage.local.get('cloudflareBlackList', r => { redirects.invidious = val.invidious; redirects.piped = val.piped; + redirects.pipedMaterial = val.pipedMaterial invidiousNormalRedirectsChecks = [...redirects.invidious.normal]; pipedNormalRedirectsChecks = [...redirects.piped.normal]; + pipedMaterialNormalRedirectsChecks = [...redirects.pipedMaterial.normal] for (const instance of r.cloudflareBlackList) { const a = invidiousNormalRedirectsChecks.indexOf(instance); if (a > -1) invidiousNormalRedirectsChecks.splice(a, 1); const b = pipedNormalRedirectsChecks.indexOf(instance); if (b > -1) pipedNormalRedirectsChecks.splice(b, 1); + + const c = pipedMaterialNormalRedirectsChecks.indexOf(instance); + if (c > -1) pipedMaterialNormalRedirectsChecks.splice(c, 1); } browser.storage.local.set({ youtubeRedirects: redirects, @@ -48,6 +53,8 @@ function setRedirects(val) { invidiousTorRedirectsChecks: redirects.invidious.tor, pipedNormalRedirectsChecks, pipedTorRedirectsChecks: redirects.piped.tor, + pipedMaterialNormalRedirectsChecks, + pipedMaterialTorRedirectsChecks: redirects.pipedMaterial.tor }) }) } @@ -64,14 +71,20 @@ let invidiousNormalCustomRedirects, invidiousTorRedirectsChecks, invidiousTorCustomRedirects, + invidiousI2pCustomRedirects, + invidiousLokiCustomRedirects, pipedNormalRedirectsChecks, pipedNormalCustomRedirects, pipedTorRedirectsChecks, pipedTorCustomRedirects, + pipedI2pCustomRedirects, + pipedLokiCustomRedirects, pipedMaterialNormalRedirectsChecks, pipedMaterialNormalCustomRedirects, pipedMaterialTorRedirectsChecks, - pipedMaterialTorCustomRedirects; + pipedMaterialTorCustomRedirects, + pipedMaterialI2pCustomRedirects, + pipedMaterialLokiCustomRedirects; function init() { return new Promise(resolve => { @@ -88,14 +101,20 @@ function init() { "invidiousNormalCustomRedirects", "invidiousTorRedirectsChecks", "invidiousTorCustomRedirects", + "invidiousI2pCustomRedirects", + "invidiousLokiCustomRedirects", "pipedNormalRedirectsChecks", "pipedNormalCustomRedirects", "pipedTorRedirectsChecks", "pipedTorCustomRedirects", + "pipedI2pCustomRedirects", + "pipedLokiCustomRedirects", "pipedMaterialNormalRedirectsChecks", "pipedMaterialNormalCustomRedirects", "pipedMaterialTorRedirectsChecks", "pipedMaterialTorCustomRedirects", + "pipedMaterialI2pCustomRedirects", + "pipedMaterialLokiCustomRedirects" ], r => { disableYoutube = r.disableYoutube; @@ -109,14 +128,20 @@ function init() { invidiousNormalCustomRedirects = r.invidiousNormalCustomRedirects; invidiousTorRedirectsChecks = r.invidiousTorRedirectsChecks; invidiousTorCustomRedirects = r.invidiousTorCustomRedirects; + invidiousI2pCustomRedirects = r.invidiousI2pCustomRedirects; + invidiousLokiCustomRedirects = r.invidiousLokiCustomRedirects; pipedNormalRedirectsChecks = r.pipedNormalRedirectsChecks; pipedNormalCustomRedirects = r.pipedNormalCustomRedirects; pipedTorRedirectsChecks = r.pipedTorRedirectsChecks; pipedTorCustomRedirects = r.pipedTorCustomRedirects; + pipedI2pCustomRedirects = r.pipedI2pCustomRedirects; + pipedLokiCustomRedirects = r.pipedLokiCustomRedirects; pipedMaterialNormalRedirectsChecks = r.pipedMaterialNormalRedirectsChecks; pipedMaterialNormalCustomRedirects = r.pipedMaterialNormalCustomRedirects; pipedMaterialTorRedirectsChecks = r.pipedMaterialTorRedirectsChecks; pipedMaterialTorCustomRedirects = r.pipedMaterialTorCustomRedirects; + pipedMaterialI2pCustomRedirects - r.pipedMaterialI2pCustomRedirects; + pipedMaterialLokiCustomRedirects = r.pipedMaterialLokiCustomRedirects; resolve(); } ) @@ -139,12 +164,18 @@ function all() { ...invidiousNormalCustomRedirects, ...invidiousTorCustomRedirects, + ...invidiousI2pCustomRedirects, + ...invidiousLokiCustomRedirects, ...pipedNormalCustomRedirects, ...pipedTorCustomRedirects, + ...pipedI2pCustomRedirects, + ...pipedLokiCustomRedirects, ...pipedMaterialNormalCustomRedirects, ...pipedMaterialTorCustomRedirects, + ...pipedMaterialI2pCustomRedirects, + ...pipedMaterialLokiCustomRedirects ]; } @@ -159,7 +190,7 @@ function redirect(url, type, initiator, disableOverride) { const isFreetube = youtubeFrontend == 'freetube'; const isYatte = youtubeFrontend == 'yatte'; - const isFrontendYoutube = youtubeEmbedFrontend == "youtube"; + //const isFrontendYoutube = youtubeEmbedFrontend == "youtube"; const isFrontendInvidious = youtubeEmbedFrontend == 'invidious'; const isFrontendPiped = youtubeEmbedFrontend == 'piped'; const isFrontendPipedMaterial = youtubeEmbedFrontend == 'pipedMaterial'; @@ -171,24 +202,28 @@ function redirect(url, type, initiator, disableOverride) { if (onlyEmbeddedVideo == 'onlyEmbedded' && main_frame) return; if (onlyEmbeddedVideo == 'onlyNotEmbedded' && !main_frame) return; - if ((isFreetube || isYatte) && sub_frame && isFrontendYoutube) return; + //if ((isFreetube || isYatte) && sub_frame && isFrontendYoutube) return; if (isYatte && main_frame) return url.href.replace(/^https?:\/{2}/, 'yattee://'); if (isFreetube && main_frame) return `freetube://https://youtube.com${url.pathname}${url.search}`; if (isInvidious || ((isFreetube || isYatte) && sub_frame && isFrontendInvidious)) { - let instancesList = [] = []; - if (protocol == 'tor') instancesList = [...invidiousTorRedirectsChecks, ...invidiousTorCustomRedirects]; - if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { - instancesList = [...invidiousNormalRedirectsChecks, ...invidiousNormalCustomRedirects]; - } + let instancesList = []; + if (protocol == 'loki') instancesList = [...invidiousLokiCustomRedirects]; + else if (protocol == 'i2p') instancesList = [...invidiousI2pCustomRedirects]; + else if (protocol == 'tor') instancesList = [...invidiousTorRedirectsChecks, ...invidiousTorCustomRedirects]; + if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { + instancesList = [...invidiousNormalRedirectsChecks, ...invidiousNormalCustomRedirects]; + } if (instancesList.length === 0) return; const randomInstance = utils.getRandomInstance(instancesList); return `${randomInstance}${url.pathname}${url.search}`; } if (isPiped || ((isFreetube || isYatte) && sub_frame && isFrontendPiped)) { let instancesList = []; - if (protocol == 'tor') instancesList = [...pipedTorRedirectsChecks, ...pipedTorCustomRedirects]; + if (protocol == 'loki') instancesList = [...pipedLokiCustomRedirects]; + else if (protocol == 'i2p') instancesList = [...pipedI2pCustomRedirects]; + else if (protocol == 'tor') instancesList = [...pipedTorRedirectsChecks, ...pipedTorCustomRedirects]; if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { instancesList = [...pipedNormalRedirectsChecks, ...pipedNormalCustomRedirects]; } @@ -198,7 +233,9 @@ function redirect(url, type, initiator, disableOverride) { } if (isPipedMaterial || ((isFreetube || isYatte) && sub_frame && isFrontendPipedMaterial)) { let instancesList = []; - if (protocol == 'tor') instancesList = [...pipedMaterialTorRedirectsChecks, ...pipedMaterialTorCustomRedirects]; + if (protocol == 'loki') instancesList = [...pipedMaterialLokiCustomRedirects]; + else if (protocol == 'i2p') instancesList = [...pipedMaterialI2pCustomRedirects]; + else if (protocol == 'tor') instancesList = [...pipedMaterialTorRedirectsChecks, ...pipedMaterialTorCustomRedirects]; if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { instancesList = [...pipedMaterialNormalRedirectsChecks, ...pipedMaterialNormalCustomRedirects]; } @@ -224,9 +261,18 @@ function switchInstance(url, disableOverride) { const protocolHost = utils.protocolHost(url); if (!all().includes(protocolHost)) { resolve(); return; } - let instancesList = [] = []; - - if (protocol == 'tor') { + let instancesList = []; + if (protocol == 'loki') { + if (youtubeFrontend == 'invidious') instancesList = [...invidiousLokiCustomRedirects]; //...invidiousLokiRedirectsChecks, + else if (youtubeFrontend == 'piped') instancesList = [...pipedLokiCustomRedirects]; //...pipedLokiRedirectsChecks, + else if (youtubeFrontend == 'pipedMaterial') instancesList = [...pipedMaterialLokiCustomRedirects]; //...pipedMaterialLokiRedirectsChecks, + } + else if (protocol == 'i2p') { + if (youtubeFrontend == 'invidious') instancesList = [...invidiousI2pCustomRedirects]; //...invidiousI2pRedirectsChecks, + else if (youtubeFrontend == 'piped') instancesList = [...pipedI2pCustomRedirects]; //...pipedI2pRedirectsChecks, + else if (youtubeFrontend == 'pipedMaterial') instancesList = [...pipedMaterialI2pCustomRedirects]; //...pipedMaterialI2pRedirectsChecks, + } + else if (protocol == 'tor') { if (youtubeFrontend == 'invidious') instancesList = [...invidiousTorRedirectsChecks, ...invidiousTorCustomRedirects]; else if (youtubeFrontend == 'piped') instancesList = [...pipedTorRedirectsChecks, ...pipedTorCustomRedirects]; else if (youtubeFrontend == 'pipedMaterial') instancesList = [...pipedMaterialTorRedirectsChecks, ...pipedMaterialTorCustomRedirects]; @@ -285,18 +331,30 @@ function initDefaults() { invidiousTorRedirectsChecks: [...redirects.invidious.tor], invidiousTorCustomRedirects: [], + invidiousI2pCustomRedirects: [], + + invidiousLokiCustomRedirects: [], + pipedNormalRedirectsChecks: pipedNormalRedirectsChecks, pipedNormalCustomRedirects: [], pipedTorRedirectsChecks: [...redirects.piped.tor], pipedTorCustomRedirects: [], + pipedI2pCustomRedirects: [], + + pipedLokiCustomRedirects: [], + pipedMaterialNormalRedirectsChecks: pipedMaterialNormalRedirectsChecks, pipedMaterialNormalCustomRedirects: [], pipedMaterialTorRedirectsChecks: [...redirects.pipedMaterial.tor], pipedMaterialTorCustomRedirects: [], + pipedMaterialI2pCustomRedirects: [], + + pipedMaterialLokiCustomRedirects: [], + youtubeEmbedFrontend: 'invidious' }, () => resolve()) }) @@ -314,11 +372,15 @@ function copyPasteInvidiousCookies(test, from) { ...invidiousTorRedirectsChecks, ...invidiousNormalCustomRedirects, ...invidiousTorCustomRedirects, + ...invidiousI2pCustomRedirects, + ...invidiousLokiCustomRedirects ].includes(protocolHost)) { resolve(); return; } if (!test) { let checkedInstances = []; - if (protocol == 'tor') checkedInstances = [...invidiousTorRedirectsChecks, ...invidiousTorCustomRedirects] + if (protocol == 'loki') checkedInstances = [...invidiousLokiCustomRedirects]; + else if (protocol == 'i2p') checkedInstances = [...invidiousI2pCustomRedirects]; + else if (protocol == 'tor') checkedInstances = [...invidiousTorRedirectsChecks, ...invidiousTorCustomRedirects] if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { checkedInstances = [...invidiousNormalRedirectsChecks, ...invidiousNormalCustomRedirects] } @@ -335,7 +397,9 @@ function pasteInvidiousCookies() { await init(); if (disableYoutube || youtubeFrontend != 'invidious') { resolve(); return; } let checkedInstances = []; - if (protocol == 'tor') checkedInstances = [...invidiousTorRedirectsChecks, ...invidiousTorCustomRedirects] + if (protocol == 'loki') checkedInstances = [...invidiousLokiCustomRedirects]; + else if (protocol == 'i2p') checkedInstances = [...invidiousI2pCustomRedirects]; + else if (protocol == 'tor') checkedInstances = [...invidiousTorRedirectsChecks, ...invidiousTorCustomRedirects] if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { checkedInstances = [...invidiousNormalRedirectsChecks, ...invidiousNormalCustomRedirects] } @@ -354,13 +418,17 @@ function copyPastePipedLocalStorage(test, url, tabId) { ...pipedNormalRedirectsChecks, ...pipedTorRedirectsChecks, ...pipedTorCustomRedirects, + ...pipedI2pCustomRedirects, + ...pipedLokiCustomRedirects ].includes(protocolHost)) { resolve(); return; } if (!test) { browser.tabs.executeScript(tabId, { file: "/assets/javascripts/youtube/get_piped_preferences.js", runAt: "document_start" }); let checkedInstances = []; - if (protocol == 'tor') checkedInstances = [...pipedTorRedirectsChecks, ...pipedTorCustomRedirects] + if (protocol == 'loki') checkedInstances = [...pipedLokiCustomRedirects]; + else if (protocol == 'i2p') checkedInstances = [...pipedI2pCustomRedirects]; + else if (protocol == 'tor') checkedInstances = [...pipedTorRedirectsChecks, ...pipedTorCustomRedirects] if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { checkedInstances = [...pipedNormalCustomRedirects, ...pipedNormalRedirectsChecks] } @@ -379,7 +447,9 @@ function pastePipedLocalStorage() { await init(); if (disableYoutube || youtubeFrontend != 'piped') { resolve(); return; } let checkedInstances = []; - if (protocol == 'tor') checkedInstances = [...pipedTorRedirectsChecks, ...pipedTorCustomRedirects] + if (protocol == 'loki') checkedInstances = [...pipedLokiCustomRedirects]; + else if (protocol == 'i2p') checkedInstances = [...pipedI2pCustomRedirects]; + else if (protocol == 'tor') checkedInstances = [...pipedTorRedirectsChecks, ...pipedTorCustomRedirects] if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { checkedInstances = [...pipedNormalCustomRedirects, ...pipedNormalRedirectsChecks] } @@ -401,13 +471,17 @@ function copyPastePipedMaterialLocalStorage(test, url, tabId,) { ...pipedMaterialNormalCustomRedirects, ...pipedMaterialTorRedirectsChecks, ...pipedMaterialTorCustomRedirects, + ...pipedMaterialI2pCustomRedirects, + ...pipedMaterialLokiCustomRedirects ].includes(protocolHost)) { resolve(); return; } if (!test) { browser.tabs.executeScript(tabId, { file: "/assets/javascripts/youtube/get_pipedMaterial_preferences.js", runAt: "document_start" }); let checkedInstances = []; - if (protocol == 'tor') checkedInstances = [...pipedMaterialTorRedirectsChecks, ...pipedMaterialTorCustomRedirects] + if (protocol == 'loki') checkedInstances = [...pipedMaterialLokiCustomRedirects]; + else if (protocol == 'i2p') checkedInstances = [...pipedMaterialI2pCustomRedirects]; + else if (protocol == 'tor') checkedInstances = [...pipedMaterialTorRedirectsChecks, ...pipedMaterialTorCustomRedirects] if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { checkedInstances = [...pipedMaterialNormalRedirectsChecks, ...pipedMaterialNormalCustomRedirects] } @@ -428,7 +502,9 @@ function pastePipedMaterialLocalStorage() { await init(); if (disableYoutube || youtubeFrontend != 'pipedMaterial') { resolve(); return; } let checkedInstances = []; - if (protocol == 'tor') checkedInstances = [...pipedMaterialTorRedirectsChecks, ...pipedMaterialTorCustomRedirects] + if (protocol == 'loki') checkedInstances = [...pipedMaterialLokiCustomRedirects]; + else if (protocol == 'i2p') checkedInstances = [...pipedMaterialI2pCustomRedirects]; + else if (protocol == 'tor') checkedInstances = [...pipedMaterialTorRedirectsChecks, ...pipedMaterialTorCustomRedirects] if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { checkedInstances = [...pipedMaterialNormalRedirectsChecks, ...pipedMaterialNormalCustomRedirects] } @@ -447,7 +523,17 @@ function removeXFrameOptions(e) { for (const i in e.responseHeaders) { if (e.responseHeaders[i].name == 'content-security-policy') { let instancesList = []; - if (protocol == 'tor') { + if (protocol == 'loki') { + if (youtubeFrontend == 'invidious') instancesList = [...invidiousLokiCustomRedirects]; //...invidiousLokiRedirectsChecks, + if (youtubeFrontend == 'piped') instancesList = [...pipedLokiCustomRedirects]; //...pipedLokiRedirectsChecks, + if (youtubeFrontend == 'pipedMaterial') instancesList = [...pipedMaterialLokiCustomRedirects]; //...pipedMaterialLokiRedirectsChecks, + } + else if (protocol == 'i2p') { + if (youtubeFrontend == 'invidious') instancesList = [...invidiousI2pCustomRedirects]; //...invidiousI2pRedirectsChecks, + if (youtubeFrontend == 'piped') instancesList = [...pipedI2pCustomRedirects]; //...pipedI2pRedirectsChecks, + if (youtubeFrontend == 'pipedMaterial') instancesList = [...pipedMaterialI2pCustomRedirects]; //...pipedMaterialI2pRedirectsChecks, + } + else if (protocol == 'tor') { if (youtubeFrontend == 'invidious') instancesList = [...invidiousTorRedirectsChecks, ...invidiousTorCustomRedirects]; if (youtubeFrontend == 'piped') instancesList = [...pipedTorRedirectsChecks, ...pipedTorCustomRedirects]; if (youtubeFrontend == 'pipedMaterial') instancesList = [...pipedMaterialTorRedirectsChecks, ...pipedMaterialTorCustomRedirects]; diff --git a/src/assets/javascripts/youtubeMusic.js b/src/assets/javascripts/youtubeMusic.js index fff2ebf..4a63911 100644 --- a/src/assets/javascripts/youtubeMusic.js +++ b/src/assets/javascripts/youtubeMusic.js @@ -12,26 +12,43 @@ let redirects = { "normal": [ "https://beatbump.ml" ], - "tor": [] + "tor": [], + "i2p": [], + "loki": [] }, }; let disableYoutubeMusic, + protocol, + protocolFallback, beatbumpNormalRedirectsChecks, - beatbumpNormalCustomRedirects; + beatbumpNormalCustomRedirects, + beatbumpTorCustomRedirects, + beatbumpI2pCustomRedirects, + beatbumpLokiCustomRedirects; function init() { browser.storage.local.get( [ "disableYoutubeMusic", + "protocol", + "protocolFallback", "beatbumpNormalRedirectsChecks", "beatbumpNormalCustomRedirects", + "beatbumpTorCustomRedirects", + "beatbumpI2pCustomRedirects", + "beatbumpLokiCustomRedirects" ], r => { disableYoutubeMusic = r.disableYoutubeMusic; + protocol = r.protocol; + protocolFallback = r.protocolFallback; beatbumpNormalRedirectsChecks = r.beatbumpNormalRedirectsChecks; beatbumpNormalCustomRedirects = r.beatbumpNormalCustomRedirects; + beatbumpTorCustomRedirects = r.beatbumpTorCustomRedirects; + beatbumpI2pCustomRedirects = r.beatbumpI2pCustomRedirects; + beatbumpLokiCustomRedirects = r.beatbumpLokiCustomRedirects; } ) } @@ -75,7 +92,13 @@ function redirect(url, disableOverride) { if (disableYoutubeMusic && !disableOverride) return; if (!targets.some(rx => rx.test(url.href))) return; - let instancesList = [...beatbumpNormalRedirectsChecks, ...beatbumpNormalCustomRedirects]; + let instancesList = []; + if (protocol == 'loki') instancesList = [...beatbumpLokiCustomRedirects]; + else if (protocol == 'i2p') instancesList = [...beatbumpI2pCustomRedirects]; + else if (protocol == 'tor') instancesList = [...beatbumpTorCustomRedirects]; + if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { + instancesList = [...beatbumpNormalRedirectsChecks, ...beatbumpNormalCustomRedirects]; + } if (instancesList.length === 0) return; const randomInstance = utils.getRandomInstance(instancesList); return `${randomInstance}${url.pathname}${url.search}` @@ -93,6 +116,12 @@ async function initDefaults() { beatbumpNormalRedirectsChecks: [...redirects.beatbump.normal], beatbumpNormalCustomRedirects: [], + + beatbumpTorCustomRedirects: [], + + beatbumpI2pCustomRedirects: [], + + beatbumpLokiCustomRedirects: [] }, () => resolve()) ) }