From f05e1b996a2b74c1d4e34038f4d2debb145ff841 Mon Sep 17 00:00:00 2001 From: BobIsMyManager Date: Wed, 13 Apr 2022 14:51:36 +0000 Subject: [PATCH] I2P support for search, Imgur and Wikipedia (#189) --- src/assets/javascripts/helpers/imgur.js | 76 +++++++--- src/assets/javascripts/helpers/search.js | 131 ++++++++++++++++-- src/assets/javascripts/helpers/wikipedia.js | 57 ++++++-- src/assets/javascripts/localise.js | 2 +- src/instances/data.json | 17 ++- src/instances/get_instances.py | 12 +- src/pages/options/imgur/imgur.html | 32 ++++- src/pages/options/imgur/imgur.js | 30 +++- src/pages/options/instagram/instagram.html | 4 +- src/pages/options/lbry/lbry.html | 4 +- src/pages/options/medium/medium.html | 4 +- src/pages/options/peertube/peertube.html | 4 +- src/pages/options/pixiv/pixiv.html | 6 +- src/pages/options/reddit/reddit.html | 4 +- src/pages/options/reddit/reddit.js | 2 +- src/pages/options/search/search.html | 76 +++++++++- src/pages/options/search/search.js | 55 +++++++- .../options/sendTargets/sendTargets.html | 4 +- src/pages/options/spotify/spotify.html | 4 +- src/pages/options/tiktok/tiktok.html | 4 +- src/pages/options/translate/translate.html | 6 +- src/pages/options/twitter/twitter.html | 4 +- src/pages/options/wikipedia/wikipedia.html | 32 ++++- src/pages/options/wikipedia/wikipedia.js | 21 ++- src/pages/options/youtube/youtube.html | 34 ++--- .../options/youtubeMusic/youtubeMusic.html | 42 +++--- .../options/youtubeMusic/youtubeMusic.js | 2 +- 27 files changed, 537 insertions(+), 132 deletions(-) diff --git a/src/assets/javascripts/helpers/imgur.js b/src/assets/javascripts/helpers/imgur.js index 91e30fd..56d26cc 100644 --- a/src/assets/javascripts/helpers/imgur.js +++ b/src/assets/javascripts/helpers/imgur.js @@ -2,24 +2,22 @@ window.browser = window.browser || window.chrome; import commonHelper from './common.js' -const targets = [ - /^https?:\/{2}([im]\.)?imgur\.com(\/|$)/ -]; +const targets = /^https?:\/{2}([im]\.)?imgur\.com(\/|$)/ let redirects = { "rimgo": { "normal": [], - "tor": [] + "tor": [], + "i2p": [] } } - const getRedirects = () => redirects; - const getCustomRedirects = function () { return { "rimgo": { "normal": [...rimgoNormalRedirectsChecks, ...rimgoNormalCustomRedirects], - "tor": [...rimgoTorRedirectsChecks, ...rimgoTorCustomRedirects] + "tor": [...rimgoTorRedirectsChecks, ...rimgoTorCustomRedirects], + "i2p": [...rimgoI2pRedirectsChecks, ...rimgoI2pCustomRedirects] }, }; }; @@ -36,11 +34,33 @@ function setRedirects(val) { setRimgoNormalRedirectsChecks(rimgoNormalRedirectsChecks); for (const item of rimgoTorRedirectsChecks) - if (!redirects.rimgo.normal.includes(item)) { + if (!redirects.rimgo.tor.includes(item)) { var index = rimgoTorRedirectsChecks.indexOf(item); if (index !== -1) rimgoTorRedirectsChecks.splice(index, 1); } setRimgoTorRedirectsChecks(rimgoTorRedirectsChecks); + + for (const item of rimgoI2pRedirectsChecks) + if (!redirects.rimgo.i2p.includes(item)) { + var index = rimgoI2pRedirectsChecks.indexOf(item); + if (index !== -1) rimgoI2pRedirectsChecks.splice(index, 1); + } + setRimgoI2pRedirectsChecks(rimgoI2pRedirectsChecks); +} + +let disable; +const getDisable = () => disable; +function setDisable(val) { + disable = val; + browser.storage.local.set({ disableImgur: disable }) +} + +let protocol; +const getProtocol = () => protocol; +function setProtocol(val) { + protocol = val; + browser.storage.local.set({ imgurProtocol: val }) + console.log("imgurProtocol: ", val) } let rimgoNormalRedirectsChecks; @@ -59,6 +79,14 @@ function setRimgoTorRedirectsChecks(val) { console.log("rimgoTorRedirectsChecks: ", val) } +let rimgoI2pRedirectsChecks; +const getRimgoI2pRedirectsChecks = () => rimgoI2pRedirectsChecks; +function setRimgoI2pRedirectsChecks(val) { + rimgoI2pRedirectsChecks = val; + browser.storage.local.set({ rimgoI2pRedirectsChecks }) + console.log("rimgoI2pRedirectsChecks: ", val) +} + let rimgoNormalCustomRedirects = []; const getRimgoNormalCustomRedirects = () => rimgoNormalCustomRedirects; function setRimgoNormalCustomRedirects(val) { @@ -75,19 +103,12 @@ function setRimgoTorCustomRedirects(val) { console.log("rimgoTorCustomRedirects: ", val) } -let disable; -const getDisable = () => disable; -function setDisable(val) { - disable = val; - browser.storage.local.set({ disableImgur: disable }) -} - -let protocol; -const getProtocol = () => protocol; -function setProtocol(val) { - protocol = val; - browser.storage.local.set({ imgurProtocol: val }) - console.log("imgurProtocol: ", val) +let rimgoI2pCustomRedirects = []; +const getRimgoI2pCustomRedirects = () => rimgoI2pCustomRedirects; +function setRimgoI2pCustomRedirects(val) { + rimgoI2pCustomRedirects = val; + browser.storage.local.set({ rimgoI2pCustomRedirects }) + console.log("rimgoI2pCustomRedirects: ", val) } function isImgur(url, initiator) { @@ -121,6 +142,7 @@ function redirect(url, type) { let instancesList; if (protocol == 'normal') instancesList = [...rimgoNormalRedirectsChecks, ...rimgoNormalCustomRedirects]; if (protocol == 'tor') instancesList = [...rimgoTorRedirectsChecks, ...rimgoTorCustomRedirects]; + if (protocol == 'i2p') instancesList = [...rimgoI2pRedirectsChecks, ...rimgoI2pCustomRedirects]; if (instancesList.length === 0) return null; let randomInstance = commonHelper.getRandomInstance(instancesList) @@ -133,15 +155,18 @@ function switchInstance(url) { let imgurList = [ ...redirects.rimgo.normal, ...redirects.rimgo.tor, + ...redirects.rimgo.i2p, ...rimgoNormalCustomRedirects, ...rimgoTorCustomRedirects, + ...rimgoI2pCustomRedirects, ]; if (!imgurList.includes(protocolHost)) return null; let instancesList; if (protocol == 'normal') instancesList = [...rimgoNormalCustomRedirects, ...rimgoNormalRedirectsChecks]; else if (protocol == 'tor') instancesList = [...rimgoTorCustomRedirects, ...rimgoTorRedirectsChecks]; + else if (protocol == 'i2p') instancesList = [...rimgoI2pCustomRedirects, ...rimgoI2pRedirectsChecks]; console.log("instancesList", instancesList); let index = instancesList.indexOf(protocolHost); @@ -168,6 +193,8 @@ async function init() { "rimgoNormalCustomRedirects", "rimgoTorRedirectsChecks", "rimgoTorCustomRedirects", + "rimgoI2pRedirectsChecks", + "rimgoI2pCustomRedirects", "imgurProtocol", ], @@ -185,6 +212,9 @@ async function init() { rimgoTorRedirectsChecks = r.rimgoTorRedirectsChecks ?? [...redirects.rimgo.tor]; rimgoTorCustomRedirects = r.rimgoTorCustomRedirects ?? []; + rimgoI2pRedirectsChecks = r.rimgoI2pRedirectsChecks ?? [...redirects.rimgo.i2p]; + rimgoI2pCustomRedirects = r.rimgoI2pCustomRedirects ?? []; + resolve(); } ) @@ -207,11 +237,15 @@ export default { setRimgoNormalRedirectsChecks, getRimgoTorRedirectsChecks, setRimgoTorRedirectsChecks, + getRimgoI2pRedirectsChecks, + setRimgoI2pRedirectsChecks, getRimgoNormalCustomRedirects, setRimgoNormalCustomRedirects, getRimgoTorCustomRedirects, setRimgoTorCustomRedirects, + getRimgoI2pCustomRedirects, + setRimgoI2pCustomRedirects, redirect, isImgur, diff --git a/src/assets/javascripts/helpers/search.js b/src/assets/javascripts/helpers/search.js index 26939ad..1a80586 100644 --- a/src/assets/javascripts/helpers/search.js +++ b/src/assets/javascripts/helpers/search.js @@ -20,7 +20,8 @@ let redirects = { }, "whoogle": { "normal": [], - "tor": [] + "tor": [], + "i2p": [] }, "startpage": { "normal": "https://www.startpage.com", @@ -33,14 +34,17 @@ const getCustomRedirects = () => { "searx": { "normal": [...searxNormalRedirectsChecks, ...searxNormalCustomRedirects], "tor": [...searxTorRedirectsChecks, ...searxTorCustomRedirects], + "i2p": [...searxI2pRedirectsChecks, ...searxI2pCustomRedirects] }, "searxng": { "normal": [...searxngNormalRedirectsChecks, ...searxngNormalCustomRedirects], "tor": [...searxngTorRedirectsChecks, ...searxngTorCustomRedirects], + "i2p": [...searxngI2pRedirectsChecks, ...searxngI2pCustomRedirects] }, "whoogle": { "normal": [...whoogleNormalRedirectsChecks, ...whoogleNormalCustomRedirects], - "normal": [...whoogleTorRedirectsChecks, ...whoogleTorCustomRedirects] + "tor": [...whoogleTorRedirectsChecks, ...whoogleTorCustomRedirects], + "i2p": [...whoogleI2pRedirectsChecks, ...whoogleI2pCustomRedirects] } }; }; @@ -60,6 +64,12 @@ function setSearxRedirects(val) { if (index !== -1) searxTorRedirectsChecks.splice(index, 1); } setSearxTorRedirectsChecks(searxTorRedirectsChecks); + + for (const item of searxI2pRedirectsChecks) if (!redirects.searx.i2p.includes(item)) { + var index = searxI2pRedirectsChecks.indexOf(item); + if (index !== -1) searxI2pRedirectsChecks.splice(index, 1); + } + setSearxI2pRedirectsChecks(searxI2pRedirectsChecks); } function setSearxngRedirects(val) { @@ -77,6 +87,12 @@ function setSearxngRedirects(val) { if (index !== -1) searxngTorRedirectsChecks.splice(index, 1); } setSearxngTorRedirectsChecks(searxngTorRedirectsChecks); + + for (const item of searxngI2pRedirectsChecks) if (!redirects.searxng.i2p.includes(item)) { + var index = searxngI2pRedirectsChecks.indexOf(item); + if (index !== -1) searxngI2pRedirectsChecks.splice(index, 1); + } + setSearxngI2pRedirectsChecks(searxngI2pRedirectsChecks); } function setWhoogleRedirects(val) { @@ -94,6 +110,12 @@ function setWhoogleRedirects(val) { if (index !== -1) whoogleTorRedirectsChecks.splice(index, 1); } setWhoogleTorRedirectsChecks(whoogleTorRedirectsChecks); + + for (const item of whoogleI2pRedirectsChecks) if (!redirects.whoogle.i2p.includes(item)) { + var index = whoogleI2pRedirectsChecks.indexOf(item); + if (index !== -1) whoogleI2pRedirectsChecks.splice(index, 1); + } + setWhoogleI2pRedirectsChecks(whoogleI2pRedirectsChecks); } let whoogleNormalRedirectsChecks; @@ -104,6 +126,14 @@ function setWhoogleNormalRedirectsChecks(val) { console.log("whoogleNormalRedirectsChecks: ", val) } +let whoogleI2pRedirectsChecks; +const getWhoogleI2pRedirectsChecks = () => whoogleI2pRedirectsChecks; +function setWhoogleI2pRedirectsChecks(val) { + whoogleI2pRedirectsChecks = val; + browser.storage.local.set({ whoogleI2pRedirectsChecks }) + console.log("whoogleI2pRedirectsChecks: ", val) +} + let whoogleTorRedirectsChecks; const getWhoogleTorRedirectsChecks = () => whoogleTorRedirectsChecks; function setWhoogleTorRedirectsChecks(val) { @@ -120,6 +150,14 @@ function setWhoogleNormalCustomRedirects(val) { console.log("whoogleNormalCustomRedirects: ", val) } +let whoogleI2pCustomRedirects = []; +const getWhoogleI2pCustomRedirects = () => whoogleI2pCustomRedirects; +function setWhoogleI2pCustomRedirects(val) { + whoogleI2pCustomRedirects = val; + browser.storage.local.set({ whoogleI2pCustomRedirects }) + console.log("whoogleI2pCustomRedirects: ", val) +} + let whoogleTorCustomRedirects = []; const getWhoogleTorCustomRedirects = () => whoogleTorCustomRedirects; function setWhoogleTorCustomRedirects(val) { @@ -136,6 +174,14 @@ function setSearxNormalRedirectsChecks(val) { console.log("searxNormalRedirectsChecks: ", val) } +let searxI2pRedirectsChecks; +const getSearxI2pRedirectsChecks = () => searxI2pRedirectsChecks; +function setSearxI2pRedirectsChecks(val) { + searxI2pRedirectsChecks = val; + browser.storage.local.set({ searxI2pRedirectsChecks }) + console.log("searxI2pRedirectsChecks: ", val) +} + let searxTorRedirectsChecks; const getSearxTorRedirectsChecks = () => searxTorRedirectsChecks; function setSearxTorRedirectsChecks(val) { @@ -152,6 +198,14 @@ function setSearxNormalCustomRedirects(val) { console.log("searxNormalCustomRedirects: ", val) } +let searxI2pCustomRedirects = []; +const getSearxI2pCustomRedirects = () => searxI2pCustomRedirects; +function setSearxI2pCustomRedirects(val) { + searxI2pCustomRedirects = val; + browser.storage.local.set({ searxI2pCustomRedirects }) + console.log("searxI2pCustomRedirects: ", val) +} + let searxTorCustomRedirects = []; const getSearxTorCustomRedirects = () => searxTorCustomRedirects; function setSearxTorCustomRedirects(val) { @@ -168,6 +222,14 @@ function setSearxngNormalRedirectsChecks(val) { console.log("searxngNormalRedirectsChecks: ", val) } +let searxngI2pRedirectsChecks; +const getSearxngI2pRedirectsChecks = () => searxngI2pRedirectsChecks; +function setSearxngI2pRedirectsChecks(val) { + searxngI2pRedirectsChecks = val; + browser.storage.local.set({ searxngI2pRedirectsChecks }) + console.log("searxngI2pRedirectsChecks: ", val) +} + let searxngTorRedirectsChecks; const getSearxngTorRedirectsChecks = () => searxngTorRedirectsChecks; function setSearxngTorRedirectsChecks(val) { @@ -184,6 +246,14 @@ function setSearxngNormalCustomRedirects(val) { console.log("searxngNormalCustomRedirects: ", val) } +let searxngI2pCustomRedirects = []; +const getSearxngI2pCustomRedirects = () => searxngI2pCustomRedirects; +function setSearxngI2pCustomRedirects(val) { + searxngI2pCustomRedirects = val; + browser.storage.local.set({ searxngI2pCustomRedirects }) + console.log("searxngI2pCustomRedirects: ", val) +} + let searxngTorCustomRedirects = []; const getSearxngTorCustomRedirects = () => searxngTorCustomRedirects; function setSearxngTorCustomRedirects(val) { @@ -223,8 +293,8 @@ function initSearxCookies() { if (theme == 'light') themeValue = 'logicodev'; if (theme == 'dark') themeValue = 'logicodev-dark'; if (applyThemeToSites && themeValue) { - let allInstances = [...redirects.searx.normal, ...redirects.searx.tor, ...searxNormalCustomRedirects, ...searxTorCustomRedirects] - let checkedInstances = [...searxNormalRedirectsChecks, ...searxNormalCustomRedirects, ...searxTorRedirectsChecks, ...searxTorCustomRedirects] + let allInstances = [...redirects.searx.normal, ...redirects.searx.tor, ...redirects.searx.i2p, ...searxNormalCustomRedirects, ...searxTorCustomRedirects, ...searxI2pCustomRedirects]; + let checkedInstances = [...searxNormalRedirectsChecks, ...searxNormalCustomRedirects, ...searxTorRedirectsChecks, ...searxTorCustomRedirects, ...searxI2pRedirectsChecks, ...searxI2pCustomRedirects]; for (const instanceUrl of allInstances) if (!checkedInstances.includes(instanceUrl)) { browser.cookies.remove({ @@ -256,8 +326,8 @@ function initSearxngCookies() { if (theme == 'light') themeValue = 'logicodev'; if (theme == 'dark') themeValue = 'logicodev-dark'; if (applyThemeToSites && themeValue) { - let allInstances = [...redirects.searxng.normal, ...redirects.searxng.tor, ...searxngNormalCustomRedirects, ...searxngTorCustomRedirects] - let checkedInstances = [...searxngNormalRedirectsChecks, ...searxngNormalCustomRedirects, ...searxngTorRedirectsChecks, ...searxngTorCustomRedirects] + let allInstances = [...redirects.searxng.normal, ...redirects.searxng.tor, ...redirects.searxng.i2p, ...searxngNormalCustomRedirects, ...searxngTorCustomRedirects, ...searxngI2pCustomRedirects]; + let checkedInstances = [...searxngNormalRedirectsChecks, ...searxngNormalCustomRedirects, ...searxngTorRedirectsChecks, ...searxngTorCustomRedirects, ...searxngI2pRedirectsChecks, ...searxngI2pCustomRedirects]; for (const instanceUrl of allInstances) if (!checkedInstances.includes(instanceUrl)) { browser.cookies.remove({ @@ -285,7 +355,7 @@ function initSearxngCookies() { } function initWhoogleCookies() { - let checkedInstances = [...whoogleNormalRedirectsChecks, ...whoogleNormalCustomRedirects, ...whoogleTorRedirectsChecks, ...whoogleTorCustomRedirects] + let checkedInstances = [...whoogleNormalRedirectsChecks, ...whoogleNormalCustomRedirects, ...whoogleTorRedirectsChecks, ...whoogleTorCustomRedirects, ...whoogleI2pRedirectsChecks, ...whoogleI2pCustomRedirects]; // for (const item of checkedInstances) { let request = new XMLHttpRequest(); @@ -336,6 +406,7 @@ function redirect(url) { let instancesList; if (protocol == 'normal') instancesList = [...searxNormalRedirectsChecks, ...searxNormalCustomRedirects]; else if (protocol == 'tor') instancesList = [...searxTorRedirectsChecks, ...searxTorCustomRedirects]; + else if (protocol == 'i2p') instancesList = [...searxI2pRedirectsChecks, ...searxI2pCustomRedirects]; if (instancesList.length === 0) return null; randomInstance = commonHelper.getRandomInstance(instancesList) path = "/"; @@ -344,6 +415,7 @@ function redirect(url) { let instancesList; if (protocol == 'normal') instancesList = [...searxngNormalRedirectsChecks, ...searxngNormalCustomRedirects]; else if (protocol == 'tor') instancesList = [...searxngTorRedirectsChecks, ...searxngTorCustomRedirects]; + else if (protocol == 'i2p') instancesList = [...searxngI2pRedirectsChecks, ...searxngI2pCustomRedirects]; if (instancesList.length === 0) return null; randomInstance = commonHelper.getRandomInstance(instancesList) path = "/"; @@ -352,6 +424,7 @@ function redirect(url) { let instancesList if (protocol == 'normal') instancesList = [...whoogleNormalRedirectsChecks, ...whoogleNormalCustomRedirects]; if (protocol == 'tor') instancesList = [...whoogleTorRedirectsChecks, ...whoogleTorCustomRedirects]; + if (protocol == 'i2p') instancesList = [...whoogleI2pRedirectsChecks, ...whoogleI2pCustomRedirects]; if (instancesList.length === 0) return null; randomInstance = commonHelper.getRandomInstance(instancesList) path = "/search"; @@ -374,21 +447,27 @@ function switchInstance(url) { let searchList = [ ...redirects.searx.normal, ...redirects.searx.tor, + ...redirects.searx.i2p, ...searxNormalCustomRedirects, ...searxTorCustomRedirects, + ...searxI2pCustomRedirects, ...redirects.searx.normal, ...redirects.searxng.tor, + ...redirects.searxng.i2p, ...searxngNormalCustomRedirects, ...searxngTorCustomRedirects, + ...searxngI2pCustomRedirects, ...redirects.whoogle.normal, ...redirects.whoogle.tor, + ...redirects.whoogle.i2p, ...whoogleNormalCustomRedirects, ...whoogleTorCustomRedirects, + ...whoogleI2pCustomRedirects, ] if (!searchList.includes(protocolHost)) return null; @@ -397,14 +476,17 @@ function switchInstance(url) { if (frontend == 'searx') { if (protocol == 'normal') instancesList = [...searxNormalRedirectsChecks, ...searxNormalCustomRedirects]; else if (protocol == 'tor') instancesList = [...searxTorRedirectsChecks, ...searxTorCustomRedirects]; + else if (protocol == 'i2p') instancesList = [...searxI2pRedirectsChecks, ...searxI2pCustomRedirects]; } else if (frontend == 'searxng') { if (protocol == 'normal') instancesList = [...searxngNormalRedirectsChecks, ...searxngNormalCustomRedirects]; else if (protocol == 'tor') instancesList = [...searxngTorRedirectsChecks, ...searxngTorCustomRedirects]; + else if (protocol == 'i2p') instancesList = [...searxngI2pRedirectsChecks, ...searxngI2pCustomRedirects]; } else if (frontend == 'whoogle') { if (protocol == 'normal') instancesList = [...whoogleNormalRedirectsChecks, ...whoogleNormalCustomRedirects]; else if (protocol == 'tor') instancesList = [...whoogleTorRedirectsChecks, ...whoogleTorCustomRedirects]; + else if (protocol == 'i2p') instancesList = [...whoogleI2pRedirectsChecks, ...whoogleI2pCustomRedirects]; } console.log("instancesList", instancesList); @@ -432,18 +514,27 @@ async function init() { "whoogleTorRedirectsChecks", "whoogleTorCustomRedirects", + + "whoogleI2pRedirectsChecks", + "whoogleI2pCustomRedirects", "searxNormalRedirectsChecks", "searxNormalCustomRedirects", "searxTorRedirectsChecks", "searxTorCustomRedirects", + + "searxI2pRedirectsChecks", + "searxI2pCustomRedirects", "searxngNormalRedirectsChecks", "searxngNormalCustomRedirects", "searxngTorRedirectsChecks", "searxngTorCustomRedirects", + + "searxngI2pRedirectsChecks", + "searxngI2pCustomRedirects", "theme", "applyThemeToSites", @@ -471,18 +562,27 @@ async function init() { whoogleTorRedirectsChecks = r.whoogleTorRedirectsChecks ?? [...redirects.whoogle.tor]; whoogleTorCustomRedirects = r.whoogleTorCustomRedirects ?? []; + whoogleI2pRedirectsChecks = r.whoogleI2pRedirectsChecks ?? [...redirects.whoogle.i2p]; + whoogleI2pCustomRedirects = r.whoogleI2pCustomRedirects ?? []; + searxNormalRedirectsChecks = r.searxNormalRedirectsChecks ?? [...redirects.searx.normal]; searxNormalCustomRedirects = r.searxNormalCustomRedirects ?? []; searxTorRedirectsChecks = r.searxTorRedirectsChecks ?? [...redirects.searx.tor]; searxTorCustomRedirects = r.searxTorCustomRedirects ?? []; + + searxI2pRedirectsChecks = r.searxI2pRedirectsChecks ?? [...redirects.searx.i2p]; + searxI2pCustomRedirects = r.searxI2pCustomRedirects ?? []; searxngNormalRedirectsChecks = r.searxngNormalRedirectsChecks ?? [...redirects.searxng.normal]; searxngNormalCustomRedirects = r.searxngNormalCustomRedirects ?? []; searxngTorRedirectsChecks = r.searxngTorRedirectsChecks ?? [...redirects.searxng.tor]; searxngTorCustomRedirects = r.searxngTorCustomRedirects ?? []; - + + searxngI2pRedirectsChecks = r.searxngI2pRedirectsChecks ?? [...redirects.searxng.i2p]; + searxngI2pCustomRedirects = r.searxngI2pCustomRedirects ?? []; + initSearxCookies() initSearxngCookies() // initWhoogleCookies() @@ -519,6 +619,11 @@ export default { getWhoogleTorCustomRedirects, setWhoogleTorCustomRedirects, + getWhoogleI2pRedirectsChecks, + setWhoogleI2pRedirectsChecks, + getWhoogleI2pCustomRedirects, + setWhoogleI2pCustomRedirects, + getSearxNormalRedirectsChecks, setSearxNormalRedirectsChecks, getSearxNormalCustomRedirects, @@ -529,6 +634,11 @@ export default { getSearxTorCustomRedirects, setSearxTorCustomRedirects, + getSearxI2pRedirectsChecks, + setSearxI2pRedirectsChecks, + getSearxI2pCustomRedirects, + setSearxI2pCustomRedirects, + getSearxngNormalRedirectsChecks, setSearxngNormalRedirectsChecks, getSearxngNormalCustomRedirects, @@ -539,6 +649,11 @@ export default { getSearxngTorCustomRedirects, setSearxngTorCustomRedirects, + getSearxngI2pRedirectsChecks, + setSearxngI2pRedirectsChecks, + getSearxngI2pCustomRedirects, + setSearxngI2pCustomRedirects, + getProtocol, setProtocol, diff --git a/src/assets/javascripts/helpers/wikipedia.js b/src/assets/javascripts/helpers/wikipedia.js index 7a4173f..42ca87d 100644 --- a/src/assets/javascripts/helpers/wikipedia.js +++ b/src/assets/javascripts/helpers/wikipedia.js @@ -6,15 +6,9 @@ const targets = /^https?:\/{2}([a-z]{1,}\.|)wikipedia\.org/ let redirects = { "wikiless": { - "normal": [ - "https://wikiless.org", - "https://wikiless.alefvanoon.xyz", - "https://wikiless.sethforprivacy.com", - "https://wiki.604kph.xyz" - ], - "tor": [ - "http://dj2tbh2nqfxyfmvq33cjmhuw7nb6am7thzd3zsjvizeqf374fixbrxyd.onion" - ] + "normal": [], + "tor": [], + "i2p": [] } }; const getRedirects = () => redirects; @@ -22,7 +16,8 @@ const getCustomRedirects = function () { return { "wikiless": { "normal": [...wikilessNormalRedirectsChecks, ...wikilessNormalCustomRedirects], - "tor": [...wikilessTorRedirectsChecks, ...wikilessTorCustomRedirects] + "tor": [...wikilessTorRedirectsChecks, ...wikilessTorCustomRedirects], + "i2p": [...wikilessI2pRedirectsChecks, ...wikilessI2pCustomRedirects] }, }; }; @@ -39,11 +34,18 @@ function setRedirects(val) { setWikilessNormalRedirectsChecks(wikilessNormalRedirectsChecks); for (const item of wikilessTorRedirectsChecks) - if (!redirects.wikiless.normal.includes(item)) { + if (!redirects.wikiless.tor.includes(item)) { var index = wikilessTorRedirectsChecks.indexOf(item); if (index !== -1) wikilessTorRedirectsChecks.splice(index, 1); } setWikilessTorRedirectsChecks(wikilessTorRedirectsChecks); + + for (const item of wikilessI2pRedirectsChecks) + if (!redirects.wikiless.i2p.includes(item)) { + var index = wikilessI2pRedirectsChecks.indexOf(item); + if (index !== -1) wikilessI2pRedirectsChecks.splice(index, 1); + } + setWikilessI2pRedirectsChecks(wikilessI2pRedirectsChecks); } let disable; @@ -61,7 +63,6 @@ function setProtocol(val) { console.log("wikipediaProtocol: ", val) } - let wikilessNormalRedirectsChecks; const getWikilessNormalRedirectsChecks = () => wikilessNormalRedirectsChecks; function setWikilessNormalRedirectsChecks(val) { @@ -78,6 +79,13 @@ function setWikilessTorRedirectsChecks(val) { console.log("wikilessTorRedirectsChecks: ", val) } +let wikilessI2pRedirectsChecks; +const getWikilessI2pRedirectsChecks = () => wikilessI2pRedirectsChecks; +function setWikilessI2pRedirectsChecks(val) { + wikilessI2pRedirectsChecks = val; + browser.storage.local.set({ wikilessI2pRedirectsChecks }) + console.log("wikilessI2pRedirectsChecks: ", val) +} let wikilessNormalCustomRedirects = []; const getWikilessNormalCustomRedirects = () => wikilessNormalCustomRedirects; @@ -95,6 +103,14 @@ function setWikilessTorCustomRedirects(val) { console.log("wikilessTorCustomRedirects: ", val) } +let wikilessI2pCustomRedirects = []; +const getWikilessI2pCustomRedirects = () => wikilessI2pCustomRedirects; +function setWikilessI2pCustomRedirects(val) { + wikilessI2pCustomRedirects = val; + browser.storage.local.set({ wikilessI2pCustomRedirects }) + console.log("wikilessI2pCustomRedirects: ", val) +} + let theme; let applyThemeToSites; function initWikilessCookies() { @@ -102,8 +118,8 @@ function initWikilessCookies() { if (theme == 'light') themeValue = 'white'; if (theme == 'dark') themeValue = 'dark'; if (applyThemeToSites && themeValue) { - let allInstances = [...redirects.wikiless.normal, ...redirects.wikiless.tor, ...wikilessNormalCustomRedirects, ...wikilessTorCustomRedirects] - let checkedInstances = [...wikilessNormalRedirectsChecks, ...wikilessNormalCustomRedirects, ...wikilessTorRedirectsChecks, ...wikilessTorCustomRedirects] + let allInstances = [...redirects.wikiless.normal, ...redirects.wikiless.tor, ...redirects.wikiless.i2p, ...wikilessNormalCustomRedirects, ...wikilessTorCustomRedirects, ...wikilessI2pCustomRedirects] + let checkedInstances = [...wikilessNormalRedirectsChecks, ...wikilessNormalCustomRedirects, ...wikilessTorRedirectsChecks, ...wikilessTorCustomRedirects, ...wikilessI2pRedirectsChecks, ...wikilessI2pCustomRedirects] for (const instanceUrl of allInstances) if (!checkedInstances.includes(instanceUrl)) browser.cookies.remove({ @@ -135,6 +151,7 @@ function redirect(url) { let instancesList; if (protocol == 'normal') instancesList = [...wikilessNormalRedirectsChecks, ...wikilessNormalCustomRedirects]; else if (protocol == 'tor') instancesList = [...wikilessTorRedirectsChecks, ...wikilessTorCustomRedirects]; + else if (protocol == 'i2p') instancesList = [...wikilessI2pRedirectsChecks, ...wikilessI2pCustomRedirects]; if (instancesList.length === 0) return null; let randomInstance = commonHelper.getRandomInstance(instancesList) @@ -162,15 +179,18 @@ function switchInstance(url) { let wikipediaList = [ ...redirects.wikiless.normal, ...redirects.wikiless.tor, + ...redirects.wikiless.i2p, ...wikilessNormalCustomRedirects, ...wikilessTorCustomRedirects, + ...wikilessI2pCustomRedirects ] if (!wikipediaList.includes(protocolHost)) return null; let instancesList; if (protocol == 'normal') instancesList = [...wikilessNormalCustomRedirects, ...wikilessNormalRedirectsChecks]; else if (protocol == 'tor') instancesList = [...wikilessTorCustomRedirects, ...wikilessTorRedirectsChecks]; + else if (protocol == 'i2p') instancesList = [...wikilessI2pCustomRedirects, ...wikilessI2pRedirectsChecks]; console.log("instancesList", instancesList); let index = instancesList.indexOf(protocolHost); @@ -192,8 +212,10 @@ async function init() { "wikipediaRedirects", "wikilessNormalRedirectsChecks", "wikilessTorRedirectsChecks", + "wikilessI2pRedirectsChecks", "wikilessNormalCustomRedirects", "wikilessTorCustomRedirects", + "wikilessI2pCustomRedirects", "wikipediaProtocol", "theme", @@ -213,6 +235,9 @@ async function init() { wikilessTorRedirectsChecks = r.wikilessTorRedirectsChecks ?? [...redirects.wikiless.tor]; wikilessTorCustomRedirects = r.wikilessTorCustomRedirects ?? []; + wikilessI2pRedirectsChecks = r.wikilessI2pRedirectsChecks ?? [...redirects.wikiless.i2p]; + wikilessI2pCustomRedirects = r.wikilessI2pCustomRedirects ?? []; + theme = r.theme ?? 'DEFAULT'; applyThemeToSites = r.applyThemeToSites ?? false; @@ -240,11 +265,15 @@ export default { setWikilessNormalRedirectsChecks, getWikilessTorRedirectsChecks, setWikilessTorRedirectsChecks, + getWikilessI2pRedirectsChecks, + setWikilessI2pRedirectsChecks, getWikilessNormalCustomRedirects, setWikilessNormalCustomRedirects, getWikilessTorCustomRedirects, setWikilessTorCustomRedirects, + getWikilessI2pCustomRedirects, + setWikilessI2pCustomRedirects, initWikilessCookies, diff --git a/src/assets/javascripts/localise.js b/src/assets/javascripts/localise.js index 7c24d6c..752a6dd 100644 --- a/src/assets/javascripts/localise.js +++ b/src/assets/javascripts/localise.js @@ -36,4 +36,4 @@ localisePage(); export default { localisePage -} \ No newline at end of file +} diff --git a/src/instances/data.json b/src/instances/data.json index c189a89..c8c57ed 100644 --- a/src/instances/data.json +++ b/src/instances/data.json @@ -35,7 +35,8 @@ }, "proxiTok": { "normal": [ - "https://proxitok.herokuapp.com" + "https://proxitok.herokuapp.com", + "https://proxitok.pussthecat.org/" ], "tor": [] }, @@ -441,7 +442,8 @@ "https://whoogle.esmailelbob.xyz", "https://whoogle.lunar.icu" ], - "tor": [] + "tor": [], + "i2p": [] }, "rimgo": { "normal": [ @@ -452,14 +454,16 @@ "https://rimgo.bus-hit.me", "https://rimgo.esmailelbob.xyz", "https://rimgo.lunar.icu", - "https://i.actionsack.com", - "https://xazdnfgtzmcbcxhmcbbvr4uodd6jtn4fdiayasghywdn227xsmoa.b32.i2p" + "https://i.actionsack.com" ], "tor": [ "http://l4d4owboqr6xcmd6lf64gbegel62kbudu3x3jnldz2mx6mhn3bsv3zyd.onion", "http://jx3dpcwedpzu2mh54obk5gvl64i2ln7pt5mrzd75s4jnndkqwzaim7ad.onion", "http://rimgo.lqs5fjmajyp7rvp4qvyubwofzi6d4imua7vs237rkc4m5qogitqwrgyd.onion", "http://be7udfhmnzqyt7cxysg6c4pbawarvaofjjywp35nhd5qamewdfxl6sid.onion" + ], + "i2p": [ + "http://xazdnfgtzmcbcxhmcbbvr4uodd6jtn4fdiayasghywdn227xsmoa.b32.i2p" ] }, "peertube": [ @@ -632,7 +636,6 @@ "https://peertube.noussommes.org", "https://exode.me", "https://megatube.lilomoino.fr", - "https://zapping.no-ip.info", "https://video.anartist.org", "https://peertube.home.x0r.fr", "https://peertube.marud.fr", @@ -679,7 +682,6 @@ "https://video.firehawk-systems.com", "https://tube.otter.sh", "https://replay.jres.org", - "https://videonaute.fr", "https://peertube.lagob.fr", "https://peertube.gcaillaut.fr", "https://peertube.hellsite.net", @@ -690,7 +692,6 @@ "https://nattyvideo.com", "https://video.zarchbox.ovh", "https://video-vision.elemsys.com", - "https://videos.ysarris.xyz", "https://video.sgiath.dev", "https://videos.b4tech.org", "https://video.off-investigation.fr", @@ -851,7 +852,6 @@ "https://pony.tube", "https://peertube.umeahackerspace.se", "https://tube.okcinfo.news", - "https://stream.conesphere.cloud", "https://www.rocaguinarda.tv", "https://videos.wirtube.de", "https://tube.tinfoil-hat.net", @@ -1143,7 +1143,6 @@ "https://tube-creteil.beta.education.fr", "https://tube.saumon.io", "https://tube-paris.beta.education.fr", - "https://videos.judrey.eu", "https://theater.ethernia.net", "https://watch.tubelab.video", "https://lastbreach.tv", diff --git a/src/instances/get_instances.py b/src/instances/get_instances.py index 0d4c9a6..d0c325c 100644 --- a/src/instances/get_instances.py +++ b/src/instances/get_instances.py @@ -231,8 +231,14 @@ tmpList = r.text.strip().split('\n') whoogleList = {} whoogleList['normal'] = [] whoogleList['tor'] = [] +whoogleList['i2p'] = [] for item in tmpList: - whoogleList['normal'].append(item) + if item.endswith('.onion'): + whoogleList['tor'].append(item) + elif item.endswith('.i2p'): + whoogleList['i2p'].append(item) + else: + whoogleList['normal'].append(item) mightyList['whoogle'] = whoogleList print(Fore.GREEN + 'fetched ' + Style.RESET_ALL + 'Whoogle') @@ -243,10 +249,12 @@ rJson = json.loads(r.text) rimgoList = {} rimgoList['normal'] = [] rimgoList['tor'] = [] - +rimgoList['i2p'] = [] for item in rJson: if item.endswith('.onion'): rimgoList['tor'].append('http://' + item) + elif item.endswith('.i2p'): + rimgoList['i2p'].append('http://' + item) else: rimgoList['normal'].append('https://' + item) mightyList['rimgo'] = rimgoList diff --git a/src/pages/options/imgur/imgur.html b/src/pages/options/imgur/imgur.html index a769bd0..b00c7d7 100644 --- a/src/pages/options/imgur/imgur.html +++ b/src/pages/options/imgur/imgur.html @@ -139,6 +139,7 @@ @@ -167,6 +168,7 @@
+

Default Instances

@@ -178,7 +180,7 @@
- +
+ +
+
+

Default Instances

+
+
+
+
+

Custom Instances

+
+
+
+ + +
+
+
+
+
- - \ No newline at end of file + diff --git a/src/pages/options/imgur/imgur.js b/src/pages/options/imgur/imgur.js index 9742bfd..26a7d41 100644 --- a/src/pages/options/imgur/imgur.js +++ b/src/pages/options/imgur/imgur.js @@ -18,13 +18,21 @@ protocolElement.addEventListener("change", function changeProtocolSettings(protocol) { let normalDiv = document.getElementsByClassName("normal")[0]; let torDiv = document.getElementsByClassName("tor")[0]; + let i2pDiv = document.getElementsByClassName("i2p")[0]; if (protocol == 'normal') { - normalDiv.style.display = 'block'; - torDiv.style.display = 'none'; + normalDiv.style.display = 'block'; + torDiv.style.display = 'none'; + i2pDiv.style.display = 'none'; } else if (protocol == 'tor') { - normalDiv.style.display = 'none'; - torDiv.style.display = 'block'; + normalDiv.style.display = 'none'; + torDiv.style.display = 'block'; + i2pDiv.style.display = 'none'; + } + else if (protocol == 'i2p') { + normalDiv.style.display = 'none'; + torDiv.style.display = 'none'; + i2pDiv.style.display = 'block'; } } @@ -32,6 +40,7 @@ imgurHelper.init().then(() => { disableImgurElement.checked = !imgurHelper.getDisable(); let protocol = imgurHelper.getProtocol(); + console.log('protocol', protocol); protocolElement.value = protocol; changeProtocolSettings(protocol); @@ -56,4 +65,15 @@ imgurHelper.init().then(() => { imgurHelper.getRimgoTorCustomRedirects, imgurHelper.setRimgoTorCustomRedirects ); -}); \ No newline at end of file + + commonHelper.processDefaultCustomInstances( + 'rimgo', + 'i2p', + imgurHelper, + document, + imgurHelper.getRimgoI2pRedirectsChecks, + imgurHelper.setRimgoI2pRedirectsChecks, + imgurHelper.getRimgoI2pCustomRedirects, + imgurHelper.setRimgoI2pCustomRedirects + ); +}); diff --git a/src/pages/options/instagram/instagram.html b/src/pages/options/instagram/instagram.html index baf5166..ced087b 100644 --- a/src/pages/options/instagram/instagram.html +++ b/src/pages/options/instagram/instagram.html @@ -171,7 +171,7 @@
- +
- +
- +
- +
- +
- +
- +
- +
@@ -210,6 +211,30 @@
+
+
+

Default Instances

+
+
+
+
+
+

Custom Instances

+
+
+
+ + +
+
+
+
@@ -262,6 +287,30 @@
+
+
+

Default Instances

+
+
+
+
+
+

Custom Instances

+
+
+
+ + +
+
+
+
@@ -314,6 +363,30 @@
+
+
+

Default Instances

+
+
+
+
+
+

Custom Instances

+
+
+
+ + +
+
+
+
@@ -324,4 +397,5 @@ - \ No newline at end of file + + diff --git a/src/pages/options/search/search.js b/src/pages/options/search/search.js index d96665e..0eeac5e 100644 --- a/src/pages/options/search/search.js +++ b/src/pages/options/search/search.js @@ -63,12 +63,15 @@ protocolElement.addEventListener("change", function changeProtocolSettings(protocol) { let normalsearxDiv = searxDivElement.getElementsByClassName("normal")[0]; let torsearxDiv = searxDivElement.getElementsByClassName("tor")[0]; + let i2psearxDiv = searxDivElement.getElementsByClassName("i2p")[0]; let normalsearxngDiv = searxngDivElement.getElementsByClassName("normal")[0]; let torsearxngDiv = searxngDivElement.getElementsByClassName("tor")[0]; + let i2psearxngDiv = searxngDivElement.getElementsByClassName("i2p")[0]; let normalwhoogleDiv = whoogleDivElement.getElementsByClassName("normal")[0]; let torwhoogleDiv = whoogleDivElement.getElementsByClassName("tor")[0]; + let i2pwhoogleDiv = whoogleDivElement.getElementsByClassName("i2p")[0]; if (protocol == 'normal') { normalsearxDiv.style.display = 'block'; @@ -77,6 +80,9 @@ function changeProtocolSettings(protocol) { torsearxDiv.style.display = 'none'; torsearxngDiv.style.display = 'none'; torwhoogleDiv.style.display = 'none'; + i2psearxDiv.style.display = 'none'; + i2psearxngDiv.style.display = 'none'; + i2pwhoogleDiv.style.display = 'none'; } else if (protocol == 'tor') { normalsearxDiv.style.display = 'none'; @@ -85,6 +91,20 @@ function changeProtocolSettings(protocol) { torsearxDiv.style.display = 'block'; torsearxngDiv.style.display = 'block'; torwhoogleDiv.style.display = 'block'; + i2psearxDiv.style.display = 'none'; + i2psearxngDiv.style.display = 'none'; + i2pwhoogleDiv.style.display = 'none'; + } + else if (protocol == 'i2p') { + normalsearxDiv.style.display = 'none'; + normalsearxngDiv.style.display = 'none'; + normalwhoogleDiv.style.display = 'none'; + torsearxDiv.style.display = 'none'; + torsearxngDiv.style.display = 'none'; + torwhoogleDiv.style.display = 'none'; + i2psearxDiv.style.display = 'block'; + i2psearxngDiv.style.display = 'block'; + i2pwhoogleDiv.style.display = 'block'; } } @@ -120,6 +140,17 @@ searchHelper.init().then(() => { searchHelper.setSearxTorCustomRedirects ); + commonHelper.processDefaultCustomInstances( + 'searx', + 'i2p', + searchHelper, + document, + searchHelper.getSearxI2pRedirectsChecks, + searchHelper.setSearxI2pRedirectsChecks, + searchHelper.getSearxI2pCustomRedirects, + searchHelper.setSearxI2pCustomRedirects + ); + commonHelper.processDefaultCustomInstances( 'searxng', 'normal', @@ -142,6 +173,17 @@ searchHelper.init().then(() => { searchHelper.setSearxngTorCustomRedirects ); + commonHelper.processDefaultCustomInstances( + 'searxng', + 'i2p', + searchHelper, + document, + searchHelper.getSearxngI2pRedirectsChecks, + searchHelper.setSearxngI2pRedirectsChecks, + searchHelper.getSearxngI2pCustomRedirects, + searchHelper.setSearxngI2pCustomRedirects + ); + commonHelper.processDefaultCustomInstances( 'whoogle', 'normal', @@ -163,4 +205,15 @@ searchHelper.init().then(() => { searchHelper.getWhoogleTorCustomRedirects, searchHelper.setWhoogleTorCustomRedirects ); -}); \ No newline at end of file + + commonHelper.processDefaultCustomInstances( + 'whoogle', + 'i2p', + searchHelper, + document, + searchHelper.getWhoogleI2pRedirectsChecks, + searchHelper.setWhoogleI2pRedirectsChecks, + searchHelper.getWhoogleI2pCustomRedirects, + searchHelper.setWhoogleI2pCustomRedirects + ); +}); diff --git a/src/pages/options/sendTargets/sendTargets.html b/src/pages/options/sendTargets/sendTargets.html index 7da5d1f..786b310 100644 --- a/src/pages/options/sendTargets/sendTargets.html +++ b/src/pages/options/sendTargets/sendTargets.html @@ -178,7 +178,7 @@
- +
- +
- +
- +
- +
- +
@@ -180,7 +181,7 @@
- +
- + +
+
+

Default Instances

+
+
+
+
+
+

Custom Instances

+
+
+
+ + +
+
+
+
+ @@ -201,4 +227,4 @@ - \ No newline at end of file + diff --git a/src/pages/options/wikipedia/wikipedia.js b/src/pages/options/wikipedia/wikipedia.js index 1cad27a..a2dafbf 100644 --- a/src/pages/options/wikipedia/wikipedia.js +++ b/src/pages/options/wikipedia/wikipedia.js @@ -18,13 +18,21 @@ protocolElement.addEventListener("change", function changeProtocolSettings(protocol) { let normalDiv = document.getElementsByClassName("normal")[0]; let torDiv = document.getElementsByClassName("tor")[0]; + let i2pDiv = document.getElementsByClassName("i2p")[0]; if (protocol == 'normal') { normalDiv.style.display = 'block'; torDiv.style.display = 'none'; + i2pDiv.style.display = 'none'; } else if (protocol == 'tor') { normalDiv.style.display = 'none'; torDiv.style.display = 'block'; + i2pDiv.style.display = 'none'; + } + else if (protocol == 'i2p') { + normalDiv.style.display = 'none'; + torDiv.style.display = 'none'; + i2pDiv.style.display = 'block'; } } @@ -57,4 +65,15 @@ wikipediaHelper.init().then(() => { wikipediaHelper.getWikilessTorCustomRedirects, wikipediaHelper.setWikilessTorCustomRedirects ) -}) \ No newline at end of file + + commonHelper.processDefaultCustomInstances( + 'wikiless', + 'i2p', + wikipediaHelper, + document, + wikipediaHelper.getWikilessI2pRedirectsChecks, + wikipediaHelper.setWikilessI2pRedirectsChecks, + wikipediaHelper.getWikilessI2pCustomRedirects, + wikipediaHelper.setWikilessI2pCustomRedirects + ) +}) diff --git a/src/pages/options/youtube/youtube.html b/src/pages/options/youtube/youtube.html index 95ebb7d..e29fefb 100644 --- a/src/pages/options/youtube/youtube.html +++ b/src/pages/options/youtube/youtube.html @@ -15,7 +15,7 @@ diff --git a/src/pages/options/youtubeMusic/youtubeMusic.js b/src/pages/options/youtubeMusic/youtubeMusic.js index 5ae354d..597458d 100644 --- a/src/pages/options/youtubeMusic/youtubeMusic.js +++ b/src/pages/options/youtubeMusic/youtubeMusic.js @@ -19,4 +19,4 @@ youtubeMusicHelper.init().then(() => { youtubeMusicHelper.getBeatbumpNormalCustomRedirects, youtubeMusicHelper.setBeatbumpNormalCustomRedirects ) -}); \ No newline at end of file +});