diff options
author | BobIsMyManager <bimmgitsignature.nly8m@simplelogin.co> | 2022-07-21 21:30:46 +0100 |
---|---|---|
committer | BobIsMyManager <bimmgitsignature.nly8m@simplelogin.co> | 2022-07-21 21:30:46 +0100 |
commit | f4dc7ded61079a8d564bd804fad00a7f4f904319 (patch) | |
tree | 06b2df78b2a55411c4b4aa39afea9e9579ecf9df | |
parent | No more trailing slashes (diff) | |
download | libredirect-f4dc7ded61079a8d564bd804fad00a7f4f904319.zip |
WIP: Optimization, resolve incorrect protocol storage, unified protocol settings...
Optmizations still throw a lot of errors, this will be resolved Custom instances of previously unused protocols do not save, this will be resolved Track version number locally for easier config migration in the future
Diffstat (limited to '')
61 files changed, 2649 insertions, 1357 deletions
diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index d3b7a355..024ba454 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -75,10 +75,6 @@ "message": "Medium", "description": "used in the settings page" }, - "tor": { - "message": "Tor", - "description": "used in the settings page" - }, "theme": { "message": "Theme", "description": "used in the settings page" @@ -206,13 +202,10 @@ "lbry": { "message": "LBRY" }, - "i2p": { - "message": "I2P" - }, - "loki": { - "message": "Lokinet" - }, "testInstancesLatency": { "message": "Test Instances Latency" + }, + "protocolFallback": { + "message": "Fallback to normal if no frontends are available for the current protocol" } } diff --git a/src/assets/javascripts/general.js b/src/assets/javascripts/general.js index f778d876..1c27a55d 100644 --- a/src/assets/javascripts/general.js +++ b/src/assets/javascripts/general.js @@ -44,6 +44,8 @@ async function initDefaults() { ], autoRedirect: false, firstPartyIsolate: false, + protocol: "normal", + protocolFallback: true }, () => resolve()) ) } diff --git a/src/assets/javascripts/imdb.js b/src/assets/javascripts/imdb.js index 0061b7e3..de1293af 100644 --- a/src/assets/javascripts/imdb.js +++ b/src/assets/javascripts/imdb.js @@ -3,15 +3,21 @@ window.browser = window.browser || window.chrome; import utils from './utils.js' const targets = [ - /^https?:\/{2}(www\.|)imdb\.com.*/ + /^https?:\/{2}(?:www\.|)imdb\.com.*/ ]; -let redirects = { - "libremdb": { - "normal": [], - "tor": [] +const frontends = new Array("libremdb") +const protocols = new Array("normal", "tor", "i2p", "loki") + +let redirects = {} + +for (let i = 0; i < frontends.length; i++) { + redirects[frontends[i]] = {} + for (let x = 0; x < protocols.length; x++) { + redirects[frontends[i]][protocols[x]] = [] } } + function setRedirects(val) { browser.storage.local.get('cloudflareBlackList', r => { redirects.libremdb = val; @@ -29,7 +35,8 @@ function setRedirects(val) { let disableImdb, - imdbProtocol, + protocol, + protocolFallback, imdbRedirects, libremdbNormalRedirectsChecks, libremdbNormalCustomRedirects, @@ -41,7 +48,8 @@ function init() { browser.storage.local.get( [ "disableImdb", - "imdbProtocol", + "protocol", + "protocolFallback", "imdbRedirects", "libremdbNormalRedirectsChecks", "libremdbNormalCustomRedirects", @@ -50,7 +58,8 @@ function init() { ], r => { disableImdb = r.disableImdb; - imdbProtocol = r.imdbProtocol; + protocol = r.protocol; + protocolFallback = r.protocolFallback; imdbRedirects = r.imdbRedirects; libremdbNormalRedirectsChecks = r.libremdbNormalRedirectsChecks; libremdbNormalCustomRedirects = r.libremdbNormalCustomRedirects; @@ -76,10 +85,12 @@ function redirect(url, type, initiator, disableOverride) { if (initiator && (all.includes(initiator.origin) || targets.includes(initiator.host))) return; if (!targets.some(rx => rx.test(url.href))) return; - let instancesList; - if (imdbProtocol == 'normal') instancesList = [...libremdbNormalRedirectsChecks, ...libremdbNormalCustomRedirects]; - if (imdbProtocol == 'tor') instancesList = [...libremdbTorRedirectsChecks, ...libremdbTorCustomRedirects]; - if (instancesList.length === 0) return; + let instancesList = []; + if (protocol == 'tor') instancesList = [...libremdbTorRedirectsChecks, ...libremdbTorCustomRedirects]; + if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { + instancesList = [...libremdbNormalRedirectsChecks, ...libremdbNormalCustomRedirects]; + } + if (instancesList.length === 0) { return; } const randomInstance = utils.getRandomInstance(instancesList); return `${randomInstance}${url.pathname}`; @@ -115,9 +126,11 @@ function switchInstance(url, disableOverride) { ]; if (!all.includes(protocolHost)) { resolve(); return; } - let instancesList; - if (imdbProtocol == 'normal') instancesList = [...libremdbNormalCustomRedirects, ...libremdbNormalRedirectsChecks]; - else if (imdbProtocol == 'tor') instancesList = [...libremdbTorCustomRedirects, ...libremdbTorRedirectsChecks]; + let instancesList = []; + if (protocol == 'tor') instancesList = [...libremdbTorRedirectsChecks, ...libremdbTorCustomRedirects]; + if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { + instancesList = [...libremdbNormalRedirectsChecks, ...libremdbNormalCustomRedirects]; + } const i = instancesList.indexOf(protocolHost); if (i > -1) instancesList.splice(i, 1); @@ -132,11 +145,11 @@ function initDefaults() { return new Promise(async resolve => { fetch('/instances/data.json').then(response => response.text()).then(async data => { let dataJson = JSON.parse(data); - redirects.libremdb = dataJson.libremdb; + for (let i = 0; i < frontends.length; i++) { + redirects[frontends[i]] = dataJson[frontends[i]] + } browser.storage.local.set({ disableImdb: true, - imdbProtocol: "normal", - imdbRedirects: redirects, libremdbNormalRedirectsChecks: [...redirects.libremdb.normal], diff --git a/src/assets/javascripts/imgur.js b/src/assets/javascripts/imgur.js index 8cf54265..dafebb9c 100644 --- a/src/assets/javascripts/imgur.js +++ b/src/assets/javascripts/imgur.js @@ -4,13 +4,18 @@ import utils from './utils.js' const targets = /^https?:\/{2}([im]\.)?imgur\.(com|io)(\/|$)/ -let redirects = { - "rimgo": { - "normal": [], - "tor": [], - "i2p": [] +const frontends = new Array("rimgo") +const protocols = new Array("normal", "tor", "i2p", "loki") + +let redirects = {} + +for (let i = 0; i < frontends.length; i++) { + redirects[frontends[i]] = {} + for (let x = 0; x < protocols.length; x++) { + redirects[frontends[i]][protocols[x]] = [] } } + function setRedirects() { return new Promise(resolve => { fetch('/instances/data.json').then(response => response.text()).then(async data => { @@ -45,7 +50,8 @@ function setRedirects() { let disableImgur, imgurRedirects, - imgurProtocol, + protocol, + protocolFallback, rimgoNormalRedirectsChecks, rimgoNormalCustomRedirects, rimgoTorRedirectsChecks, @@ -59,7 +65,8 @@ function init() { [ "disableImgur", "imgurRedirects", - "imgurProtocol", + "protocol", + "protocolFallback", "rimgoNormalRedirectsChecks", "rimgoNormalCustomRedirects", "rimgoTorRedirectsChecks", @@ -70,7 +77,8 @@ function init() { r => { disableImgur = r.disableImgur; imgurRedirects = r.imgurRedirects; - imgurProtocol = r.imgurProtocol; + protocol = r.protocol; + protocolFallback = r.protocolFallback; rimgoNormalRedirectsChecks = r.rimgoNormalRedirectsChecks; rimgoNormalCustomRedirects = r.rimgoNormalCustomRedirects; rimgoTorRedirectsChecks = r.rimgoTorRedirectsChecks; @@ -111,11 +119,13 @@ function redirect(url, type, initiator, disableOverride) { if (!targets.test(url.href)) return; if (url.pathname.includes("delete/")) return; - let instancesList; - if (imgurProtocol == 'normal') instancesList = [...rimgoNormalRedirectsChecks, ...rimgoNormalCustomRedirects]; - if (imgurProtocol == 'tor') instancesList = [...rimgoTorRedirectsChecks, ...rimgoTorCustomRedirects]; - if (imgurProtocol == 'i2p') instancesList = [...rimgoI2pRedirectsChecks, ...rimgoI2pCustomRedirects]; - if (instancesList.length === 0) return; + let instancesList = []; + if (protocol == 'i2p') instancesList = [...rimgoI2pCustomRedirects, ...rimgoI2pRedirectsChecks]; + if (protocol == 'tor') instancesList = [...rimgoTorRedirectsChecks, ...rimgoTorCustomRedirects]; + if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { + instancesList = [...rimgoNormalRedirectsChecks, ...rimgoNormalCustomRedirects]; + } + if (instancesList.length === 0) { return; } const randomInstance = utils.getRandomInstance(instancesList); return `${randomInstance}${url.pathname}${url.search}`; @@ -136,10 +146,12 @@ function switchInstance(url, disableOverride) { if (disableImgur && !disableOverride) { resolve(); return; } let protocolHost = utils.protocolHost(url); if (!all().includes(protocolHost)) { resolve(); return; } - let instancesList; - if (imgurProtocol == 'normal') instancesList = [...rimgoNormalCustomRedirects, ...rimgoNormalRedirectsChecks]; - else if (imgurProtocol == 'tor') instancesList = [...rimgoTorCustomRedirects, ...rimgoTorRedirectsChecks]; - else if (imgurProtocol == 'i2p') instancesList = [...rimgoI2pCustomRedirects, ...rimgoI2pRedirectsChecks]; + let instancesList = []; + if (protocol == 'i2p') instancesList = [...rimgoI2pCustomRedirects, ...rimgoI2pRedirectsChecks]; + if (protocol == 'tor') instancesList = [...rimgoTorRedirectsChecks, ...rimgoTorCustomRedirects]; + if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { + instancesList = [...rimgoNormalRedirectsChecks, ...rimgoNormalCustomRedirects]; + } const i = instancesList.indexOf(protocolHost); if (i > -1) instancesList.splice(i, 1); @@ -154,7 +166,9 @@ function initDefaults() { return new Promise(resolve => { fetch('/instances/data.json').then(response => response.text()).then(async data => { let dataJson = JSON.parse(data); - redirects.rimgo = dataJson.rimgo; + for (let i = 0; i < frontends.length; i++) { + redirects[frontends[i]] = dataJson[frontends[i]] + } browser.storage.local.get('cloudflareBlackList', async r => { rimgoNormalRedirectsChecks = [...redirects.rimgo.normal]; for (const instance of r.cloudflareBlackList) { @@ -163,7 +177,6 @@ function initDefaults() { } browser.storage.local.set({ disableImgur: false, - imgurProtocol: 'normal', imgurRedirects: redirects, rimgoNormalRedirectsChecks: rimgoNormalRedirectsChecks, diff --git a/src/assets/javascripts/instagram.js b/src/assets/javascripts/instagram.js index 7fa69200..e1c4061b 100644 --- a/src/assets/javascripts/instagram.js +++ b/src/assets/javascripts/instagram.js @@ -5,12 +5,19 @@ const targets = [ "instagram.com", "www.instagram.com", ]; -let redirects = { - "bibliogram": { - "normal": [], - "tor": [] - } -}; + +const frontends = new Array("bibliogram") +const protocols = new Array("normal", "tor", "i2p", "loki") + +let redirects = {}; + +for (let i = 0; i < frontends.length; i++) { + redirects[frontends[i]] = {} + for (let x = 0; x < protocols.length; x++) { + redirects[frontends[i]][protocols[x]] = [] + } +} + function setRedirects(val) { browser.storage.local.get('cloudflareBlackList', async r => { redirects.bibliogram = val; @@ -28,7 +35,8 @@ function setRedirects(val) { let disableInstagram, - instagramProtocol, + protocol, + protocolFallback, instagramRedirects, bibliogramNormalRedirectsChecks, bibliogramTorRedirectsChecks, @@ -40,7 +48,8 @@ function init() { browser.storage.local.get( [ "disableInstagram", - "instagramProtocol", + "protocol", + "protocolFallback", "instagramRedirects", "bibliogramNormalRedirectsChecks", "bibliogramTorRedirectsChecks", @@ -49,7 +58,8 @@ function init() { ], r => { disableInstagram = r.disableInstagram; - instagramProtocol = r.instagramProtocol; + protocol = r.protocol; + protocolFallback = r.protocolFallback; instagramRedirects = r.instagramRedirects; bibliogramNormalRedirectsChecks = r.bibliogramNormalRedirectsChecks; bibliogramTorRedirectsChecks = r.bibliogramTorRedirectsChecks; @@ -82,10 +92,12 @@ function redirect(url, type, initiator, disableOverride) { const bypassPaths = [/about/, /explore/, /support/, /press/, /api/, /privacy/, /safety/, /admin/, /\/(accounts\/|embeds?.js)/]; if (bypassPaths.some(rx => rx.test(url.pathname))) return; - let instancesList; - if (instagramProtocol == 'normal') instancesList = [...bibliogramNormalRedirectsChecks, ...bibliogramNormalCustomRedirects]; - else if (instagramProtocol == 'tor') instancesList = [...bibliogramTorRedirectsChecks, ...bibliogramTorCustomRedirects]; - if (instancesList.length === 0) return; + let instancesList = []; + if (protocol == 'tor') instancesList = [...bibliogramTorRedirectsChecks, ...bibliogramTorCustomRedirects]; + if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { + instancesList = [...bibliogramNormalRedirectsChecks, ...bibliogramNormalCustomRedirects]; + } + if (instancesList.length === 0) { return; } let randomInstance = utils.getRandomInstance(instancesList) const reservedPaths = ["u", "p", "privacy",]; @@ -116,9 +128,11 @@ function switchInstance(url, disableOverride) { let protocolHost = utils.protocolHost(url); if (!all().includes(protocolHost)) { resolve(); return; } - let instancesList; - if (instagramProtocol == 'normal') instancesList = [...bibliogramNormalCustomRedirects, ...bibliogramNormalRedirectsChecks]; - else if (instagramProtocol == 'tor') instancesList = [...bibliogramTorCustomRedirects, ...bibliogramTorRedirectsChecks]; + let instancesList = []; + if (protocol == 'tor') instancesList = [...bibliogramTorRedirectsChecks, ...bibliogramTorCustomRedirects]; + if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { + instancesList = [...bibliogramNormalRedirectsChecks, ...bibliogramNormalCustomRedirects]; + } const i = instancesList.indexOf(protocolHost); if (i > -1) instancesList.splice(i, 1); @@ -133,7 +147,9 @@ function initDefaults() { return new Promise(resolve => { fetch('/instances/data.json').then(response => response.text()).then(data => { let dataJson = JSON.parse(data); - redirects.bibliogram = dataJson.bibliogram; + for (let i = 0; i < frontends.length; i++) { + redirects[frontends[i]] = dataJson[frontends[i]] + } browser.storage.local.get('cloudflareBlackList', r => { bibliogramNormalRedirectsChecks = [...redirects.bibliogram.normal]; for (const instance of r.cloudflareBlackList) { @@ -148,8 +164,7 @@ function initDefaults() { bibliogramTorRedirectsChecks: [], bibliogramNormalCustomRedirects: [...redirects.bibliogram.tor], - bibliogramTorCustomRedirects: [], - instagramProtocol: "normal", + bibliogramTorCustomRedirects: [] }) resolve(); } diff --git a/src/assets/javascripts/lbry.js b/src/assets/javascripts/lbry.js index 77a8e4ec..7a298fbe 100644 --- a/src/assets/javascripts/lbry.js +++ b/src/assets/javascripts/lbry.js @@ -4,44 +4,36 @@ import utils from './utils.js' let targets = ["odysee.com"]; -let redirects = { - "librarian": { - "normal": [ - "https://lbry.bcow.xyz", - "https://odysee.076.ne.jp", - "https://lbry.ix.tc", - "https://librarian.pussthecat.org", - "https://lbry.mutahar.rocks", - "https://librarian.esmailelbob.xyz", - ], - "tor": [ - "http://ecc5mi5ncdw6mxhjz6re6g2uevtpbzxjvxgrxia2gyvrlnil3srbnhyd.onion", - "http://vrmbc4brkgkaysmi3fenbzkayobxjh24slmhtocambn3ewe62iuqt3yd.onion", - ] +const frontends = new Array("librarian") +const protocols = new Array("normal", "tor", "i2p", "loki") + +let redirects = {} + +for (let i = 0; i < frontends.length; i++) { + redirects[frontends[i]] = {} + for (let x = 0; x < protocols.length; x++) { + redirects[frontends[i]][protocols[x]] = [] } } function setRedirects(val) { - redirects.librarian = val; - browser.storage.local.set({ lbryTargetsRedirects: redirects }) - for (const item of librarianNormalRedirectsChecks) - if (!redirects.librarian.normal.includes(item)) { - var index = librarianNormalRedirectsChecks.indexOf(item); - if (index !== -1) librarianNormalRedirectsChecks.splice(index, 1); - } - browser.storage.local.set(librarianNormalRedirectsChecks); - - for (const item of librarianTorRedirectsChecks) - if (!redirects.librarian.normal.includes(item)) { - var index = librarianTorRedirectsChecks.indexOf(item); - if (index !== -1) librarianTorRedirectsChecks.splice(index, 1); + browser.storage.local.get('cloudflareBlackList', r => { + redirects.librarian = val; + librarianNormalRedirectsChecks = [...redirects.librarian.normal]; + for (const instance of r.cloudflareBlackList) { + const a = librarianNormalRedirectsChecks.indexOf(instance); + if (a > -1) librarianNormalRedirectsChecks.splice(a, 1); } - browser.storage.local.set(librarianTorRedirectsChecks) + browser.storage.local.set({ + lbryTargetsRedirects: redirects, + librarianNormalRedirectsChecks + }) + }) } let disableLbryTargets, - lbryTargetsProtocol, + protocol, lbryTargetsRedirects, librarianNormalRedirectsChecks, librarianNormalCustomRedirects, @@ -53,7 +45,7 @@ function init() { browser.storage.local.get( [ "disableLbryTargets", - "lbryTargetsProtocol", + "protocol", "lbryTargetsRedirects", "librarianNormalRedirectsChecks", "librarianNormalCustomRedirects", @@ -62,7 +54,7 @@ function init() { ], r => { disableLbryTargets = r.disableLbryTargets; - lbryTargetsProtocol = r.lbryTargetsProtocol; + protocol = r.protocol; lbryTargetsRedirects = r.lbryTargetsRedirects; librarianNormalRedirectsChecks = r.librarianNormalRedirectsChecks; librarianNormalCustomRedirects = r.librarianNormalCustomRedirects; @@ -92,9 +84,11 @@ function switchInstance(url, disableOverride) { const protocolHost = utils.protocolHost(url); if (!all().includes(protocolHost)) { resolve(); return; } - let instancesList; - if (lbryTargetsProtocol == 'normal') instancesList = [...librarianNormalRedirectsChecks, ...librarianNormalCustomRedirects]; - else if (lbryTargetsProtocol == 'tor') instancesList = [...librarianTorRedirectsChecks, ...librarianTorCustomRedirects]; + let instancesList = []; + if (protocol == 'tor') instancesList = [...librarianTorRedirectsChecks, ...librarianTorCustomRedirects]; + if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { + instancesList = [...librarianNormalRedirectsChecks, ...librarianNormalCustomRedirects]; + } const i = instancesList.indexOf(protocolHost); if (i > -1) instancesList.splice(i, 1); @@ -111,9 +105,11 @@ function redirect(url, type, initiator, disableOverride) { if (!targets.includes(url.host)) return; if (type != "main_frame") return; - let instancesList; - if (lbryTargetsProtocol == 'normal') instancesList = [...librarianNormalRedirectsChecks, ...librarianNormalCustomRedirects]; - if (lbryTargetsProtocol == 'tor') instancesList = [...librarianTorRedirectsChecks, ...librarianTorCustomRedirects]; + let instancesList = []; + if (protocol == 'tor') instancesList = [...librarianTorRedirectsChecks, ...librarianTorCustomRedirects]; + if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { + instancesList = [...librarianNormalRedirectsChecks, ...librarianNormalCustomRedirects]; + } if (instancesList.length === 0) return; const randomInstance = utils.getRandomInstance(instancesList); @@ -121,31 +117,24 @@ function redirect(url, type, initiator, disableOverride) { } function initDefaults() { - return new Promise(resolve => { - browser.storage.local.get('cloudflareBlackList', async r => { - librarianNormalRedirectsChecks = [...redirects.librarian.normal]; - for (const instance of r.cloudflareBlackList) { - let i; - - i = librarianNormalRedirectsChecks.indexOf(instance); - if (i > -1) librarianNormalRedirectsChecks.splice(i, 1); + return new Promise(async resolve => { + fetch('/instances/data.json').then(response => response.text()).then(async data => { + let dataJson = JSON.parse(data); + for (let i = 0; i < frontends.length; i++) { + redirects[frontends[i]] = dataJson[frontends[i]] } browser.storage.local.set({ disableLbryTargets: true, - lbryTargetsRedirects: { - 'librarian': redirects.librarian - }, + + lbryTargetsRedirects: redirects, librarianNormalRedirectsChecks: librarianNormalRedirectsChecks, librarianNormalCustomRedirects: [], librarianTorRedirectsChecks: [...redirects.librarian.tor], librarianTorCustomRedirects: [], - - lbryTargetsProtocol: "normal", - }, () => resolve()) - - }) + }, () => resolve()); + }); }) } diff --git a/src/assets/javascripts/medium.js b/src/assets/javascripts/medium.js index 5d688b23..37a8a3db 100644 --- a/src/assets/javascripts/medium.js +++ b/src/assets/javascripts/medium.js @@ -1,7 +1,6 @@ window.browser = window.browser || window.chrome; import utils from './utils.js' - const targets = [ // /(?:.*\.)*(?<!(link\.|cdn\-images\-\d+\.))medium\.com(\/.*)?$/, /^medium\.com/, @@ -28,12 +27,18 @@ const targets = [ /^ writingcooperative\.com /, ]; -let redirects = { - "scribe": { - "normal": [], - "tor": [] - } -}; +const frontends = new Array("scribe") +const protocols = new Array("normal", "tor", "i2p", "loki") + +let redirects = {}; + +for (let i = 0; i < frontends.length; i++) { + redirects[frontends[i]] = {} + for (let x = 0; x < protocols.length; x++) { + redirects[frontends[i]][protocols[x]] = [] + } +} + function setRedirects(val) { browser.storage.local.get('cloudflareBlackList', r => { redirects.scribe = val; @@ -56,7 +61,8 @@ let scribeNormalCustomRedirects, scribeTorRedirectsChecks, scribeTorCustomRedirects, - mediumProtocol; + protocol, + protocolFallback; function init() { return new Promise(resolve => { @@ -68,7 +74,8 @@ function init() { "scribeNormalCustomRedirects", "scribeTorRedirectsChecks", "scribeTorCustomRedirects", - "mediumProtocol" + "protocol", + "protocolFallback" ], r => { disableMedium = r.disableMedium; @@ -77,7 +84,8 @@ function init() { scribeNormalCustomRedirects = r.scribeNormalCustomRedirects; scribeTorRedirectsChecks = r.scribeTorRedirectsChecks; scribeTorCustomRedirects = r.scribeTorCustomRedirects; - mediumProtocol = r.mediumProtocol; + protocol = r.protocol; + protocolFallback = r.protocolFallback; resolve(); } ) @@ -102,10 +110,12 @@ function redirect(url, type, initiator, disableOverride) { if (!targets.some(rx => rx.test(url.host))) return; if (/^\/(@[a-zA-Z.]{0,}(\/|)$)/.test(url.pathname)) return; - let instancesList; - if (mediumProtocol == 'normal') instancesList = [...scribeNormalRedirectsChecks, ...scribeNormalCustomRedirects]; - else if (mediumProtocol == 'tor') instancesList = [...scribeTorRedirectsChecks, ...scribeTorCustomRedirects]; - if (instancesList.length === 0) return; + let instancesList = []; + if (protocol == 'tor') instancesList = [...scribeTorRedirectsChecks, ...scribeTorCustomRedirects]; + if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { + instancesList = [...scribeNormalRedirectsChecks, ...scribeNormalCustomRedirects]; + } + if (instancesList.length === 0) { return; } const randomInstance = utils.getRandomInstance(instancesList) return `${randomInstance}${url.pathname}${url.search}`; @@ -125,9 +135,11 @@ function switchInstance(url, disableOverride) { ]; if (!all.includes(protocolHost)) { resolve(); return; } - let instancesList; - if (mediumProtocol == 'normal') instancesList = [...scribeNormalCustomRedirects, ...scribeNormalRedirectsChecks]; - else if (mediumProtocol == 'tor') instancesList = [...scribeTorCustomRedirects, ...scribeTorRedirectsChecks]; + let instancesList = []; + if (protocol == 'tor') instancesList = [...scribeTorRedirectsChecks, ...scribeTorCustomRedirects]; + if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { + instancesList = [...scribeNormalRedirectsChecks, ...scribeNormalCustomRedirects]; + } const i = instancesList.indexOf(protocolHost); if (i > -1) instancesList.splice(i, 1); @@ -142,7 +154,9 @@ function initDefaults() { return new Promise(resolve => { fetch('/instances/data.json').then(response => response.text()).then(data => { let dataJson = JSON.parse(data); - redirects.scribe = dataJson.scribe; + for (let i = 0; i < frontends.length; i++) { + redirects[frontends[i]] = dataJson[frontends[i]] + } browser.storage.local.get('cloudflareBlackList', async r => { scribeNormalRedirectsChecks = [...redirects.scribe.normal]; @@ -159,8 +173,6 @@ function initDefaults() { scribeTorRedirectsChecks: [...redirects.scribe.tor], scribeTorCustomRedirects: [], - - mediumProtocol: "normal", }, () => resolve()) }) }) diff --git a/src/assets/javascripts/peertube.js b/src/assets/javascripts/peertube.js index 8b7414e8..b397f972 100644 --- a/src/assets/javascripts/peertube.js +++ b/src/assets/javascripts/peertube.js @@ -40,7 +40,8 @@ let simpleertubeTorRedirectsChecks, simpleertubeTorCustomRedirects, peerTubeTargets, - peertubeTargetsProtocol; + protocol, + protocolFallback; function init() { return new Promise(resolve => { @@ -53,7 +54,8 @@ function init() { "simpleertubeTorRedirectsChecks", "simpleertubeTorCustomRedirects", "peerTubeTargets", - "peertubeTargetsProtocol" + "protocol", + "protocolFallback" ], r => { disablePeertubeTargets = r.disablePeertubeTargets; @@ -63,7 +65,8 @@ function init() { simpleertubeTorRedirectsChecks = r.simpleertubeTorRedirectsChecks; simpleertubeTorCustomRedirects = r.simpleertubeTorCustomRedirects; peerTubeTargets = r.peerTubeTargets; - peertubeTargetsProtocol = r.peertubeTargetsProtocol; + protocol = r.protocol; + protocolFallback = r.protocolFallback; resolve(); } ) @@ -89,10 +92,12 @@ function redirect(url, type, initiator, disableOverride) { if (!peerTubeTargets.includes(protocolHost)) return; if (type != "main_frame") return; - let instancesList; - if (peertubeTargetsProtocol == 'normal') instancesList = [...simpleertubeNormalRedirectsChecks, ...simpleertubeNormalCustomRedirects]; - if (peertubeTargetsProtocol == 'tor') instancesList = [...simpleertubeTorRedirectsChecks, ...simpleertubeTorCustomRedirects]; - if (instancesList.length === 0) return; + let instancesList = []; + if (protocol == 'tor') instancesList = [...simpleertubeTorRedirectsChecks, ...simpleertubeTorCustomRedirects]; + if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { + instancesList = [...simpleertubeNormalRedirectsChecks, ...simpleertubeNormalCustomRedirects]; + } + if (instancesList.length === 0) { return; } const randomInstance = utils.getRandomInstance(instancesList); if (url.host == 'search.joinpeertube.org' || url.host == 'sepiasearch.org') return randomInstance; @@ -106,9 +111,11 @@ function switchInstance(url, disableOverride) { const protocolHost = utils.protocolHost(url); if (!all().includes(protocolHost)) { resolve(); return; } - let instancesList; - if (peertubeTargetsProtocol == 'normal') instancesList = [...simpleertubeNormalRedirectsChecks, ...simpleertubeNormalCustomRedirects]; - else if (peertubeTargetsProtocol == 'tor') instancesList = [...simpleertubeTorRedirectsChecks, ...simpleertubeTorCustomRedirects]; + let instancesList = []; + if (protocol == 'tor') instancesList = [...simpleertubeTorRedirectsChecks, ...simpleertubeTorCustomRedirects]; + if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { + instancesList = [...simpleertubeNormalRedirectsChecks, ...simpleertubeNormalCustomRedirects]; + } const i = instancesList.indexOf(protocolHost); if (i > -1) instancesList.splice(i, 1); @@ -138,9 +145,7 @@ function initDefaults() { simpleertubeNormalCustomRedirects: [], simpleertubeTorRedirectsChecks: [...redirects.simpleertube.tor], - simpleertubeTorCustomRedirects: [], - - peertubeTargetsProtocol: "normal", + simpleertubeTorCustomRedirects: [] }, () => resolve()); }) }) diff --git a/src/assets/javascripts/quora.js b/src/assets/javascripts/quora.js index 5f33f08d..aa907368 100644 --- a/src/assets/javascripts/quora.js +++ b/src/assets/javascripts/quora.js @@ -6,12 +6,18 @@ const targets = [ /^https?:\/{2}(www\.|)quora\.com.*/ ]; -let redirects = { - "quetre": { - "normal": [], - "tor": [] +let redirects = {} + +const frontends = new Array("quetre") +const protocols = new Array("normal", "tor", "i2p", "loki") + +for (let i = 0; i < frontends.length; i++) { + redirects[frontends[i]] = {} + for (let x = 0; x < protocols.length; x++) { + redirects[frontends[i]][protocols[x]] = [] } } + function setRedirects(val) { browser.storage.local.get('cloudflareBlackList', r => { redirects.quetre = val; @@ -29,7 +35,8 @@ function setRedirects(val) { let disableQuora, - quoraProtocol, + protocol, + protocolFallback, quoraRedirects, quetreNormalRedirectsChecks, quetreNormalCustomRedirects, @@ -41,7 +48,8 @@ function init() { browser.storage.local.get( [ "disableQuora", - "quoraProtocol", + "protocol", + "protocolFallback", "quoraRedirects", "quetreNormalRedirectsChecks", "quetreNormalCustomRedirects", @@ -50,7 +58,8 @@ function init() { ], r => { disableQuora = r.disableQuora; - quoraProtocol = r.quoraProtocol; + protocol = r.protocol; + protocolFallback = r.protocolFallback; quoraRedirects = r.quoraRedirects; quetreNormalRedirectsChecks = r.quetreNormalRedirectsChecks; quetreNormalCustomRedirects = r.quetreNormalCustomRedirects; @@ -76,10 +85,12 @@ function redirect(url, type, initiator, disableOverride) { if (initiator && (all.includes(initiator.origin) || targets.includes(initiator.host))) return; if (!targets.some(rx => rx.test(url.href))) return; - let instancesList; - if (quoraProtocol == 'normal') instancesList = [...quetreNormalRedirectsChecks, ...quetreNormalCustomRedirects]; - if (quoraProtocol == 'tor') instancesList = [...quetreTorRedirectsChecks, ...quetreTorCustomRedirects]; - if (instancesList.length === 0) return; + let instancesList = []; + if (protocol == 'tor') instancesList = [...quetreTorRedirectsChecks, ...quetreTorCustomRedirects]; + if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { + instancesList = [...quetreNormalRedirectsChecks, ...quetreNormalCustomRedirects]; + } + if (instancesList.length === 0) { return; } const randomInstance = utils.getRandomInstance(instancesList); return `${randomInstance}${url.pathname}`; @@ -115,9 +126,11 @@ function switchInstance(url, disableOverride) { ]; if (!all.includes(protocolHost)) { resolve(); return; } - let instancesList; - if (quoraProtocol == 'normal') instancesList = [...quetreNormalCustomRedirects, ...quetreNormalRedirectsChecks]; - else if (quoraProtocol == 'tor') instancesList = [...quetreTorCustomRedirects, ...quetreTorRedirectsChecks]; + let instancesList = []; + if (protocol == 'tor') instancesList = [...quetreTorRedirectsChecks, ...quetreTorCustomRedirects]; + if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { + instancesList = [...quetreNormalRedirectsChecks, ...quetreNormalCustomRedirects]; + } const i = instancesList.indexOf(protocolHost); if (i > -1) instancesList.splice(i, 1); @@ -132,10 +145,11 @@ function initDefaults() { return new Promise(async resolve => { fetch('/instances/data.json').then(response => response.text()).then(async data => { let dataJson = JSON.parse(data); - redirects.quetre = dataJson.quetre; + for (let i = 0; i < frontends.length; i++) { + redirects[frontends[i]] = dataJson[frontends[i]] + } browser.storage.local.set({ disableQuora: false, - quoraProtocol: "normal", quoraRedirects: redirects, diff --git a/src/assets/javascripts/reddit.js b/src/assets/javascripts/reddit.js index e1f910c3..f43d88dd 100644 --- a/src/assets/javascripts/reddit.js +++ b/src/assets/javascripts/reddit.js @@ -6,16 +6,18 @@ const targets = [ /^https?:\/{2}(www\.|old\.|np\.|new\.|amp\.|)reddit\.com/, /^https?:\/{2}(i\.|preview\.)redd\.it/, ]; -let redirects = { - "libreddit": { - "normal": [], - "tor": [] - }, - "teddit": { - "normal": [], - "tor": [] - }, -}; +let redirects = {}; + +const frontends = new Array("libreddit", "teddit") +const protocols = new Array("normal", "tor", "i2p", "loki") + +for (let i = 0; i < frontends.length; i++) { + redirects[frontends[i]] = {} + for (let x = 0; x < protocols.length; x++) { + redirects[frontends[i]][protocols[x]] = [] + } +} + function setRedirects(val) { browser.storage.local.get('cloudflareBlackList', r => { redirects = val; @@ -40,7 +42,7 @@ let disableReddit, redditFrontend, redditRedirects, - redditProtocol, + protocol, libredditNormalRedirectsChecks, libredditNormalCustomRedirects, libredditTorRedirectsChecks, @@ -57,7 +59,7 @@ function init() { "disableReddit", "redditFrontend", "redditRedirects", - "redditProtocol", + "protocol", "libredditNormalRedirectsChecks", "libredditNormalCustomRedirects", "libredditTorRedirectsChecks", @@ -71,7 +73,7 @@ function init() { disableReddit = r.disableReddit; redditFrontend = r.redditFrontend; redditRedirects = r.redditRedirects; - redditProtocol = r.redditProtocol; + protocol = r.protocol; libredditNormalRedirectsChecks = r.libredditNormalRedirectsChecks; libredditNormalCustomRedirects = r.libredditNormalCustomRedirects; libredditTorRedirectsChecks = r.libredditTorRedirectsChecks; @@ -102,8 +104,8 @@ function initLibredditCookies(test, from) { if (!test) { let checkedInstances; - if (redditProtocol == 'normal') checkedInstances = [...libredditNormalRedirectsChecks, ...libredditNormalCustomRedirects]; - else if (redditProtocol == 'tor') checkedInstances = [...libredditTorRedirectsChecks, ...libredditTorCustomRedirects]; + if (protocol == 'normal') checkedInstances = [...libredditNormalRedirectsChecks, ...libredditNormalCustomRedirects]; + else if (protocol == 'tor') checkedInstances = [...libredditTorRedirectsChecks, ...libredditTorCustomRedirects]; await utils.copyCookie('libreddit', from, checkedInstances, "theme"); await utils.copyCookie('libreddit', from, checkedInstances, "front_page"); await utils.copyCookie('libreddit', from, checkedInstances, "layout"); @@ -124,10 +126,10 @@ function initLibredditCookies(test, from) { function pasteLibredditCookies() { return new Promise(async resolve => { await init(); - if (disableReddit || redditFrontend != 'libreddit' || redditProtocol === undefined) { resolve(); return; } + if (disableReddit || redditFrontend != 'libreddit' || protocol === undefined) { resolve(); return; } let checkedInstances; - if (redditProtocol == 'normal') checkedInstances = [...libredditNormalRedirectsChecks, ...libredditNormalCustomRedirects] - else if (redditProtocol == 'tor') checkedInstances = [...libredditTorRedirectsChecks, ...libredditTorCustomRedirects] + if (protocol == 'normal') checkedInstances = [...libredditNormalRedirectsChecks, ...libredditNormalCustomRedirects] + else if (protocol == 'tor') checkedInstances = [...libredditTorRedirectsChecks, ...libredditTorCustomRedirects] utils.getCookiesFromStorage('libreddit', checkedInstances, "theme"); utils.getCookiesFromStorage('libreddit', checkedInstances, "front_page"); utils.getCookiesFromStorage('libreddit', checkedInstances, "layout"); @@ -157,8 +159,8 @@ function initTedditCookies(test, from) { if (!test) { let checkedInstances; - if (redditProtocol == 'normal') checkedInstances = [...tedditNormalRedirectsChecks, ...tedditNormalCustomRedirects] - else if (redditProtocol == 'tor') checkedInstances = [...tedditTorRedirectsChecks, ...tedditTorCustomRedirects] + if (protocol == 'normal') checkedInstances = [...tedditNormalRedirectsChecks, ...tedditNormalCustomRedirects] + else if (protocol == 'tor') checkedInstances = [...tedditTorRedirectsChecks, ...tedditTorCustomRedirects] 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') @@ -179,10 +181,10 @@ function initTedditCookies(test, from) { function pasteTedditCookies() { return new Promise(async resolve => { await init(); - if (disableReddit || redditFrontend != 'teddit' || redditProtocol === undefined) { resolve(); return; } + if (disableReddit || redditFrontend != 'teddit' || protocol === undefined) { resolve(); return; } let checkedInstances; - if (redditProtocol == 'normal') checkedInstances = [...tedditNormalRedirectsChecks, ...tedditNormalCustomRedirects] - else if (redditProtocol == 'tor') checkedInstances = [...tedditTorRedirectsChecks, ...tedditTorCustomRedirects] + if (protocol == 'normal') checkedInstances = [...tedditNormalRedirectsChecks, ...tedditNormalCustomRedirects] + else if (protocol == 'tor') checkedInstances = [...tedditTorRedirectsChecks, ...tedditTorCustomRedirects] utils.getCookiesFromStorage('teddit', checkedInstances, 'collapse_child_comments') utils.getCookiesFromStorage('teddit', checkedInstances, 'domain_instagram') utils.getCookiesFromStorage('teddit', checkedInstances, 'domain_twitter') @@ -230,15 +232,17 @@ function redirect(url, type, initiator, disableOverride) { const bypassPaths = /\/(gallery\/poll\/rpan\/settings\/topics)/; if (url.pathname.match(bypassPaths)) return; - let libredditInstancesList; - let tedditInstancesList; - if (redditProtocol == 'normal') { - libredditInstancesList = [...libredditNormalRedirectsChecks, ...libredditNormalCustomRedirects]; - tedditInstancesList = [...tedditNormalRedirectsChecks, ...tedditNormalCustomRedirects]; - } else if (redditProtocol == 'tor') { - libredditInstancesList = [...libredditTorRedirectsChecks, ...libredditTorCustomRedirects]; - tedditInstancesList = [...tedditTorRedirectsChecks, ...tedditTorCustomRedirects]; - } + 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 (url.host === "i.redd.it") { if (redditFrontend == 'teddit') { @@ -293,18 +297,22 @@ function switchInstance(url, disableOverride) { if (disableReddit && !disableOverride) { resolve(); return; } const protocolHost = utils.protocolHost(url); if (!all().includes(protocolHost)) { resolve(); return; } - let instancesList; + let instancesList = []; if (redditFrontend == 'libreddit') { - if (redditProtocol == 'normal') instancesList = [...libredditNormalRedirectsChecks, ...libredditNormalCustomRedirects]; - else if (redditProtocol == 'tor') instancesList = [...libredditTorRedirectsChecks, ...libredditTorCustomRedirects]; + if (protocol == 'tor') instancesList = [...libredditTorRedirectsChecks, ...libredditTorCustomRedirects]; + if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { + instancesList = [...libredditNormalRedirectsChecks, ...libredditNormalCustomRedirects]; + } if ([ ...redditRedirects.teddit.normal, ...redditRedirects.teddit.tor ].includes(protocolHost)) url.pathname = url.pathname.replace("/pics/w:null_", "/img/"); } else if (redditFrontend == 'teddit') { - if (redditProtocol == 'normal') instancesList = [...tedditNormalRedirectsChecks, ...tedditNormalCustomRedirects]; - else if (redditProtocol == 'tor') instancesList = [...tedditTorRedirectsChecks, ...tedditTorCustomRedirects]; + if (protocol == 'tor') instancesList = [...tedditTorRedirectsChecks, ...tedditTorCustomRedirects]; + if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { + instancesList = [...tedditNormalRedirectsChecks, ...tedditNormalCustomRedirects]; + } if ([ ...redditRedirects.libreddit.normal, ...redditRedirects.libreddit.tor @@ -325,8 +333,9 @@ function initDefaults() { return new Promise(resolve => { fetch('/instances/data.json').then(response => response.text()).then(async data => { let dataJson = JSON.parse(data); - redirects.teddit = dataJson.teddit; - redirects.libreddit = dataJson.libreddit; + for (let i = 0; i < frontends.length; i++) { + redirects[frontends[i]] = dataJson[frontends[i]] + } browser.storage.local.get('cloudflareBlackList', async r => { libredditNormalRedirectsChecks = [...redirects.libreddit.normal]; tedditNormalRedirectsChecks = [...redirects.teddit.normal] @@ -341,7 +350,6 @@ function initDefaults() { } browser.storage.local.set({ disableReddit: false, - redditProtocol: 'normal', redditFrontend: 'libreddit', redditRedirects: redirects, diff --git a/src/assets/javascripts/reuters.js b/src/assets/javascripts/reuters.js index 5f215518..ee4f227c 100644 --- a/src/assets/javascripts/reuters.js +++ b/src/assets/javascripts/reuters.js @@ -6,18 +6,22 @@ const targets = [ /^https?:\/{2}(www\.|)reuters\.com.*/ ]; -let redirects = { - "neuters": { - "normal": [ - 'https://neuters.de', - ], - "tor": [] +let redirects = {} + +const frontends = new Array("neuters") +const protocols = new Array("normal", "tor", "i2p", "loki") + +for (let i = 0; i < frontends.length; i++) { + redirects[frontends[i]] = {} + for (let x = 0; x < protocols.length; x++) { + redirects[frontends[i]][protocols[x]] = [] } } let disableReuters, - reutersProtocol, + protocol, + protocolFallback, reutersRedirects, neutersNormalRedirectsChecks, neutersNormalCustomRedirects, @@ -29,7 +33,8 @@ function init() { browser.storage.local.get( [ "disableReuters", - "reutersProtocol", + "protocol", + "protocolFallback", "reutersRedirects", "neutersNormalRedirectsChecks", "neutersNormalCustomRedirects", @@ -38,7 +43,8 @@ function init() { ], r => { disableReuters = r.disableReuters; - reutersProtocol = r.reutersProtocol; + protocol = r.protocol; + protocolFallback = r.protocolFallback; reutersRedirects = r.reutersRedirects; neutersNormalRedirectsChecks = r.neutersNormalRedirectsChecks; neutersNormalCustomRedirects = r.neutersNormalCustomRedirects; @@ -63,9 +69,11 @@ function redirect(url, type, initiator, disableOverride) { if (initiator && (all.includes(initiator.origin) || targets.includes(initiator.host))) return; if (!targets.some(rx => rx.test(url.href))) return; - let instancesList; - if (reutersProtocol == 'normal') instancesList = [...neutersNormalRedirectsChecks, ...neutersNormalCustomRedirects]; - if (reutersProtocol == 'tor') instancesList = [...neutersTorRedirectsChecks, ...neutersTorCustomRedirects]; + let instancesList = []; + if (protocol == 'tor') instancesList = [...neutersTorRedirectsChecks, ...neutersTorCustomRedirects]; + if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { + instancesList = [...neutersNormalRedirectsChecks, ...neutersNormalCustomRedirects]; + } if (instancesList.length === 0) return; const randomInstance = utils.getRandomInstance(instancesList); @@ -87,7 +95,6 @@ function initDefaults() { return new Promise(resolve => { browser.storage.local.set({ disableReuters: true, - reutersProtocol: "normal", reutersRedirects: redirects, diff --git a/src/assets/javascripts/search.js b/src/assets/javascripts/search.js index c19f4d4a..6653d2bd 100644 --- a/src/assets/javascripts/search.js +++ b/src/assets/javascripts/search.js @@ -7,7 +7,7 @@ const targets = [ ]; // Ill optimise all of assets/javascripts at a later date. For now, I'll just add librex and optimse options javascript const frontends = new Array("searx", "searxng", "whoogle", "librex") -const protocols = new Array("normal", "tor", "i2p") +const protocols = new Array("normal", "tor", "i2p", "loki") const redirects = {} /* @@ -82,7 +82,8 @@ let disableSearch, searchFrontend, searchRedirects, - searchProtocol, + protocol, + protocolFallback, whoogleNormalRedirectsChecks, whoogleNormalCustomRedirects, whoogleTorRedirectsChecks, @@ -115,7 +116,8 @@ function init() { "disableSearch", "searchFrontend", "searchRedirects", - "searchProtocol", + "protocol", + "protocolFallback", "whoogleNormalRedirectsChecks", "whoogleNormalCustomRedirects", "whoogleTorRedirectsChecks", @@ -145,7 +147,8 @@ function init() { disableSearch = r.disableSearch; searchFrontend = r.searchFrontend; searchRedirects = r.searchRedirects; - searchProtocol = r.searchProtocol; + protocol = r.protocol; + protocolFallback = r.protocolFallback; whoogleNormalRedirectsChecks = r.whoogleNormalRedirectsChecks; whoogleNormalCustomRedirects = r.whoogleNormalCustomRedirects; whoogleTorRedirectsChecks = r.whoogleTorRedirectsChecks; @@ -193,10 +196,12 @@ function initSearxCookies(test, from) { ].includes(protocolHost)) { resolve(); return; } if (!test) { - let checkedInstances; - if (searchProtocol == 'normal') checkedInstances = [...searxNormalRedirectsChecks, ...searxNormalCustomRedirects]; - else if (searchProtocol == 'tor') checkedInstances = [...searxTorRedirectsChecks, ...searxTorCustomRedirects]; - else if (searchProtocol == 'i2p') checkedInstances = [...searxI2pRedirectsChecks, ...searxI2pCustomRedirects]; + let checkedInstances = []; + if (protocol == 'i2p') checkedInstances = [...searxI2pCustomRedirects, ...searxI2pRedirectsChecks]; + if (protocol == 'tor') checkedInstances = [...searxTorRedirectsChecks, ...searxTorCustomRedirects]; + if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') { + checkedInstances = [...searxNormalRedirectsChecks, ...searxNormalCustomRedirects]; + } await utils.copyCookie('searx', from, checkedInstances, 'advanced_search'); await utils.copyCookie('searx', from, checkedInstances, 'autocomplete'); await utils.copyCookie('searx', from, checkedInstances, 'categories'); @@ -223,10 +228,12 @@ function pasteSearxCookies() { return new Promise(async resolve => { await init(); if (disableSearch || searchFrontend != 'searx') { resolve(); return; } - let checkedInstances; - if (searchProtocol == 'normal') checkedInstances = [...searxNormalRedirectsChecks, ...searxNormalCustomRedirects]; - else if (searchProtocol == 'tor') checkedInstances = [...searxTorRedirectsChecks, ...searxTorCustomRedirects]; - else if (searchProtocol == 'i2p') checkedInstances = [...searxI2pRedirectsChecks, ...searxI2pCustomRedirects]; + let checkedInstances = []; + if (protocol == 'i2p') checkedInstances = [...searxI2pCustomRedirects, ...searxI2pRedirectsChecks]; + if (protocol == 'tor') checkedInstances = [...searxTorRedirectsChecks, ...searxTorCustomRedirects]; + if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') { + checkedInstances = [...searxNormalRedirectsChecks, ...searxNormalCustomRedirects]; + } utils.getCookiesFromStorage('searx', checkedInstances, 'advanced_search'); utils.getCookiesFromStorage('searx', checkedInstances, 'autocomplete'); utils.getCookiesFromStorage('searx', checkedInstances, 'categories'); @@ -262,10 +269,12 @@ function initSearxngCookies(test, from) { ].includes(protocolHost)) { resolve(); return; } if (!test) { - let checkedInstances; - if (searchProtocol == 'normal') checkedInstances = [...searxngNormalRedirectsChecks, ...searxngNormalCustomRedirects]; - else if (searchProtocol == 'tor') checkedInstances = [...searxngTorRedirectsChecks, ...searxngTorCustomRedirects]; - else if (searchProtocol == 'i2p') checkedInstances = [...searxngI2pRedirectsChecks, ...searxngI2pCustomRedirects]; + let checkedInstances = []; + if (protocol == 'i2p') checkedInstances = [...searxngI2pCustomRedirects, ...searxngI2pRedirectsChecks]; + if (protocol == 'tor') checkedInstances = [...searxngTorRedirectsChecks, ...searxngTorCustomRedirects]; + if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') { + checkedInstances = [...searxngNormalRedirectsChecks, ...searxngNormalCustomRedirects]; + } await utils.copyCookie('searxng', from, checkedInstances, 'autocomplete'); await utils.copyCookie('searxng', from, checkedInstances, 'categories'); await utils.copyCookie('searxng', from, checkedInstances, 'disabled_engines'); @@ -293,11 +302,13 @@ function initSearxngCookies(test, from) { function pasteSearxngCookies() { return new Promise(async resolve => { await init(); - if (disableSearch || searchFrontend != 'searxng', searchProtocol === undefined) { resolve(); return; } - let checkedInstances; - if (searchProtocol == 'normal') checkedInstances = [...searxngNormalRedirectsChecks, ...searxngNormalCustomRedirects]; - else if (searchProtocol == 'tor') checkedInstances = [...searxngTorRedirectsChecks, ...searxngTorCustomRedirects]; - else if (searchProtocol == 'i2p') checkedInstances = [...searxngI2pRedirectsChecks, ...searxngI2pCustomRedirects]; + if (disableSearch || searchFrontend != 'searxng', protocol === undefined) { resolve(); return; } + let checkedInstances = []; + if (protocol == 'i2p') checkedInstances = [...searxngI2pCustomRedirects, ...searxngI2pRedirectsChecks]; + if (protocol == 'tor') checkedInstances = [...searxngTorRedirectsChecks, ...searxngTorCustomRedirects]; + if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') { + checkedInstances = [...searxngNormalRedirectsChecks, ...searxngNormalCustomRedirects]; + } utils.getCookiesFromStorage('searxng', checkedInstances, 'autocomplete'); utils.getCookiesFromStorage('searxng', checkedInstances, 'categories'); utils.getCookiesFromStorage('searxng', checkedInstances, 'disabled_engines'); @@ -335,10 +346,12 @@ function initLibrexCookies(test, from) { ].includes(protocolHost)) { resolve(); return; } if(!test) { - let checkedInstances; - if (searchProtocol == 'normal') checkedInstances = [...librexNormalRedirectsChecks, ...librexNormalCustomRedirects]; - else if (searchProtocol == 'tor') checkedInstances = [...librexTorRedirectsChecks, ...librexTorCustomRedirects]; - else if (searchProtocol == 'i2p') checkedInstances = [...librexI2pRedirectsChecks, ...librexI2pCustomRedirects]; + let checkedInstances = []; + if (protocol == 'i2p') checkedInstances = [...librexI2pCustomRedirects, ...librexI2pRedirectsChecks]; + if (protocol == 'tor') checkedInstances = [...librexTorRedirectsChecks, ...librexTorCustomRedirects]; + if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') { + checkedInstances = [...librexNormalRedirectsChecks, ...librexNormalCustomRedirects]; + } await utils.copyCookie('librex', from, checkedInstances, 'bibliogram'); await utils.copyCookie('librex', from, checkedInstances, 'disable_special'); await utils.copyCookie('librex', from, checkedInstances, 'invidious'); @@ -355,11 +368,13 @@ function initLibrexCookies(test, from) { function pasteLibrexCookies() { return new Promise(async resolve => { await init(); - if (disableSearch || searchFrontend != 'librex', searchProtocol === undefined) { resolve(); return; } - let checkedInstances; - if (searchProtocol == 'normal') checkedInstances = [...librexNormalRedirectsChecks, ...librexNormalCustomRedirects]; - else if (searchProtocol == 'tor') checkedInstances = [...librexTorRedirectsChecks, ...librexTorCustomRedirects]; - else if (searchProtocol == 'i2p') checkedInstances = [...librexI2pRedirectsChecks, ...librexI2pCustomRedirects]; + if (disableSearch || searchFrontend != 'librex', protocol === undefined) { resolve(); return; } + let checkedInstances = []; + if (protocol == 'i2p') checkedInstances = [...librexI2pCustomRedirects, ...librexI2pRedirectsChecks]; + if (protocol == 'tor') checkedInstances = [...librexTorRedirectsChecks, ...librexTorCustomRedirects]; + if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') { + checkedInstances = [...librexNormalRedirectsChecks, ...librexNormalCustomRedirects]; + } utils.getCookiesFromStorage('librex', checkedInstances, 'bibliogram'); utils.getCookiesFromStorage('librex', checkedInstances, 'disable_special'); utils.getCookiesFromStorage('librex', checkedInstances, 'invidious'); @@ -380,37 +395,50 @@ function redirect(url, disableOverride) { let randomInstance; let path; if (searchFrontend == 'searx') { - let instancesList; - if (searchProtocol == 'normal') instancesList = [...searxNormalRedirectsChecks, ...searxNormalCustomRedirects]; - else if (searchProtocol == 'tor') instancesList = [...searxTorRedirectsChecks, ...searxTorCustomRedirects]; - else if (searchProtocol == 'i2p') instancesList = [...searxI2pRedirectsChecks, ...searxI2pCustomRedirects]; - if (instancesList.length === 0) return; + let instancesList = []; + if (protocol == 'i2p') instancesList = [...searxI2pCustomRedirects, ...searxI2pRedirectsChecks]; + if (protocol == 'tor') instancesList = [...searxTorRedirectsChecks, ...searxTorCustomRedirects]; + if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { + instancesList = [...searxNormalRedirectsChecks, ...searxNormalCustomRedirects]; + } + if (instancesList.length === 0) { return; } + randomInstance = utils.getRandomInstance(instancesList) path = "/"; } else if (searchFrontend == 'searxng') { - let instancesList; - if (searchProtocol == 'normal') instancesList = [...searxngNormalRedirectsChecks, ...searxngNormalCustomRedirects]; - else if (searchProtocol == 'tor') instancesList = [...searxngTorRedirectsChecks, ...searxngTorCustomRedirects]; - else if (searchProtocol == 'i2p') instancesList = [...searxngI2pRedirectsChecks, ...searxngI2pCustomRedirects]; - if (instancesList.length === 0) return; + let instancesList = []; + if (protocol == 'i2p') instancesList = [...searxngI2pCustomRedirects, ...searxngI2pRedirectsChecks]; + if (protocol == 'tor') instancesList = [...searxngTorRedirectsChecks, ...searxngTorCustomRedirects]; + if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { + instancesList = [...searxngNormalRedirectsChecks, ...searxngNormalCustomRedirects]; + } + if (instancesList.length === 0) { return; } + randomInstance = utils.getRandomInstance(instancesList) path = "/"; } else if (searchFrontend == 'whoogle') { - let instancesList; - if (searchProtocol == 'normal') instancesList = [...whoogleNormalRedirectsChecks, ...whoogleNormalCustomRedirects]; - if (searchProtocol == 'tor') instancesList = [...whoogleTorRedirectsChecks, ...whoogleTorCustomRedirects]; - if (searchProtocol == 'i2p') instancesList = [...whoogleI2pRedirectsChecks, ...whoogleI2pCustomRedirects]; - if (instancesList.length === 0) return; + let instancesList = []; + if (protocol == 'i2p') instancesList = [...whoogleI2pCustomRedirects, ...whoogleI2pRedirectsChecks]; + if (protocol == 'tor') instancesList = [...whoogleTorRedirectsChecks, ...whoogleTorCustomRedirects]; + if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { + instancesList = [...whoogleNormalRedirectsChecks, ...whoogleNormalCustomRedirects]; + } + if (instancesList.length === 0) { return; } + randomInstance = utils.getRandomInstance(instancesList) path = "/search"; } else if (searchFrontend == 'librex') { - let instancesList; - if (searchProtocol == 'normal') instancesList = [...librexNormalRedirectsChecks, ...librexNormalCustomRedirects]; - if (searchProtocol == 'tor') instancesList = [...librexTorRedirectsChecks, ...librexTorCustomRedirects]; - if (searchProtocol == 'i2p') instancesList = [...librexI2pRedirectsChecks, ...librexI2pCustomRedirects]; + let instancesList = []; + if (protocol == 'i2p') instancesList = [...librexI2pCustomRedirects, ...librexI2pRedirectsChecks]; + if (protocol == 'tor') instancesList = [...librexTorRedirectsChecks, ...librexTorCustomRedirects]; + if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { + instancesList = [...librexNormalRedirectsChecks, ...librexNormalCustomRedirects]; + } + if (instancesList.length === 0) { return; } + randomInstance = utils.getRandomInstance(instancesList) path = "/search.php"; } @@ -474,25 +502,25 @@ function switchInstance(url, disableOverride) { ].includes(protocolHost)) { resolve(); return; } let instancesList; - if (searchProtocol == 'normal') { - if (searchFrontend == 'searx') instancesList = [...searxNormalRedirectsChecks, ...searxNormalCustomRedirects]; - else if (searchFrontend == 'searxng') instancesList = [...searxngNormalRedirectsChecks, ...searxngNormalCustomRedirects]; - else if (searchFrontend == 'whoogle') instancesList = [...whoogleNormalRedirectsChecks, ...whoogleNormalCustomRedirects]; - else if (searchFrontend == 'librex') instancesList = [...librexNormalRedirectsChecks, ...librexNormalCustomRedirects]; - } - else if (searchProtocol == 'tor') { + + if (protocol == 'tor') { if (searchFrontend == 'searx') instancesList = [...searxTorRedirectsChecks, ...searxTorCustomRedirects]; else if (searchFrontend == 'searxng') instancesList = [...searxngTorRedirectsChecks, ...searxngTorCustomRedirects]; else if (searchFrontend == 'whoogle') instancesList = [...whoogleTorRedirectsChecks, ...whoogleTorCustomRedirects]; else if (searchFrontend == 'librex') instancesList = [...librexTorRedirectsChecks, ...librexTorCustomRedirects]; } - else if (searchProtocol == 'i2p') { + else if (protocol == 'i2p') { if (searchFrontend == 'searx') instancesList = [...searxI2pRedirectsChecks, ...searxI2pCustomRedirects]; else if (searchFrontend == 'searxng') instancesList = [...searxngI2pRedirectsChecks, ...searxngI2pCustomRedirects]; else if (searchFrontend == 'whoogle') instancesList = [...whoogleI2pRedirectsChecks, ...whoogleI2pCustomRedirects]; else if (searchFrontend == 'librex') instancesList = [...librexI2pRedirectsChecks, ...librexI2pCustomRedirects]; } - + if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { + if (searchFrontend == 'searx') instancesList = [...searxNormalRedirectsChecks, ...searxNormalCustomRedirects]; + else if (searchFrontend == 'searxng') instancesList = [...searxngNormalRedirectsChecks, ...searxngNormalCustomRedirects]; + else if (searchFrontend == 'whoogle') instancesList = [...whoogleNormalRedirectsChecks, ...whoogleNormalCustomRedirects]; + else if (searchFrontend == 'librex') instancesList = [...librexNormalRedirectsChecks, ...librexNormalCustomRedirects]; + } const i = instancesList.indexOf(protocolHost); if (i > -1) instancesList.splice(i, 1); if (instancesList.length === 0) { resolve(); return; } @@ -540,7 +568,6 @@ function initDefaults() { searchFrontend: 'searxng', searchRedirects: redirects, searxngCustomSettings: false, - searchProtocol: 'normal', whoogleNormalRedirectsChecks: whoogleNormalRedirectsChecks, whoogleNormalCustomRedirects: [], diff --git a/src/assets/javascripts/sendTargets.js b/src/assets/javascripts/sendTargets.js index f507e552..cc5b348c 100644 --- a/src/assets/javascripts/sendTargets.js +++ b/src/assets/javascripts/sendTargets.js @@ -8,12 +8,18 @@ const targets = [ /^https?:\/{2}sendfiles\.online\/$/ ]; -let redirects = { - "send": { - "normal": [], - "tor": [] +const frontends = new Array("send") +const protocols = new Array("normal", "tor", "i2p", "loki") + +let redirects = {} + +for (let i = 0; i < frontends.length; i++) { + redirects[frontends[i]] = {} + for (let x = 0; x < protocols.length; x++) { + redirects[frontends[i]][protocols[x]] = [] } } + function setRedirects(val) { browser.storage.local.get('cloudflareBlackList', r => { redirects.send = val; @@ -36,7 +42,8 @@ let sendNormalCustomRedirects, sendTorRedirectsChecks, sendTorCustomRedirects, - sendTargetsProtocol; + protocol, + protocolFallback; function init() { return new Promise(resolve => { @@ -44,7 +51,8 @@ function init() { [ "disableSendTarget", "sendTargetsRedirects", - "sendTargetsProtocol", + "protocol", + "protocolFallback", "sendNormalRedirectsChecks", "sendNormalCustomRedirects", "sendTorRedirectsChecks", @@ -57,7 +65,8 @@ function init() { sendNormalCustomRedirects = r.sendNormalCustomRedirects; sendTorRedirectsChecks = r.sendTorRedirectsChecks; sendTorCustomRedirects = r.sendTorCustomRedirects; - sendTargetsProtocol = r.sendTargetsProtocol; + protocol = r.protocol; + protocolFallback = r.protocolFallback; resolve(); } ) @@ -85,9 +94,11 @@ function switchInstance(url, disableOverride) { if (!all().includes(protocolHost)) { resolve(); return; } if (url.pathname != '/') { resolve(); return; } - let instancesList; - if (sendTargetsProtocol == 'normal') instancesList = [...sendNormalRedirectsChecks, ...sendNormalCustomRedirects]; - else if (sendTargetsProtocol == 'tor') instancesList = [...sendTorRedirectsChecks, ...sendTorCustomRedirects]; + let instancesList = []; + if (protocol == 'tor') instancesList = [...sendTorRedirectsChecks, ...sendTorCustomRedirects]; + if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { + instancesList = [...sendNormalRedirectsChecks, ...sendNormalCustomRedirects]; + } const i = instancesList.indexOf(protocolHost); if (i > -1) instancesList.splice(i, 1); @@ -104,9 +115,11 @@ function redirect(url, type, initiator, disableOverride) { if (initiator && (all().includes(initiator.origin) || targets.includes(initiator.host))) return; if (!targets.some(rx => rx.test(url.href))) return; - let instancesList; - if (sendTargetsProtocol == 'normal') instancesList = [...sendNormalRedirectsChecks, ...sendNormalCustomRedirects]; - if (sendTargetsProtocol == 'tor') instancesList = [...sendTorRedirectsChecks, ...sendTorCustomRedirects]; + let instancesList = []; + if (protocol == 'tor') instancesList = [...sendTorRedirectsChecks, ...sendTorCustomRedirects]; + if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { + instancesList = [...sendNormalRedirectsChecks, ...sendNormalCustomRedirects]; + } if (instancesList.length === 0) return; const randomInstance = utils.getRandomInstance(instancesList); @@ -117,7 +130,9 @@ function initDefaults() { return new Promise(resolve => { fetch('/instances/data.json').then(response => response.text()).then(async data => { let dataJson = JSON.parse(data); - redirects.send = dataJson.send; + for (let i = 0; i < frontends.length; i++) { + redirects[frontends[i]] = dataJson[frontends[i]] + } browser.storage.local.get('cloudflareBlackList', async r => { sendNormalRedirectsChecks = [...redirects.send.normal]; for (const instance of r.cloudflareBlackList) { @@ -132,9 +147,7 @@ function initDefaults() { sendNormalCustomRedirects: [], sendTorRedirectsChecks: [...redirects.send.tor], - sendTorCustomRedirects: [], - - sendTargetsProtocol: "normal", + sendTorCustomRedirects: [] }, () => resolve()) }) }) diff --git a/src/assets/javascripts/tiktok.js b/src/assets/javascripts/tiktok.js index 75e710d0..0bf6d592 100644 --- a/src/assets/javascripts/tiktok.js +++ b/src/assets/javascripts/tiktok.js @@ -6,12 +6,18 @@ const targets = [ /^https?:\/{2}(www\.|)tiktok\.com.*/ ]; -let redirects = { - "proxiTok": { - "normal": [], - "tor": [] +const frontends = new Array("proxiTok") +const protocols = new Array("normal", "tor", "i2p", "loki") + +let redirects = {} + +for (let i = 0; i < frontends.length; i++) { + redirects[frontends[i]] = {} + for (let x = 0; x < protocols.length; x++) { + redirects[frontends[i]][protocols[x]] = [] } } + function setRedirects(val) { browser.storage.local.get('cloudflareBlackList', r => { redirects.proxiTok = val; @@ -39,9 +45,11 @@ function initProxiTokCookies(test, from) { ].includes(protocolHost)) resolve(); if (!test) { - let checkedInstances; - if (tiktokProtocol == 'normal') checkedInstances = [...proxiTokNormalRedirectsChecks, ...proxiTokNormalCustomRedirects] - else if (tiktokProtocol == 'tor') checkedInstances = [...proxiTokTorRedirectsChecks, ...proxiTokTorCustomRedirects] + let instancesList = []; + if (protocol == 'tor') instancesList = [...proxiTokTorRedirectsChecks, ...proxiTokTorCustomRedirects]; + if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { + instancesList = [...proxiTokNormalRedirectsChecks, ...proxiTokNormalCustomRedirects]; + } await utils.copyCookie('proxitok', from, checkedInstances, 'theme'); await utils.copyCookie('proxitok', from, checkedInstances, 'api-legacy'); } @@ -52,10 +60,12 @@ function initProxiTokCookies(test, from) { function pasteProxiTokCookies() { return new Promise(async resolve => { await init(); - if (disableTiktok || tiktokProtocol === undefined) { resolve(); return; } - let checkedInstances; - if (tiktokProtocol == 'normal') checkedInstances = [...proxiTokNormalRedirectsChecks, ...proxiTokNormalCustomRedirects] - else if (tiktokProtocol == 'tor') checkedInstances = [...proxiTokTorRedirectsChecks, ...proxiTokTorCustomRedirects] + if (disableTiktok || protocol === undefined) { resolve(); return; } + let instancesList = []; + if (protocol == 'tor') instancesList = [...proxiTokTorRedirectsChecks, ...proxiTokTorCustomRedirects]; + if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { + instancesList = [...proxiTokNormalRedirectsChecks, ...proxiTokNormalCustomRedirects]; + } utils.getCookiesFromStorage('proxitok', checkedInstances, 'theme'); utils.getCookiesFromStorage('proxitok', checkedInstances, 'api-legacy'); resolve(); @@ -64,7 +74,8 @@ function pasteProxiTokCookies() { let disableTiktok, - tiktokProtocol, + protocol, + protocolFallback, tiktokRedirects, proxiTokNormalRedirectsChecks, proxiTokNormalCustomRedirects, @@ -76,7 +87,8 @@ function init() { browser.storage.local.get( [ "disableTiktok", - "tiktokProtocol", + "protocol", + "protocolFallback", "tiktokRedirects", "proxiTokNormalRedirectsChecks", "proxiTokNormalCustomRedirects", @@ -85,7 +97,8 @@ function init() { ], r => { disableTiktok = r.disableTiktok; - tiktokProtocol = r.tiktokProtocol; + protocol = r.protocol; + protocolFallback = r.protocolFallback; tiktokRedirects = r.tiktokRedirects; proxiTokNormalRedirectsChecks = r.proxiTokNormalRedirectsChecks; proxiTokNormalCustomRedirects = r.proxiTokNormalCustomRedirects; @@ -112,9 +125,11 @@ function redirect(url, type, initiator, disableOverride) { if (initiator && (all.includes(initiator.origin) || targets.includes(initiator.host))) return; if (!targets.some(rx => rx.test(url.href))) return; - let instancesList; - if (tiktokProtocol == 'normal') instancesList = [...proxiTokNormalRedirectsChecks, ...proxiTokNormalCustomRedirects]; - if (tiktokProtocol == 'tor') instancesList = [...proxiTokTorRedirectsChecks, ...proxiTokTorCustomRedirects]; + let instancesList = []; + if (protocol == 'tor') instancesList = [...proxiTokTorRedirectsChecks, ...proxiTokTorCustomRedirects]; + if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { + instancesList = [...proxiTokNormalRedirectsChecks, ...proxiTokNormalCustomRedirects]; + } if (instancesList.length === 0) return; const randomInstance = utils.getRandomInstance(instancesList); @@ -151,9 +166,11 @@ function switchInstance(url, disableOverride) { ]; if (!all.includes(protocolHost)) { resolve(); return; } - let instancesList; - if (tiktokProtocol == 'normal') instancesList = [...proxiTokNormalCustomRedirects, ...proxiTokNormalRedirectsChecks]; - else if (tiktokProtocol == 'tor') instancesList = [...proxiTokTorCustomRedirects, ...proxiTokTorRedirectsChecks]; + let instancesList = []; + if (protocol == 'tor') instancesList = [...proxiTokTorRedirectsChecks, ...proxiTokTorCustomRedirects]; + if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { + instancesList = [...proxiTokNormalRedirectsChecks, ...proxiTokNormalCustomRedirects]; + } const i = instancesList.indexOf(protocolHost); if (i > -1) instancesList.splice(i, 1); @@ -168,10 +185,11 @@ function initDefaults() { return new Promise(async resolve => { fetch('/instances/data.json').then(response => response.text()).then(async data => { let dataJson = JSON.parse(data); - redirects.proxiTok = dataJson.proxiTok; + for (let i = 0; i < frontends.length; i++) { + redirects[frontends[i]] = dataJson[frontends[i]] + } browser.storage.local.set({ disableTiktok: false, - tiktokProtocol: "normal", tiktokRedirects: redirects, diff --git a/src/assets/javascripts/translate/translate.js b/src/assets/javascripts/translate/translate.js index bbf08d52..ae64f127 100644 --- a/src/assets/javascripts/translate/translate.js +++ b/src/assets/javascripts/translate/translate.js @@ -6,30 +6,30 @@ const targets = [ /^https?:\/{2}translate\.google(\.[a-z]{2,3}){1,2}\//, ]; -let redirects = { - "simplyTranslate": { - "normal": [], - "tor": [], - "i2p": [], - "loki": [] - }, - "lingva": { - "normal": [], - "tor": [] - } -}; +const frontends = new Array("simplyTranslate", "lingva") +const protocols = new Array("normal", "tor", "i2p", "loki") + +let redirects = {}; + +for (let i = 0; i < frontends.length; i++) { + redirects[frontends[i]] = {} + for (let x = 0; x < protocols.length; x++) { + redirects[frontends[i]][protocols[x]] = [] + } +} let translateDisable, translateFrontend, - translateProtocol, + protocol, + protocolFallback, translateRedirects, simplyTranslateNormalRedirectsChecks, simplyTranslateNormalCustomRedirects, simplyTranslateTorRedirectsChecks, simplyTranslateTorCustomRedirects, - simplyTranslateI2PRedirectsChecks, - simplyTranslateI2PCustomRedirects, + simplyTranslateI2pRedirectsChecks, + simplyTranslateI2pCustomRedirects, simplyTranslateLokiRedirectsChecks, simplyTranslateLokiCustomReidrects, lingvaNormalRedirectsChecks, @@ -43,15 +43,15 @@ function init() { [ "translateDisable", "translateFrontend", - "translateProtocol", + "protocol", + "protocolFallback", "translateRedirects", - "simplyTranslateNormalRedirectsChecks", "simplyTranslateNormalCustomRedirects", "simplyTranslateTorRedirectsChecks", "simplyTranslateTorCustomRedirects", - "simplyTranslateI2PRedirectsChecks", - "simplyTranslateI2PCustomRedirects", + "simplyTranslateI2pRedirectsChecks", + "simplyTranslateI2pCustomRedirects", "simplyTranslateLokiRedirectsChecks", "simplyTranslateLokiCustomReidrects", @@ -63,14 +63,15 @@ function init() { r => { translateDisable = r.translateDisable; translateFrontend = r.translateFrontend; - translateProtocol = r.translateProtocol; + protocol = r.protocol; + protocolFallback = r.protocolFallback translateRedirects = r.translateRedirects; simplyTranslateNormalRedirectsChecks = r.simplyTranslateNormalRedirectsChecks; simplyTranslateNormalCustomRedirects = r.simplyTranslateNormalCustomRedirects; simplyTranslateTorRedirectsChecks = r.simplyTranslateTorRedirectsChecks; simplyTranslateTorCustomRedirects = r.simplyTranslateTorCustomRedirects; - simplyTranslateI2PRedirectsChecks = r.simplyTranslateI2PRedirectsChecks; - simplyTranslateI2PCustomRedirects = r.simplyTranslateI2PCustomRedirects; + simplyTranslateI2pRedirectsChecks = r.simplyTranslateI2pRedirectsChecks; + simplyTranslateI2pCustomRedirects = r.simplyTranslateI2pCustomRedirects; simplyTranslateLokiRedirectsChecks = r.simplyTranslateLokiRedirectsChecks; simplyTranslateLokiCustomReidrects = r.simplyTranslateLokiCustomReidrects; lingvaNormalRedirectsChecks = r.lingvaNormalRedirectsChecks; @@ -98,7 +99,7 @@ function setRedirects(val) { translateRedirects: redirects, simplyTranslateNormalRedirectsChecks: redirects.simplyTranslate.normal, simplyTranslateTorRedirectsChecks: redirects.simplyTranslate.tor, - simplyTranslateI2PRedirectsChecks: redirects.simplyTranslate.i2p, + simplyTranslateI2pRedirectsChecks: redirects.simplyTranslate.i2p, simplyTranslateLokiRedirectsChecks: redirects.simplyTranslate.loki, lingvaNormalRedirectsChecks, lingvaTorRedirectsChecks: redirects.lingva.tor, @@ -124,9 +125,11 @@ function copyPasteLingvaLocalStorage(test, url, tabId) { { file: "/assets/javascripts/translate/get_lingva_preferences.js", runAt: "document_start" } ); - let checkedInstances; - if (translateProtocol == 'normal') checkedInstances = [...lingvaNormalRedirectsChecks, ...lingvaNormalCustomRedirects]; - if (translateProtocol == 'tor') checkedInstances = [...lingvaTorRedirectsChecks, ...lingvaTorCustomRedirects]; + let checkedInstances = []; + if (protocol == 'tor') checkedInstances = [...lingvaTorRedirectsChecks, ...lingvaTorCustomRedirects]; + if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') { + checkedInstances = [...lingvaNormalRedirectsChecks, ...lingvaNormalCustomRedirects]; + } const i = checkedInstances.indexOf(protocolHost); if (i !== -1) checkedInstances.splice(i, 1); if (checkedInstances.length === 0) { resolve(); return; } @@ -145,9 +148,11 @@ function pasteLingvaLocalStorage() { return new Promise(async resolve => { await init(); if (translateDisable || translateFrontend != 'lingva') { resolve(); return; } - let checkedInstances; - if (translateProtocol == 'normal') checkedInstances = [...lingvaNormalRedirectsChecks, ...lingvaNormalCustomRedirects]; - if (translateProtocol == 'tor') checkedInstances = [...lingvaTorRedirectsChecks, ...lingvaTorCustomRedirects]; + let checkedInstances = []; + if (protocol == 'tor') checkedInstances = [...lingvaTorRedirectsChecks, ...lingvaTorCustomRedirects]; + if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') { + checkedInstances = [...lingvaNormalRedirectsChecks, ...lingvaNormalCustomRedirects]; + } for (const to of checkedInstances) browser.tabs.create({ url: to }, tab => browser.tabs.executeScript(tab.id, { file: "/assets/javascripts/translate/set_lingva_preferences.js", runAt: "document_start" })) @@ -164,17 +169,19 @@ function copyPasteSimplyTranslateCookies(test, from) { ...simplyTranslateNormalCustomRedirects, ...simplyTranslateTorRedirectsChecks, ...simplyTranslateTorCustomRedirects, - ...simplyTranslateI2PRedirectsChecks, - ...simplyTranslateI2PCustomRedirects, + ...simplyTranslateI2pRedirectsChecks, + ...simplyTranslateI2pCustomRedirects, ...simplyTranslateLokiRedirectsChecks, ...simplyTranslateLokiCustomReidrects, ].includes(protocolHost)) { resolve(); return; } if (!test) { - let checkedInstances; - if (translateProtocol == 'normal') checkedInstances = [...simplyTranslateNormalRedirectsChecks, ...simplyTranslateNormalCustomRedirects] - else if (translateProtocol == 'tor') checkedInstances = [...simplyTranslateTorRedirectsChecks, ...simplyTranslateTorCustomRedirects] - else if (translateProtocol == 'i2p') checkedInstances = [...simplyTranslateI2PRedirectsChecks, ...simplyTranslateI2PCustomRedirects] - else if (translateProtocol == 'loki') checkedInstances = [...simplyTranslateLokiRedirectsChecks, ...simplyTranslateLokiCustomReidrects] + let checkedInstances = []; + if (protocol == 'loki') checkedInstances = [...simplyTranslateLokiRedirectsChecks, ...simplyTranslateLokiCustomReidrects] + else if (protocol == 'i2p') checkedInstances = [...simplyTranslateI2pCustomRedirects, ...simplyTranslateI2pRedirectsChecks]; + else if (protocol == 'tor') checkedInstances = [...simplyTranslateTorRedirectsChecks, ...simplyTranslateTorCustomRedirects]; + if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') { + checkedInstances = [...simplyTranslateNormalRedirectsChecks, ...simplyTranslateNormalCustomRedirects]; + } await utils.copyCookie('simplyTranslate', from, checkedInstances, 'from_lang'); await utils.copyCookie('simplyTranslate', from, checkedInstances, 'to_lang'); await utils.copyCookie('simplyTranslate', from, checkedInstances, 'tts_enabled'); @@ -189,11 +196,13 @@ function pasteSimplyTranslateCookies() { return new Promise(async resolve => { await init(); if (translateDisable || translateFrontend != 'simplyTranslate') { resolve(); return; } - let checkedInstances; - if (translateProtocol == 'normal') checkedInstances = [...simplyTranslateNormalRedirectsChecks, ...simplyTranslateNormalCustomRedirects] - else if (translateProtocol == 'tor') checkedInstances = [...simplyTranslateTorRedirectsChecks, ...simplyTranslateTorCustomRedirects] - else if (translateProtocol == 'i2p') checkedInstances = [...simplyTranslateI2PRedirectsChecks, ...simplyTranslateI2PCustomRedirects] - else if (translateProtocol == 'loki') checkedInstances = [...simplyTranslateLokiRedirectsChecks, ...simplyTranslateLokiCustomReidrects] + let checkedInstances = []; + if (protocol == 'loki') checkedInstances = [...simplyTranslateLokiRedirectsChecks, ...simplyTranslateLokiCustomReidrects] + else if (protocol == 'i2p') checkedInstances = [...simplyTranslateI2pCustomRedirects, ...simplyTranslateI2pRedirectsChecks]; + else if (protocol == 'tor') checkedInstances = [...simplyTranslateTorRedirectsChecks, ...simplyTranslateTorCustomRedirects]; + if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') { + checkedInstances = [...simplyTranslateNormalRedirectsChecks, ...simplyTranslateNormalCustomRedirects]; + } utils.getCookiesFromStorage('simplyTranslate', checkedInstances, 'from_lang'); utils.getCookiesFromStorage('simplyTranslate', checkedInstances, 'to_lang'); utils.getCookiesFromStorage('simplyTranslate', checkedInstances, 'tts_enabled'); @@ -208,11 +217,13 @@ function redirect(url, disableOverride) { if (!targets.some(rx => rx.test(url.href))) return; if (translateFrontend == 'simplyTranslate') { - let instancesList; - if (translateProtocol == 'normal') instancesList = [...simplyTranslateNormalRedirectsChecks, ...simplyTranslateNormalCustomRedirects]; - if (translateProtocol == 'tor') instancesList = [...simplyTranslateTorRedirectsChecks, ...simplyTranslateTorCustomRedirects]; - if (translateProtocol == 'i2p') instancesList = [...simplyTranslateI2PRedirectsChecks, ...simplyTranslateI2PCustomRedirects]; - if (translateProtocol == 'loki') instancesList = [...simplyTranslateLokiRedirectsChecks, ...simplyTranslateLokiCustomReidrects]; + let instancesList = []; + if (protocol == 'loki') instancesList = [...simplyTranslateLokiRedirectsChecks, ...simplyTranslateLokiCustomReidrects]; + else if (protocol == 'i2p') instancesList = [...simplyTranslateI2pRedirectsChecks, ...simplyTranslateI2pCustomRedirects]; + else if (protocol == 'tor') instancesList = [...simplyTranslateTorRedirectsChecks, ...simplyTranslateTorCustomRedirects]; + if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { + instancesList = [...simplyTranslateNormalRedirectsChecks, ...simplyTranslateNormalCustomRedirects]; + } if (instancesList.length === 0) return; const randomInstance = utils.getRandomInstance(instancesList) @@ -226,9 +237,11 @@ function redirect(url, disableOverride) { let pair = params_arr[i].split('='); params[pair[0]] = pair[1]; } - let instancesList; - if (translateProtocol == 'normal') instancesList = [...lingvaNormalRedirectsChecks, ...lingvaNormalCustomRedirects]; - if (translateProtocol == 'tor') instancesList = [...lingvaTorRedirectsChecks, ...lingvaTorCustomRedirects]; + let instancesList = []; + if (protocol == 'tor') instancesList = [...lingvaTorRedirectsChecks, ...lingvaTorCustomRedirects]; + if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { + instancesList = [...lingvaNormalRedirectsChecks, ...lingvaNormalCustomRedirects]; + } if (instancesList.length === 0) return; const randomInstance = utils.getRandomInstance(instancesList) @@ -252,7 +265,7 @@ function switchInstance(url, disableOverride) { ...simplyTranslateNormalCustomRedirects, ...simplyTranslateTorCustomRedirects, - ...simplyTranslateI2PCustomRedirects, + ...simplyTranslateI2pCustomRedirects, ...simplyTranslateLokiCustomReidrects, ...translateRedirects.lingva.normal, @@ -263,21 +276,22 @@ function switchInstance(url, disableOverride) { ].includes(protocolHost)) { resolve(); return; } let instancesList; - if (translateProtocol == 'normal') { - if (translateFrontend == 'simplyTranslate') instancesList = [...simplyTranslateNormalRedirectsChecks, ...simplyTranslateNormalCustomRedirects]; - else if (translateFrontend == 'lingva') instancesList = [...lingvaNormalRedirectsChecks, ...lingvaNormalCustomRedirects]; + + if (protocol == 'loki') { + if (translateFrontend == 'simplyTranslate') instancesList = [...simplyTranslateLokiRedirectsChecks, ...simplyTranslateLokiCustomReidrects]; + //else if (translateFrontend == 'lingva') instancesList = [...lingvaLokiRedirectsChecks, ...lingvaLokiCustomRedirects]; + } + else if (protocol == 'i2p') { + if (translateFrontend == 'simplyTranslate') instancesList = [...simplyTranslateI2pRedirectsChecks, ...simplyTranslateI2pCustomRedirects]; + //else if (translateFrontend == 'lingva') instancesList = [...lingvaI2PRedirectsChecks, ...lingvaI2PCustomRedirects]; } - else if (translateProtocol == 'tor') { + else if (protocol == 'tor') { if (translateFrontend == 'simplyTranslate') instancesList = [...simplyTranslateTorRedirectsChecks, ...simplyTranslateTorCustomRedirects]; else if (translateFrontend == 'lingva') instancesList = [...lingvaTorRedirectsChecks, ...lingvaTorCustomRedirects]; } - else if (translateProtocol == 'i2p') { - if (translateFrontend == 'simplyTranslate') instancesList = [...simplyTranslateI2PRedirectsChecks, ...simplyTranslateI2PCustomRedirects]; - //else if (translateFrontend == 'lingva') instancesList = [...lingvaI2PRedirectsChecks, ...lingvaI2PCustomRedirects]; - } - else if (translateProtocol == 'loki') { - if (translateFrontend == 'simplyTranslate') instancesList = [...simplyTranslateLokiRedirectsChecks, ...simplyTranslateLokiCustomReidrects]; - //else if (translateFrontend == 'lingva') instancesList = [...lingvaLokiRedirectsChecks, ...lingvaLokiCustomRedirects]; + if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { + if (translateFrontend == 'simplyTranslate') instancesList = [...simplyTranslateNormalRedirectsChecks, ...simplyTranslateNormalCustomRedirects]; + else if (translateFrontend == 'lingva') instancesList = [...lingvaNormalRedirectsChecks, ...lingvaNormalCustomRedirects]; } const i = instancesList.indexOf(protocolHost); @@ -293,8 +307,9 @@ function initDefaults() { return new Promise(async resolve => { fetch('/instances/data.json').then(response => response.text()).then(data => { let dataJson = JSON.parse(data); - redirects.simplyTranslate = dataJson.simplyTranslate; - redirects.lingva = dataJson.lingva; + for (let i = 0; i < frontends.length; i++) { + redirects[frontends[i]] = dataJson[frontends[i]] + } browser.storage.local.get('cloudflareBlackList', async r => { lingvaNormalRedirectsChecks = [...redirects.lingva.normal] @@ -305,15 +320,14 @@ function initDefaults() { browser.storage.local.set({ translateDisable: false, translateFrontend: "simplyTranslate", - translateProtocol: 'normal', translateRedirects: redirects, simplyTranslateNormalRedirectsChecks: [...redirects.simplyTranslate.normal], simplyTranslateNormalCustomRedirects: [], simplyTranslateTorRedirectsChecks: [...redirects.simplyTranslate.tor], simplyTranslateTorCustomRedirects: [], - simplyTranslateI2PRedirectsChecks: [...redirects.simplyTranslate.i2p], - simplyTranslateI2PCustomRedirects: [], + simplyTranslateI2pRedirectsChecks: [...redirects.simplyTranslate.i2p], + simplyTranslateI2pCustomRedirects: [], simplyTranslateLokiRedirectsChecks: [...redirects.simplyTranslate.loki], simplyTranslateLokiCustomReidrects: [], diff --git a/src/assets/javascripts/twitter.js b/src/assets/javascripts/twitter.js index bd674aba..e69d9abc 100644 --- a/src/assets/javascripts/twitter.js +++ b/src/assets/javascripts/twitter.js @@ -9,12 +9,17 @@ const targets = [ /^https?:\/{2}t\.co/ ]; -let redirects = { - "nitter": { - "normal": [], - "tor": [] - }, -}; +const frontends = new Array("nitter") +const protocols = new Array("normal", "tor", "i2p", "loki") + +let redirects = {} + +for (let i = 0; i < frontends.length; i++) { + redirects[frontends[i]] = {} + for (let x = 0; x < protocols.length; x++) { + redirects[frontends[i]][protocols[x]] = [] + } +} function setRedirects(val) { browser.storage.local.get(['cloudflareBlackList', 'authenticateBlackList'], r => { @@ -34,7 +39,8 @@ function setRedirects(val) { let disableTwitter, - twitterProtocol, + protocol, + protocolFallback, twitterRedirects, twitterRedirectType, nitterNormalRedirectsChecks, @@ -47,7 +53,8 @@ function init() { browser.storage.local.get( [ "disableTwitter", - "twitterProtocol", + "protocol", + "protocolFallback", "twitterRedirects", "twitterRedirectType", "nitterNormalRedirectsChecks", @@ -57,7 +64,8 @@ function init() { ], r => { disableTwitter = r.disableTwitter; - twitterProtocol = r.twitterProtocol; + protocol = r.protocol; + protocolFallback = r.protocolFallback; twitterRedirects = r.twitterRedirects; twitterRedirectType = r.twitterRedirectType; nitterNormalRedirectsChecks = r.nitterNormalRedirectsChecks; @@ -90,9 +98,11 @@ function redirect(url, type, initiator, disableOverride) { if (twitterRedirectType == 'sub_frame' && type == "main_frame") return; if (twitterRedirectType == 'main_frame' && type != "main_frame") return; - let instancesList; - if (twitterProtocol == 'normal') instancesList = [...nitterNormalRedirectsChecks, ...nitterNormalCustomRedirects]; - else if (twitterProtocol == 'tor') instancesList = [...nitterTorRedirectsChecks, ...nitterTorCustomRedirects]; + let instancesList = []; + if (protocol == 'tor') instancesList = [...nitterTorRedirectsChecks, ...nitterTorCustomRedirects]; + if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { + instancesList = [...nitterNormalRedirectsChecks, ...nitterNormalCustomRedirects]; + } if (instancesList.length === 0) return; const randomInstance = utils.getRandomInstance(instancesList); @@ -125,9 +135,11 @@ function switchInstance(url, disableOverride) { if (disableTwitter && !disableOverride) { resolve(); return; } const protocolHost = utils.protocolHost(url); if (!all().includes(protocolHost)) { resolve(); return; } - let instancesList; - if (twitterProtocol == 'normal') instancesList = [...nitterNormalRedirectsChecks, ...nitterNormalCustomRedirects]; - else if (twitterProtocol == 'tor') instancesList = [...nitterTorRedirectsChecks, ...nitterTorCustomRedirects]; + let instancesList = []; + if (protocol == 'tor') instancesList = [...nitterTorRedirectsChecks, ...nitterTorCustomRedirects]; + if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { + instancesList = [...nitterNormalRedirectsChecks, ...nitterNormalCustomRedirects]; + } let index = instancesList.indexOf(protocolHost); if (index > -1) instancesList.splice(index, 1); @@ -164,9 +176,11 @@ function initNitterCookies(test, from) { if (!all().includes(protocolHost) ) { resolve(); return; } if (!test) { - let checkedInstances; - if (twitterProtocol == 'normal') checkedInstances = [...nitterNormalRedirectsChecks, ...nitterNormalCustomRedirects] - else if (twitterProtocol == 'tor') checkedInstances = [...nitterTorRedirectsChecks, ...nitterTorCustomRedirects] + let checkedInstances = []; + if (protocol == 'tor') checkedInstances = [...nitterTorRedirectsChecks, ...nitterTorCustomRedirects]; + if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') { + checkedInstances = [...nitterNormalRedirectsChecks, ...nitterNormalCustomRedirects]; + } await utils.copyCookie('nitter', from, checkedInstances, 'theme'); await utils.copyCookie('nitter', from, checkedInstances, 'infiniteScroll'); await utils.copyCookie('nitter', from, checkedInstances, 'stickyProfile'); @@ -194,10 +208,12 @@ function initNitterCookies(test, from) { function pasteNitterCookies() { return new Promise(async resolve => { await init(); - if (disableTwitter || twitterProtocol === undefined) { resolve(); return; } - let checkedInstances; - if (twitterProtocol == 'normal') checkedInstances = [...nitterNormalRedirectsChecks, ...nitterNormalCustomRedirects] - else if (twitterProtocol == 'tor') checkedInstances = [...nitterTorRedirectsChecks, ...nitterTorCustomRedirects] + if (disableTwitter || protocol === undefined) { resolve(); return; } + let checkedInstances = []; + if (protocol == 'tor') checkedInstances = [...nitterTorRedirectsChecks, ...nitterTorCustomRedirects]; + if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') { + checkedInstances = [...nitterNormalRedirectsChecks, ...nitterNormalCustomRedirects]; + } utils.getCookiesFromStorage('nitter', checkedInstances, 'theme'); utils.getCookiesFromStorage('nitter', checkedInstances, 'infiniteScroll'); utils.getCookiesFromStorage('nitter', checkedInstances, 'stickyProfile'); @@ -226,7 +242,9 @@ function initDefaults() { return new Promise(resolve => { fetch('/instances/data.json').then(response => response.text()).then(data => { let dataJson = JSON.parse(data); - redirects.nitter = dataJson.nitter; + for (let i = 0; i < frontends.length; i++) { + redirects[frontends[i]] = dataJson[frontends[i]] + } browser.storage.local.get(['cloudflareBlackList', 'authenticateBlackList'], async r => { nitterNormalRedirectsChecks = [...redirects.nitter.normal]; for (const instance of [...r.cloudflareBlackList, ...r.authenticateBlackList]) { @@ -236,7 +254,6 @@ function initDefaults() { browser.storage.local.set({ disableTwitter: false, twitterRedirects: redirects, - twitterProtocol: "normal", twitterRedirectType: "both", nitterNormalRedirectsChecks: nitterNormalRedirectsChecks, diff --git a/src/assets/javascripts/utils.js b/src/assets/javascripts/utils.js index a5300364..f9d48275 100644 --- a/src/assets/javascripts/utils.js +++ b/src/assets/javascripts/utils.js @@ -53,6 +53,7 @@ function updateInstances() { libremdbHelper.setRedirects(instances.libremdb); sendTargetsHelper.setRedirects(instances.send); tiktokHelper.setRedirects(instances.proxiTok); + lbryHelper.setRedirects(instances.librarian); console.info("Successfully updated Instances"); resolve(true); return; @@ -119,13 +120,13 @@ async function processDefaultCustomInstances(target, name, protocol, document) { for (const element of nameCheckListElement.getElementsByTagName('input')) element.checked = nameDefaultRedirects.includes(element.className) if (nameDefaultRedirects.length == 0) isTrue = false; - nameProtocolElement.getElementsByClassName('toogle-all')[0].checked = isTrue; + nameProtocolElement.getElementsByClassName('toggle-all')[0].checked = isTrue; } nameCheckListElement.innerHTML = [ `<div> <x data-localise="__MSG_toggleAll__">Toggle All</x> - <input type="checkbox" class="toogle-all"/> + <input type="checkbox" class="toggle-all"/> </div>`, ...redirects[name][protocol].map( x => { @@ -153,7 +154,7 @@ async function processDefaultCustomInstances(target, name, protocol, document) { localise.localisePage(); calcNameCheckBoxes(); - nameProtocolElement.getElementsByClassName('toogle-all')[0].addEventListener("change", async event => { + nameProtocolElement.getElementsByClassName('toggle-all')[0].addEventListener("change", async event => { if (event.target.checked) nameDefaultRedirects = [...redirects[name][protocol]]; else @@ -164,7 +165,7 @@ async function processDefaultCustomInstances(target, name, protocol, document) { }); for (let element of nameCheckListElement.getElementsByTagName('input')) { - if (element.className != 'toogle-all') + if (element.className != 'toggle-all') nameProtocolElement.getElementsByClassName(element.className)[0].addEventListener("change", async event => { if (event.target.checked) nameDefaultRedirects.push(element.className) diff --git a/src/assets/javascripts/wikipedia.js b/src/assets/javascripts/wikipedia.js index 629219b8..d945e221 100644 --- a/src/assets/javascripts/wikipedia.js +++ b/src/assets/javascripts/wikipedia.js @@ -4,13 +4,18 @@ import utils from './utils.js' const targets = /^https?:\/{2}(([a-z]{1,}\.){0,})wikipedia\.org/ -let redirects = { - "wikiless": { - "normal": [], - "tor": [], - "i2p": [] - } -}; +const frontends = new Array("wikiless") +const protocols = new Array("normal", "tor", "i2p", "loki") + +let redirects = {}; + +for (let i = 0; i < frontends.length; i++) { + redirects[frontends[i]] = {} + for (let x = 0; x < protocols.length; x++) { + redirects[frontends[i]][protocols[x]] = [] + } +} + function setRedirects(val) { browser.storage.local.get('cloudflareBlackList', r => { redirects.wikiless = val; @@ -29,7 +34,8 @@ function setRedirects(val) { let disableWikipedia, wikipediaRedirects, - wikipediaProtocol, + protocol, + protocolFallback, wikilessNormalRedirectsChecks, wikilessTorRedirectsChecks, wikilessI2pRedirectsChecks, @@ -43,8 +49,8 @@ function init() { [ "disableWikipedia", "wikipediaRedirects", - "wikipediaProtocol", - + "protocol", + "protocolFallback", "wikilessNormalRedirectsChecks", "wikilessTorRedirectsChecks", "wikilessI2pRedirectsChecks", @@ -55,7 +61,8 @@ function init() { r => { disableWikipedia = r.disableWikipedia; wikipediaRedirects = r.wikipediaRedirects; - wikipediaProtocol = r.wikipediaProtocol; + protocol = r.protocol; + protocolFallback = r.protocolFallback; wikilessNormalRedirectsChecks = r.wikilessNormalRedirectsChecks; wikilessTorRedirectsChecks = r.wikilessTorRedirectsChecks; wikilessI2pRedirectsChecks = r.wikilessI2pRedirectsChecks; @@ -86,10 +93,12 @@ function initWikilessCookies(test, from) { if (!all.includes(protocolHost)) { resolve(); return; } if (!test) { - let checkedInstances; - if (wikipediaProtocol == 'normal') checkedInstances = [...wikilessNormalRedirectsChecks, ...wikilessNormalCustomRedirects] - else if (wikipediaProtocol == 'tor') checkedInstances = [...wikilessTorRedirectsChecks, ...wikilessTorCustomRedirects] - else if (wikipediaProtocol == 'i2p') checkedInstances = [...wikilessI2pRedirectsChecks, ...wikilessI2pCustomRedirects] + let checkedInstances = []; + if (protocol == 'i2p') checkedInstances = [...wikilessI2pCustomRedirects, ...wikilessI2pRedirectsChecks]; + if (protocol == 'tor') checkedInstances = [...wikilessTorRedirectsChecks, ...wikilessTorCustomRedirects]; + if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') { + checkedInstances = [...wikilessNormalRedirectsChecks, ...wikilessNormalCustomRedirects]; + } await utils.copyCookie('wikiless', from, checkedInstances, 'theme'); await utils.copyCookie('wikiless', from, checkedInstances, 'default_lang'); } @@ -100,10 +109,13 @@ function initWikilessCookies(test, from) { function pasteWikilessCookies() { return new Promise(async resolve => { await init(); - if (disableWikipedia || wikipediaProtocol === undefined) { resolve(); return; } - let checkedInstances; - if (wikipediaProtocol == 'normal') checkedInstances = [...wikilessNormalRedirectsChecks, ...wikilessNormalCustomRedirects] - else if (wikipediaProtocol == 'tor') checkedInstances = [...wikilessTorRedirectsChecks, ...wikilessTorCustomRedirects] + if (disableWikipedia || protocol === undefined) { resolve(); return; } + let checkedInstances = []; + if (protocol == 'i2p') checkedInstances = [...wikilessI2pCustomRedirects, ...wikilessI2pRedirectsChecks]; + else if (protocol == 'tor') checkedInstances = [...wikilessTorRedirectsChecks, ...wikilessTorCustomRedirects]; + if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') { + checkedInstances = [...wikilessNormalRedirectsChecks, ...wikilessNormalCustomRedirects]; + } utils.getCookiesFromStorage('wikiless', checkedInstances, 'theme'); utils.getCookiesFromStorage('wikiless', checkedInstances, 'default_lang'); resolve(); @@ -123,10 +135,12 @@ function redirect(url, disableOverride) { GETArguments.push([args[0], args[1]]); } } - let instancesList; - if (wikipediaProtocol == 'normal') instancesList = [...wikilessNormalRedirectsChecks, ...wikilessNormalCustomRedirects]; - else if (wikipediaProtocol == 'tor') instancesList = [...wikilessTorRedirectsChecks, ...wikilessTorCustomRedirects]; - else if (wikipediaProtocol == 'i2p') instancesList = [...wikilessI2pRedirectsChecks, ...wikilessI2pCustomRedirects]; + let instancesList = []; + if (protocol == 'i2p') instancesList = [...wikilessI2pCustomRedirects, ...wikilessI2pRedirectsChecks]; + else if (protocol == 'tor') instancesList = [...wikilessTorRedirectsChecks, ...wikilessTorCustomRedirects]; + if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { + instancesList = [...wikilessNormalRedirectsChecks, ...wikilessNormalCustomRedirects]; + } if (instancesList.length === 0) return; const randomInstance = utils.getRandomInstance(instancesList) @@ -162,10 +176,12 @@ function switchInstance(url, disableOverride) { ]; if (!wikipediaList.includes(protocolHost)) { resolve(); return; } - let instancesList; - if (wikipediaProtocol == 'normal') instancesList = [...wikilessNormalCustomRedirects, ...wikilessNormalRedirectsChecks]; - else if (wikipediaProtocol == 'tor') instancesList = [...wikilessTorCustomRedirects, ...wikilessTorRedirectsChecks]; - else if (wikipediaProtocol == 'i2p') instancesList = [...wikilessI2pCustomRedirects, ...wikilessI2pRedirectsChecks]; + let instancesList = []; + if (protocol == 'i2p') instancesList = [...wikilessI2pCustomRedirects, ...wikilessI2pRedirectsChecks]; + else if (protocol == 'tor') instancesList = [...wikilessTorRedirectsChecks, ...wikilessTorCustomRedirects]; + if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { + instancesList = [...wikilessNormalRedirectsChecks, ...wikilessNormalCustomRedirects]; + } let index = instancesList.indexOf(protocolHost); if (index > -1) instancesList.splice(index, 1); @@ -180,7 +196,9 @@ function initDefaults() { return new Promise(resolve => { fetch('/instances/data.json').then(response => response.text()).then(async data => { let dataJson = JSON.parse(data); - redirects.wikiless = dataJson.wikiless; + for (let i = 0; i < frontends.length; i++) { + redirects[frontends[i]] = dataJson[frontends[i]] + } browser.storage.local.get('cloudflareBlackList', async r => { wikilessNormalRedirectsChecks = [...redirects.wikiless.normal]; for (const instance of r.cloudflareBlackList) { @@ -190,7 +208,6 @@ function initDefaults() { browser.storage.local.set({ disableWikipedia: true, wikipediaRedirects: redirects, - wikipediaProtocol: "normal", wikilessNormalRedirectsChecks: wikilessNormalRedirectsChecks, wikilessTorRedirectsChecks: [...redirects.wikiless.tor], wikilessI2pRedirectsChecks: [...redirects.wikiless.i2p], diff --git a/src/assets/javascripts/youtube/youtube.js b/src/assets/javascripts/youtube/youtube.js index 965b94bf..feb2fc12 100644 --- a/src/assets/javascripts/youtube/youtube.js +++ b/src/assets/javascripts/youtube/youtube.js @@ -16,23 +16,19 @@ const targets = [ /^https?:\/{2}(www\.|)(youtube|youtube-nocookie)\.com\/embed\/..*/, ]; -let redirects = { - "invidious": { - "normal": [], - "tor": [] - }, - "piped": { - "normal": [], - "tor": [] - }, - "pipedMaterial": { - "normal": [ - "https://piped-material.xn--17b.net", - "https://piped-material.ftp.sh", - ], - "tor": [] - } -}; + +const frontends = new Array("invidious", "piped", "pipedMaterial") +const protocols = new Array("normal", "tor", "i2p", "loki") + +let redirects = {}; + +for (let i = 0; i < frontends.length; i++) { + redirects[frontends[i]] = {} + for (let x = 0; x < protocols.length; x++) { + redirects[frontends[i]][protocols[x]] = [] + } +} + function setRedirects(val) { browser.storage.local.get('cloudflareBlackList', r => { redirects.invidious = val.invidious; @@ -60,7 +56,8 @@ let disableYoutube, onlyEmbeddedVideo, youtubeFrontend, - youtubeProtocol, + protocol, + protocolFallback, youtubeEmbedFrontend, youtubeRedirects, invidiousNormalRedirectsChecks, @@ -83,7 +80,8 @@ function init() { "disableYoutube", "onlyEmbeddedVideo", "youtubeFrontend", - "youtubeProtocol", + "protocol", + "protocolFallback", "youtubeEmbedFrontend", "youtubeRedirects", "invidiousNormalRedirectsChecks", @@ -103,7 +101,8 @@ function init() { disableYoutube = r.disableYoutube; onlyEmbeddedVideo = r.onlyEmbeddedVideo; youtubeFrontend = r.youtubeFrontend; - youtubeProtocol = r.youtubeProtocol; + protocol = r.protocol; + protocolFallback = r.protocolFallback; youtubeEmbedFrontend = r.youtubeEmbedFrontend; youtubeRedirects = r.youtubeRedirects; invidiousNormalRedirectsChecks = r.invidiousNormalRedirectsChecks; @@ -178,25 +177,31 @@ function redirect(url, type, initiator, disableOverride) { if (isFreetube && main_frame) return `freetube://https://youtube.com${url.pathname}${url.search}`; if (isInvidious || ((isFreetube || isYatte) && sub_frame && isFrontendInvidious)) { - let instancesList; - if (youtubeProtocol == 'normal') instancesList = [...invidiousNormalRedirectsChecks, ...invidiousNormalCustomRedirects]; - else if (youtubeProtocol == 'tor') instancesList = [...invidiousTorRedirectsChecks, ...invidiousTorCustomRedirects]; + let instancesList = [] = []; + 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 (youtubeProtocol == 'normal') instancesList = [...pipedNormalRedirectsChecks, ...pipedNormalCustomRedirects]; - else if (youtubeProtocol == 'tor') instancesList = [...pipedTorRedirectsChecks, ...pipedTorCustomRedirects]; + let instancesList = []; + if (protocol == 'tor') instancesList = [...pipedTorRedirectsChecks, ...pipedTorCustomRedirects]; + if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { + instancesList = [...pipedNormalRedirectsChecks, ...pipedNormalCustomRedirects]; + } if (instancesList.length === 0) return; const randomInstance = utils.getRandomInstance(instancesList); return `${randomInstance}${url.pathname}${url.search}`; } if (isPipedMaterial || ((isFreetube || isYatte) && sub_frame && isFrontendPipedMaterial)) { - let instancesList; - if (youtubeProtocol == 'normal') instancesList = [...pipedMaterialNormalRedirectsChecks, ...pipedMaterialNormalCustomRedirects]; - else if (youtubeProtocol == 'tor') instancesList = [...pipedMaterialTorRedirectsChecks, ...pipedMaterialTorCustomRedirects]; + let instancesList = []; + if (protocol == 'tor') instancesList = [...pipedMaterialTorRedirectsChecks, ...pipedMaterialTorCustomRedirects]; + if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { + instancesList = [...pipedMaterialNormalRedirectsChecks, ...pipedMaterialNormalCustomRedirects]; + } const randomInstance = utils.getRandomInstance(instancesList); return `${randomInstance}${url.pathname}${url.search}`; } @@ -219,17 +224,18 @@ function switchInstance(url, disableOverride) { const protocolHost = utils.protocolHost(url); if (!all().includes(protocolHost)) { resolve(); return; } - let instancesList; - if (youtubeProtocol == 'normal') { - if (youtubeFrontend == 'invidious') instancesList = [...invidiousNormalRedirectsChecks, ...invidiousNormalCustomRedirects]; - else if (youtubeFrontend == 'piped') instancesList = [...pipedNormalRedirectsChecks, ...pipedNormalCustomRedirects]; - else if (youtubeFrontend == 'pipedMaterial') instancesList = [...pipedMaterialNormalRedirectsChecks, ...pipedMaterialNormalCustomRedirects]; - } - else if (youtubeProtocol == 'tor') { + let instancesList = [] = []; + + if (protocol == 'tor') { if (youtubeFrontend == 'invidious') instancesList = [...invidiousTorRedirectsChecks, ...invidiousTorCustomRedirects]; else if (youtubeFrontend == 'piped') instancesList = [...pipedTorRedirectsChecks, ...pipedTorCustomRedirects]; else if (youtubeFrontend == 'pipedMaterial') instancesList = [...pipedMaterialTorRedirectsChecks, ...pipedMaterialTorCustomRedirects]; } + if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { + if (youtubeFrontend == 'invidious') instancesList = [...invidiousNormalRedirectsChecks, ...invidiousNormalCustomRedirects]; + else if (youtubeFrontend == 'piped') instancesList = [...pipedNormalRedirectsChecks, ...pipedNormalCustomRedirects]; + else if (youtubeFrontend == 'pipedMaterial') instancesList = [...pipedMaterialNormalRedirectsChecks, ...pipedMaterialNormalCustomRedirects]; + } const i = instancesList.indexOf(protocolHost); if (i > -1) instancesList.splice(i, 1); @@ -244,8 +250,9 @@ function initDefaults() { return new Promise(async resolve => { fetch('/instances/data.json').then(response => response.text()).then(async data => { let dataJson = JSON.parse(data); - redirects.invidious = dataJson.invidious; - redirects.piped = dataJson.piped; + for (let i = 0; i < frontends.length; i++) { + redirects[frontends[i]] = dataJson[frontends[i]] + } browser.storage.local.get('cloudflareBlackList', async r => { invidiousNormalRedirectsChecks = [...redirects.invidious.normal]; @@ -290,8 +297,7 @@ function initDefaults() { pipedMaterialTorRedirectsChecks: [...redirects.pipedMaterial.tor], pipedMaterialTorCustomRedirects: [], - youtubeEmbedFrontend: 'invidious', - youtubeProtocol: 'normal', + youtubeEmbedFrontend: 'invidious' }, () => resolve()) }) }) @@ -310,9 +316,12 @@ function copyPasteInvidiousCookies(test, from) { ...invidiousTorCustomRedirects, ].includes(protocolHost)) { resolve(); return; } if (!test) { - let checkedInstances; - if (youtubeProtocol == 'normal') checkedInstances = [...invidiousNormalRedirectsChecks, ...invidiousNormalCustomRedirects] - else if (youtubeProtocol == 'tor') checkedInstances = [...invidiousTorRedirectsChecks, ...invidiousTorCustomRedirects] + let checkedInstances = []; + + if (protocol == 'tor') checkedInstances = [...invidiousTorRedirectsChecks, ...invidiousTorCustomRedirects] + if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { + checkedInstances = [...invidiousNormalRedirectsChecks, ...invidiousNormalCustomRedirects] + } const i = checkedInstances.indexOf(protocolHost); if (i !== -1) checkedInstances.splice(i, 1); await utils.copyCookie('invidious', from, checkedInstances, 'PREFS'); @@ -325,9 +334,11 @@ function pasteInvidiousCookies() { return new Promise(async resolve => { await init(); if (disableYoutube || youtubeFrontend != 'invidious') { resolve(); return; } - let checkedInstances; - if (youtubeProtocol == 'normal') checkedInstances = [...invidiousNormalRedirectsChecks, ...invidiousNormalCustomRedirects] - else if (youtubeProtocol == 'tor') checkedInstances = [...invidiousTorRedirectsChecks, ...invidiousTorCustomRedirects] + let checkedInstances = []; + if (protocol == 'tor') checkedInstances = [...invidiousTorRedirectsChecks, ...invidiousTorCustomRedirects] + if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { + checkedInstances = [...invidiousNormalRedirectsChecks, ...invidiousNormalCustomRedirects] + } utils.getCookiesFromStorage('invidious', checkedInstances, 'PREFS'); resolve(); }) @@ -348,9 +359,11 @@ function copyPastePipedLocalStorage(test, url, tabId) { if (!test) { browser.tabs.executeScript(tabId, { file: "/assets/javascripts/youtube/get_piped_preferences.js", runAt: "document_start" }); - let checkedInstances; - if (youtubeProtocol == 'normal') checkedInstances = [...pipedNormalCustomRedirects, ...pipedNormalRedirectsChecks] - else if (youtubeProtocol == 'tor') checkedInstances = [...pipedTorRedirectsChecks, ...pipedTorCustomRedirects] + let checkedInstances = []; + if (protocol == 'tor') checkedInstances = [...pipedTorRedirectsChecks, ...pipedTorCustomRedirects] + if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { + checkedInstances = [...pipedNormalCustomRedirects, ...pipedNormalRedirectsChecks] + } const i = checkedInstances.indexOf(protocolHost); if (i !== -1) checkedInstances.splice(i, 1); for (const to of checkedInstances) { @@ -365,9 +378,11 @@ function pastePipedLocalStorage() { return new Promise(async resolve => { await init(); if (disableYoutube || youtubeFrontend != 'piped') { resolve(); return; } - let checkedInstances; - if (youtubeProtocol == 'normal') checkedInstances = [...pipedNormalCustomRedirects, ...pipedNormalRedirectsChecks] - else if (youtubeProtocol == 'tor') checkedInstances = [...pipedTorRedirectsChecks, ...pipedTorCustomRedirects] + let checkedInstances = []; + if (protocol == 'tor') checkedInstances = [...pipedTorRedirectsChecks, ...pipedTorCustomRedirects] + if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { + checkedInstances = [...pipedNormalCustomRedirects, ...pipedNormalRedirectsChecks] + } for (const to of checkedInstances) { browser.tabs.create({ url: to }, tab => browser.tabs.executeScript(tab.id, { file: "/assets/javascripts/youtube/set_piped_preferences.js", runAt: "document_start" })) @@ -391,9 +406,11 @@ function copyPastePipedMaterialLocalStorage(test, url, tabId,) { if (!test) { browser.tabs.executeScript(tabId, { file: "/assets/javascripts/youtube/get_pipedMaterial_preferences.js", runAt: "document_start" }); - let checkedInstances; - if (youtubeProtocol == 'normal') checkedInstances = [...pipedMaterialNormalRedirectsChecks, ...pipedMaterialNormalCustomRedirects] - else if (youtubeProtocol == 'tor') checkedInstances = [...pipedMaterialTorRedirectsChecks, ...pipedMaterialTorCustomRedirects] + let checkedInstances = []; + if (protocol == 'tor') checkedInstances = [...pipedMaterialTorRedirectsChecks, ...pipedMaterialTorCustomRedirects] + if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { + checkedInstances = [...pipedMaterialNormalRedirectsChecks, ...pipedMaterialNormalCustomRedirects] + } const i = checkedInstances.indexOf(protocolHost); if (i !== -1) checkedInstances.splice(i, 1); for (const to of checkedInstances) @@ -410,9 +427,11 @@ function pastePipedMaterialLocalStorage() { return new Promise(async resolve => { await init(); if (disableYoutube || youtubeFrontend != 'pipedMaterial') { resolve(); return; } - let checkedInstances; - if (youtubeProtocol == 'normal') checkedInstances = [...pipedMaterialNormalRedirectsChecks, ...pipedMaterialNormalCustomRedirects] - else if (youtubeProtocol == 'tor') checkedInstances = [...pipedMaterialTorRedirectsChecks, ...pipedMaterialTorCustomRedirects] + let checkedInstances = []; + if (protocol == 'tor') checkedInstances = [...pipedMaterialTorRedirectsChecks, ...pipedMaterialTorCustomRedirects] + if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { + checkedInstances = [...pipedMaterialNormalRedirectsChecks, ...pipedMaterialNormalCustomRedirects] + } for (const to of checkedInstances) { browser.tabs.create({ url: to }, tab => browser.tabs.executeScript(tab.id, { file: "/assets/javascripts/youtube/set_pipedMaterial_preferences.js", runAt: "document_start" })) @@ -427,18 +446,16 @@ function removeXFrameOptions(e) { if (e.type == 'main_frame') { for (const i in e.responseHeaders) { if (e.responseHeaders[i].name == 'content-security-policy') { - let instancesList; - if (youtubeFrontend == 'invidious') { - if (youtubeProtocol == 'normal') instancesList = [...invidiousNormalRedirectsChecks, ...invidiousNormalCustomRedirects]; - else if (youtubeProtocol == 'tor') instancesList = [...invidiousTorRedirectsChecks, ...invidiousTorCustomRedirects]; - } - else if (youtubeFrontend == 'piped') { - if (youtubeProtocol == 'normal') instancesList = [...pipedNormalRedirectsChecks, ...pipedNormalCustomRedirects]; - else if (youtubeProtocol == 'tor') instancesList = [...pipedTorRedirectsChecks, ...pipedTorCustomRedirects]; + let instancesList = []; + if (protocol == 'tor') { + if (youtubeFrontend == 'invidious') instancesList = [...invidiousTorRedirectsChecks, ...invidiousTorCustomRedirects]; + if (youtubeFrontend == 'piped') instancesList = [...pipedTorRedirectsChecks, ...pipedTorCustomRedirects]; + if (youtubeFrontend == 'pipedMaterial') instancesList = [...pipedMaterialTorRedirectsChecks, ...pipedMaterialTorCustomRedirects]; } - else if (youtubeFrontend == 'pipedMaterial') { - if (youtubeProtocol == 'normal') instancesList = [...pipedMaterialNormalRedirectsChecks, ...pipedMaterialNormalCustomRedirects]; - else if (youtubeProtocol == 'tor') instancesList = [...pipedMaterialTorRedirectsChecks, ...pipedMaterialTorCustomRedirects]; + if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { + if (youtubeFrontend == 'invidious') instancesList = [...invidiousNormalRedirectsChecks, ...invidiousNormalCustomRedirects]; + if (youtubeFrontend == 'piped') instancesList = [...pipedNormalRedirectsChecks, ...pipedNormalCustomRedirects]; + if (youtubeFrontend == 'pipedMaterial') instancesList = [...pipedMaterialNormalRedirectsChecks, ...pipedMaterialNormalCustomRedirects]; } let securityPolicyList = e.responseHeaders[i].value.split(';'); for (const i in securityPolicyList) securityPolicyList[i] = securityPolicyList[i].trim(); diff --git a/src/instances/get_instances.py b/src/instances/get_instances.py index e211a596..b7ff2432 100644 --- a/src/instances/get_instances.py +++ b/src/instances/get_instances.py @@ -103,6 +103,20 @@ def piped(): print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'Piped') +def pipedMaterial(): + r = requests.get( + 'https://raw.githubusercontent.com/mmjee/Piped-Material/master/README.md') + + tmp = re.findall( + r"\| (https?:\/{2}(?:.+\.)+[a-zA-Z0-9]*) +\|", r.text) + pipedMaterialList = {} + pipedMaterialList['normal'] = [] + for item in tmp: + pipedMaterialList['normal'].append(item) + mightyList['pipedMaterial'] = pipedMaterialList + print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'pipedMaterial') + + def proxitok(): r = requests.get( 'https://raw.githubusercontent.com/wiki/pablouser1/ProxiTok/Public-instances.md') @@ -181,9 +195,8 @@ def libreddit(): tmp = re.findall( r"\| \[.*\]\(([-a-zA-Z0-9@:%_\+.~#?&//=]{2,}\.[a-z]{2,}\b(?:\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?)\)*\|*[A-Z]{0,}.*\|.*\|", r.text) - for item in tmp: - if item.endswith('.onion'): + if re.search("https?:\/{2}(?:[a-zA-Z0-9]+\.)+onion(?:\/[a-zA-Z0-9]+)*\/?", item): libredditList['tor'].append(item) else: libredditList['normal'].append(item) @@ -220,11 +233,14 @@ def wikiless(): wikilessList['i2p'] = [] for item in rJson: if 'url' in item: - wikilessList['normal'].append(item['url']) + if item['url'].strip() != "": + wikilessList['normal'].append(item['url']) if 'onion' in item: - wikilessList['tor'].append(item['onion']) + if item['onion'].strip() != "": + wikilessList['tor'].append(item['onion']) if 'i2p' in item: - wikilessList['i2p'].append(item['i2p']) + if item['i2p'].strip() != "": + wikilessList['i2p'].append(item['i2p']) mightyList['wikiless'] = wikilessList print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'Wikiless') @@ -254,7 +270,7 @@ def quetre(): for item in tmp: - if item.endswith('.onion'): + if re.search("https?:\/{2}(?:[a-zA-Z0-9]+\.)+onion(?:\/[a-zA-Z0-9]+)*\/?", item): _list['tor'].append(item) else: _list['normal'].append(item) @@ -276,7 +292,7 @@ def libremdb(): for item in tmp: if item.strip() == "": continue - if item.endswith('.onion'): + if re.search("https?:\/{2}(?:[a-zA-Z0-9]+\.)+onion(?:\/[a-zA-Z0-9]+)*\/?", item): _list['tor'].append(item) else: _list['normal'].append(item) @@ -337,12 +353,12 @@ def searx_searxng(): searxngList['i2p'] = [] searxngList['normal'] = [] for item in rJson['instances']: - if item[:-1].endswith('.onion'): + if re.search("https?:\/{2}(?:[a-zA-Z0-9]+\.)+onion(?:\/[a-zA-Z0-9]+)*\/?", item[:-1]): if (rJson['instances'][item].get('generator') == 'searxng'): searxngList['tor'].append(item[:-1]) else: searxList['tor'].append(item[:-1]) - elif item[:-1].endswith('.i2p'): + elif re.search("https?:\/{2}(?:[a-zA-Z0-9]+\.)+i2p(?:\/[a-zA-Z0-9]+)*\/?", item[:-1]): if (rJson['instances'][item].get('generator') == 'searxng'): searxngList['i2p'].append(item[:-1]) else: @@ -367,9 +383,9 @@ def whoogle(): whoogleList['tor'] = [] whoogleList['i2p'] = [] for item in tmpList: - if item.endswith('.onion'): + if re.search("https?:\/{2}(?:[a-zA-Z0-9]+\.)+onion(?:\/[a-zA-Z0-9]+)*\/?", item): whoogleList['tor'].append(item) - elif item.endswith('.i2p'): + elif re.search("https?:\/{2}(?:[a-zA-Z0-9]+\.)+i2p(?:\/[a-zA-Z0-9]+)*\/?", item): whoogleList['i2p'].append(item) else: whoogleList['normal'].append(item) @@ -387,14 +403,13 @@ def librex(): tmp = re.findall( r"\| {1,2}\[(?:(?:[a-zA-Z0-9]+\.)+[a-zA-Z]{2,}|✅)\]\((https?:\/{2}(?:[a-zA-Z0-9]+\.)+[a-zA-Z0-9]{2,})", r.text) - tmp = filterLastSlash(tmp) for item in tmp: if item.strip() == "": continue - elif item.endswith('.onion'): + elif re.search("https?:\/{2}(?:[a-zA-Z0-9]+\.)+onion(?:\/[a-zA-Z0-9]+)*\/?", item): _list['tor'].append(item) - elif item.endswith('.i2p'): + elif re.search("https?:\/{2}(?:[a-zA-Z0-9]+\.)+i2p(?:\/[a-zA-Z0-9]+)*\/?", item): _list['i2p'].append(item) else: _list['normal'].append(item) @@ -421,6 +436,29 @@ def rimgo(): print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'Rimgo') +def librarian(): + r = requests.get( + 'https://codeberg.org/librarian/librarian/raw/branch/main/instances.json') + rJson = json.loads(r.text) + librarianList = {} + librarianList['normal'] = [] + librarianList['tor'] = [] + librarianList['i2p'] = [] + instances = rJson['instances'] + for item in instances: + url = item['url'] + if url.strip() == "": + continue + elif re.search("https?:\/{2}(?:[a-zA-Z0-9]+\.)+onion(?:\/[a-zA-Z0-9]+)*\/?", url): + librarianList['tor'].append(url) + elif re.search("https?:\/{2}(?:[a-zA-Z0-9]+\.)+i2p(?:\/[a-zA-Z0-9]+)*\/?", url): + librarianList['i2p'].append(url) + else: + librarianList['normal'].append(url) + mightyList['librarian'] = librarianList + print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'Librarian') + + def peertube(): r = requests.get( 'https://instances.joinpeertube.org/api/v1/instances?start=0&count=1045&sort=-createdAt') @@ -444,6 +482,7 @@ def isValid(url): # This code is contributed by avanitrachhadiya2155 invidious() piped() +pipedMaterial() proxitok() send() nitter() @@ -460,6 +499,7 @@ searx_searxng() whoogle() librex() rimgo() +librarian() mightyList = filterLastSlash(mightyList) cloudflare = [] diff --git a/src/pages/background/background.js b/src/pages/background/background.js index fd7b5dcf..293a2c84 100644 --- a/src/pages/background/background.js +++ b/src/pages/background/background.js @@ -259,3 +259,5 @@ browser.runtime.onMessage.addListener((message, sender, sendResponse) => { if (message.function === 'unify') utils.unify(false).then(r => sendResponse({ response: r })) return true; }); + +browser.storage.local.set({"version": browser.runtime.getManifest().version}) diff --git a/src/pages/options/index.html b/src/pages/options/index.html index 80c2a039..8eb3c21b 100644 --- a/src/pages/options/index.html +++ b/src/pages/options/index.html @@ -76,6 +76,21 @@ </select> </div> <div class="some-block option-block"> + <h4 data-localise="__MSG_protocol__"></h4> + <select id="protocol"> + <option value="normal" data-localise="__MSG_normal__">Normal</option> + <option value="tor">Tor</option> + <option value="i2p">I2P</option> + <option value="loki">Lokinet</option> + </select> + </div> + <div id="protocol-fallback"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_protocolFallback__">Fallback to normal if no frontends are available for the current protocol</h4> + <input id="protocol-fallback" type="checkbox"> + </div> + </div> + <div class="some-block option-block"> <h4 data-localise="__MSG_autoRedirect__"></h4> <input id="auto-redirect" type="checkbox"> </div> @@ -274,33 +289,23 @@ <option value="yatte">Yattee</option> </select> </div> - <div id="freetube-yatte"> + <div id="youtube-embedded_frontend"> <div class="some-block option-block"> <h4 data-localise="__MSG_embeddedVids__">Embedded Videos Frontend</h4> <select id="youtube-embed_frontend"> <option value="invidious">Invidious</option> <option value="piped">Piped</option> <option value="pipedMaterial">Piped-Material</option> - <option value="youtube">Youtube</option> </select> </div> </div> - <div id="invidious-piped-pipedMaterial"> - <div class="some-block option-block"> - <h4 data-localise="__MSG_protocol__">Protocol</h4> - <select id="youtube-protocol"> - <option value="normal" data-localise="__MSG_normal__">Normal</option> - <option value="tor" data-localise="__MSG_tor__">Tor</option> - </select> - </div> - <div class="some-block option-block"> - <h4 data-localise="__MSG_redirectType__">Redirect Type</h4> - <select id="youtube-redirect_type"> - <option value="both" data-localise="__MSG_both__">both</option> - <option value="onlyEmbedded" data-localise="__MSG_onlyEmbedded__">Only Embedded</option> - <option value="onlyNotEmbedded" data-localise="__MSG_onlyNotEmbedded__">Only Not Embedded</option> - </select> - </div> + <div class="some-block option-block"> + <h4 data-localise="__MSG_redirectType__">Redirect Type</h4> + <select id="youtube-redirect_type"> + <option value="both" data-localise="__MSG_both__">both</option> + <option value="onlyEmbedded" data-localise="__MSG_onlyEmbedded__">Only Embedded</option> + <option value="onlyNotEmbedded" data-localise="__MSG_onlyNotEmbedded__">Only Not Embedded</option> + </select> </div> <div id="invidious"> <hr> @@ -315,7 +320,7 @@ </div> <form class="custom-instance-form"> <div class="some-block option-block"> - <input class="custom-instance" placeholder="https://invidious.com" type="url"> + <input class="custom-instance" placeholder="http://invidious.com" type="url"> <button class="add add-instance" type="submit"> <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> @@ -345,7 +350,49 @@ </div> <form class="custom-instance-form"> <div class="some-block option-block"> - <input class="custom-instance" placeholder="https://invidious.onion" type="url"> + <input class="custom-instance" placeholder="http://invidious.onion" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> + <div class="i2p"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://invidious.i2p" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> + <div class="loki"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://invidious.loki" type="url"> <button class="add add-instance" type="submit"> <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> @@ -399,7 +446,49 @@ </div> <form class="custom-instance-form"> <div class="some-block option-block"> - <input class="custom-instance" placeholder="https://piped.onion" type="url"> + <input class="custom-instance" placeholder="http://piped.onion" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> + <div class="i2p"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://piped.i2p" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> + <div class="loki"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://piped.loki" type="url"> <button class="add add-instance" type="submit"> <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> @@ -453,7 +542,49 @@ </div> <form class="custom-instance-form"> <div class="some-block option-block"> - <input class="custom-instance" placeholder="https://piped-material.onion" type="url"> + <input class="custom-instance" placeholder="http://piped-material.onion" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> + <div class="i2p"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://piped-material.i2p" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> + <div class="loki"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://piped-material.loki" type="url"> <button class="add add-instance" type="submit"> <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> @@ -507,6 +638,69 @@ <input class="button button-inline" id="latency-beatbump" style="display:none;"> </div> </div> + <div class="tor"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://beatbump.onion" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> + <div class="i2p"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://beatbump.i2p" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> + <div class="loki"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://beatbump.loki" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> </div> <script type="module" src="./widgets/youtubeMusic.js"></script> </section> @@ -520,13 +714,6 @@ <input id="twitter-enable" type="checkbox"> </div> <div class="some-block option-block"> - <h4 data-localise="__MSG_protocol__">Protocol</h4> - <select id="twitter-protocol"> - <option value="normal" data-localise="__MSG_normal__">Normal</option> - <option value="tor" data-localise="__MSG_tor__">Tor</option> - </select> - </div> - <div class="some-block option-block"> <h4 data-localise="__MSG_redirectType__">Redirect Type</h4> <select id="twitter-redirect_type"> <option value="both" data-localise="__MSG_both__">both</option> @@ -577,7 +764,49 @@ </div> <form class="custom-instance-form"> <div class="some-block option-block"> - <input class="custom-instance" placeholder="https://nitter.onion" type="url"> + <input class="custom-instance" placeholder="http://nitter.onion" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> + <div class="i2p"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://nitter.i2p" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> + <div class="loki"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://nitter.loki" type="url"> <button class="add add-instance" type="submit"> <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> @@ -599,13 +828,6 @@ <h4 data-localise="__MSG_enable__">Enable</h4> <input id="instagram-enable" type="checkbox"> </div> - <div class="some-block option-block"> - <h4 data-localise="__MSG_protocol__">Protocol</h4> - <select id="instagram-protocol"> - <option value="normal" data-localise="__MSG_normal__">Normal</option> - <option value="tor" data-localise="__MSG_tor__">Tor</option> - </select> - </div> <div id="bibliogram"> <hr> <div class="normal"> @@ -659,6 +881,48 @@ </form> <div class="checklist custom-checklist"></div> </div> + <div class="i2p"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://bibliogram.onion" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> + <div class="loki"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://bibliogram.loki" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> </div> <script type="module" src="./widgets/instagram.js"></script> </section> @@ -671,13 +935,6 @@ <h4 data-localise="__MSG_enable__">Enable</h4> <input id="tiktok-enable" type="checkbox"> </div> - <div class="some-block option-block"> - <h4 data-localise="__MSG_protocol__">Protocol</h4> - <select id="tiktok-protocol"> - <option value="normal" data-localise="__MSG_normal__">Normal</option> - <option value="tor" data-localise="__MSG_tor__">Tor</option> - </select> - </div> <div id="proxiTok"> <hr> <div class="normal"> @@ -721,7 +978,49 @@ </div> <form class="custom-instance-form"> <div class="some-block option-block"> - <input class="custom-instance" placeholder="https://proxitok.onion" type="url"> + <input class="custom-instance" placeholder="http://proxitok.onion" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> + <div class="i2p"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://proxitok.i2p" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> + <div class="loki"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://proxitok.loki" type="url"> <button class="add add-instance" type="submit"> <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> @@ -750,13 +1049,6 @@ <option value="teddit">Teddit</option> </select> </div> - <div class="some-block option-block"> - <h4 data-localise="__MSG_protocol__">Protocol</h4> - <select id="reddit-protocol"> - <option value="normal" data-localise="__MSG_normal__">Normal</option> - <option value="tor" data-localise="__MSG_tor__">Tor</option> - </select> - </div> <div id="libreddit"> <hr> <div class="normal"> @@ -800,7 +1092,49 @@ </div> <form class="custom-instance-form"> <div class="some-block option-block"> - <input class="custom-instance" placeholder="https://libreddit.onion" type="url"> + <input class="custom-instance" placeholder="http://libreddit.onion" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> + <div class="i2p"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://libreddit.i2p" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> + <div class="loki"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://libreddit.loki" type="url"> <button class="add add-instance" type="submit"> <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> @@ -854,7 +1188,49 @@ </div> <form class="custom-instance-form"> <div class="some-block option-block"> - <input class="custom-instance" placeholder="https://teddit.onion" type="url"> + <input class="custom-instance" placeholder="http://teddit.onion" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> + <div class="i2p"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://teddit.i2p" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> + <div class="loki"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://teddit.loki" type="url"> <button class="add add-instance" type="submit"> <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> @@ -876,14 +1252,6 @@ <h4 data-localise="__MSG_enable__">Enable</h4> <input id="imgur-enable" type="checkbox"> </div> - <div class="some-block option-block"> - <h4 data-localise="__MSG_protocol__">Protocol</h4> - <select id="imgur-protocol"> - <option value="normal" data-localise="__MSG_normal__">Normal</option> - <option value="tor" data-localise="__MSG_tor__">Tor</option> - <option value="i2p" data-localise="__MSG_i2p__">I2P</option> - </select> - </div> <div id="rimgo"> <hr> <div class="normal"> @@ -927,7 +1295,7 @@ </div> <form class="custom-instance-form"> <div class="some-block option-block"> - <input class="custom-instance" placeholder="https://rimgo.onion" type="url"> + <input class="custom-instance" placeholder="http://rimgo.onion" type="url"> <button class="add add-instance" type="submit"> <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> @@ -948,7 +1316,28 @@ </div> <form class="custom-instance-form"> <div class="some-block option-block"> - <input class="custom-instance" placeholder="https://rimgo.onion" type="url"> + <input class="custom-instance" placeholder="http://rimgo.onion" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> + <div class="loki"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://rimgo.loki" type="url"> <button class="add add-instance" type="submit"> <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> @@ -970,14 +1359,6 @@ <h4 data-localise="__MSG_enable__">Enable</h4> <input id="wikipedia-enable" type="checkbox"> </div> - <div class="some-block option-block"> - <h4 data-localise="__MSG_protocol__">Protocol</h4> - <select id="wikipedia-protocol"> - <option value="normal" data-localise="__MSG_normal__">Normal</option> - <option value="tor" data-localise="__MSG_tor__">Tor</option> - <option value="i2p" data-localise="__MSG_i2p__">I2P</option> - </select> - </div> <div id="wikiless"> <hr> <div class="normal"> @@ -1021,7 +1402,7 @@ </div> <form class="custom-instance-form"> <div class="some-block option-block"> - <input class="custom-instance" placeholder="https://wikiless.onion" type="url"> + <input class="custom-instance" placeholder="http://wikiless.onion" type="url"> <button class="add add-instance" type="submit"> <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> @@ -1052,6 +1433,27 @@ </form> <div class="checklist custom-checklist"></div> </div> + <div class="loki"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://wikiless.loki" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> </div> <script type="module" src="./widgets/wikipedia.js"></script> </section> @@ -1064,13 +1466,6 @@ <h4 data-localise="__MSG_enable__">Enable</h4> <input id="medium-enable" type="checkbox"> </div> - <div class="some-block option-block"> - <h4 data-localise="__MSG_protocol__">Protocol</h4> - <select id="medium-protocol"> - <option value="normal" data-localise="__MSG_normal__">Normal</option> - <option value="tor" data-localise="__MSG_tor__">Tor</option> - </select> - </div> <div id="scribe"> <hr> <div class="normal"> @@ -1114,7 +1509,49 @@ </div> <form class="custom-instance-form"> <div class="some-block option-block"> - <input class="custom-instance" placeholder="https://scribe.onion" type="url"> + <input class="custom-instance" placeholder="http://scribe.onion" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> + <div class="i2p"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://scribe.i2p" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> + <div class="loki"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://scribe.loki" type="url"> <button class="add add-instance" type="submit"> <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> @@ -1136,13 +1573,6 @@ <h4 data-localise="__MSG_enable__">Enable</h4> <input id="quora-enable" type="checkbox"> </div> - <div class="some-block option-block"> - <h4 data-localise="__MSG_protocol__">Protocol</h4> - <select id="quora-protocol"> - <option value="normal" data-localise="__MSG_normal__">Normal</option> - <option value="tor" data-localise="__MSG_tor__">Tor</option> - </select> - </div> <div id="quetre"> <hr> <div class="normal"> @@ -1186,7 +1616,49 @@ </div> <form class="custom-instance-form"> <div class="some-block option-block"> - <input class="custom-instance" placeholder="https://quetre.onion" type="url"> + <input class="custom-instance" placeholder="http://quetre.onion" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> + <div class="i2p"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://quetre.i2p" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> + <div class="loki"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://quetre.loki" type="url"> <button class="add add-instance" type="submit"> <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> @@ -1208,13 +1680,6 @@ <h4 data-localise="__MSG_enable__">Enable</h4> <input id="imdb-enable" type="checkbox"> </div> - <div class="some-block option-block"> - <h4 data-localise="__MSG_protocol__">Protocol</h4> - <select id="imdb-protocol"> - <option value="normal" data-localise="__MSG_normal__">Normal</option> - <option value="tor" data-localise="__MSG_tor__">Tor</option> - </select> - </div> <div id="libremdb"> <hr> <div class="normal"> @@ -1258,7 +1723,49 @@ </div> <form class="custom-instance-form"> <div class="some-block option-block"> - <input class="custom-instance" placeholder="https://libremdb.onion" type="url"> + <input class="custom-instance" placeholder="http://libremdb.onion" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> + <div class="i2p"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://libremdb.i2p" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> + <div class="loki"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://libremdb.loki" type="url"> <button class="add add-instance" type="submit"> <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> @@ -1280,13 +1787,6 @@ <h4 data-localise="__MSG_enable__">Enable</h4> <input id="reuters-enable" type="checkbox"> </div> - <div class="some-block option-block"> - <h4 data-localise="__MSG_protocol__">Protocol</h4> - <select id="reuters-protocol"> - <option value="normal" data-localise="__MSG_normal__">Normal</option> - <option value="tor" data-localise="__MSG_tor__">Tor</option> - </select> - </div> <div id="neuters"> <hr> <div class="normal"> @@ -1330,7 +1830,49 @@ </div> <form class="custom-instance-form"> <div class="some-block option-block"> - <input class="custom-instance" placeholder="https://neuters.onion" type="url"> + <input class="custom-instance" placeholder="http://neuters.onion" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> + <div class="i2p"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://neuters.i2p" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> + <div class="loki"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://neuters.loki" type="url"> <button class="add add-instance" type="submit"> <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> @@ -1352,13 +1894,6 @@ <h4 data-localise="__MSG_enable__">Enable</h4> <input id="peertube-enable" type="checkbox"> </div> - <div class="some-block option-block"> - <h4 data-localise="__MSG_protocol__">Protocol</h4> - <select id="peertube-protocol"> - <option value="normal" data-localise="__MSG_normal__">Normal</option> - <option value="tor" data-localise="__MSG_tor__">Tor</option> - </select> - </div> <div id="simpleertube"> <hr> <div class="normal"> @@ -1402,7 +1937,49 @@ </div> <form class="custom-instance-form"> <div class="some-block option-block"> - <input class="custom-instance" placeholder="https://simpleertube.onion" type="url"> + <input class="custom-instance" placeholder="http://simpleertube.onion" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> + <div class="i2p"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://simpleertube.i2p" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> + <div class="loki"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://simpleertube.loki" type="url"> <button class="add add-instance" type="submit"> <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> @@ -1424,13 +2001,6 @@ <h4 data-localise="__MSG_enable__">Enable</h4> <input id="lbry-enable" type="checkbox"> </div> - <div class="some-block option-block"> - <h4 data-localise="__MSG_protocol__">Protocol</h4> - <select id="lbry-protocol"> - <option value="normal" data-localise="__MSG_normal__">Normal</option> - <option value="tor" data-localise="__MSG_tor__">Tor</option> - </select> - </div> <div id="librarian"> <hr> <div class="normal"> @@ -1484,6 +2054,48 @@ </form> <div class="checklist custom-checklist"></div> </div> + <div class="i2p"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://librarian.onion" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> + <div class="loki"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://librarian.loki" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> </div> <script type="module" src="./widgets/lbry.js"></script> </section> @@ -1505,14 +2117,6 @@ <option value="librex">LibreX</option> </select> </div> - <div class="some-block option-block"> - <h4 data-localise="__MSG_protocol__">Protocol</h4> - <select id="search-protocol"> - <option value="normal" data-localise="__MSG_normal__">Normal</option> - <option value="tor" data-localise="__MSG_tor__">Tor</option> - <option value="i2p" data-localise="__MSG_i2p__">I2P</option> - </select> - </div> <div class="some-block"> <h4 data-localise="__MSG_searchNote__">Note: To use Search, make LibRedirect the Default Search Engine</h4> </div> @@ -1590,6 +2194,27 @@ </form> <div class="checklist custom-checklist"></div> </div> + <div class="loki"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://searx.loki" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> </div> <div id="searxng"> <hr> @@ -1665,6 +2290,27 @@ </form> <div class="checklist custom-checklist"></div> </div> + <div class="loki"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://searxng.loki" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> </div> <div id="whoogle"> <hr> @@ -1740,6 +2386,27 @@ </form> <div class="checklist custom-checklist"></div> </div> + <div class="loki"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://whoogle.loki" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> </div> <div id="librex"> <hr> @@ -1815,6 +2482,27 @@ </form> <div class="checklist custom-checklist"></div> </div> + <div class="loki"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://librex.loki" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> </div> <script type="module" src="./widgets/search.js"></script> </section> @@ -1834,15 +2522,6 @@ <option value="lingva">Lingva</option> </select> </div> - <div class="some-block option-block"> - <h4 data-localise="__MSG_protocol__">Protocol</h4> - <select id="translate-protocol"> - <option value="normal" data-localise="__MSG_normal__">Normal</option> - <option value="tor" data-localise="__MSG_tor__">Tor</option> - <option value="i2p" data-localise="__MSG_i2p__">I2P</option> - <option value="loki" data-localise="__MSG_loki__">Lokinet</option> - </select> - </div> <hr> <div id="simplyTranslate"> <div class="normal"> @@ -1981,7 +2660,49 @@ </div> <form class="custom-instance-form"> <div class="some-block option-block"> - <input class="custom-instance" placeholder="http://tyzxppdeoojdnaux.onion" type="url"> + <input class="custom-instance" placeholder="http://lingvatranslate.onion" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> + <div class="i2p"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://lingvatranslate.i2p" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> + <div class="loki"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://lingvatranslate.loki" type="url"> <button class="add add-instance" type="submit"> <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> @@ -2042,6 +2763,69 @@ <input class="button button-inline" id="latency-facilmap" style="display:none;"> </div> </div> + <div class="tor"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://facilmap.onion" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> + <div class="i2p"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://facilmap.i2p" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> + <div class="loki"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://facilmap.loki" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> </div> <script type="module" src="./widgets/maps.js"></script> </section> @@ -2054,13 +2838,6 @@ <h4 data-localise="__MSG_enable__">Enable</h4> <input id="sendTargets-enable" type="checkbox"> </div> - <div class="some-block option-block"> - <h4 data-localise="__MSG_protocol__">Protocol</h4> - <select id="sendTargets-protocol"> - <option value="normal" data-localise="__MSG_normal__">Normal</option> - <option value="tor" data-localise="__MSG_tor__">Tor</option> - </select> - </div> <div id="send"> <hr> <div class="normal"> @@ -2104,7 +2881,49 @@ </div> <form class="custom-instance-form"> <div class="some-block option-block"> - <input class="custom-instance" placeholder="https://send.onion" type="url"> + <input class="custom-instance" placeholder="http://send.onion" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> + <div class="i2p"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://send.i2p" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> + <div class="loki"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://send.loki" type="url"> <button class="add add-instance" type="submit"> <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> diff --git a/src/pages/options/widgets/general.js b/src/pages/options/widgets/general.js index c0faf410..106bd532 100644 --- a/src/pages/options/widgets/general.js +++ b/src/pages/options/widgets/general.js @@ -151,9 +151,9 @@ resetSettings.addEventListener("click", ); let autoRedirectElement = document.getElementById("auto-redirect") -autoRedirectElement.addEventListener("change", - event => browser.storage.local.set({ autoRedirect: event.target.checked }) -); +autoRedirectElement.addEventListener("change", event => { + browser.storage.local.set({ autoRedirect: event.target.checked }) +}); let themeElement = document.getElementById("theme"); themeElement.addEventListener("change", event => { @@ -162,6 +162,18 @@ themeElement.addEventListener("change", event => { location.reload(); }) +let protocolElement = document.getElementById("protocol"); +protocolElement.addEventListener("change", event => { + const value = event.target.options[protocol.selectedIndex].value; + browser.storage.local.set({ protocol: value }); + location.reload(); +}) + +let protocolFallbackElement = document.getElementById("protocol-fallback") +protocolFallbackElement.addEventListener("change", event => { + browser.storage.local.set({ protocolFallback: event.target.checked}); +}) + let nameCustomInstanceInput = document.getElementById("exceptions-custom-instance"); let instanceTypeElement = document.getElementById("exceptions-custom-instance-type"); let instanceType = "url" @@ -188,12 +200,23 @@ browser.storage.local.get( 'theme', 'autoRedirect', 'exceptions', + 'protocol', + 'protocolFallback' // 'firstPartyIsolate' ], r => { autoRedirectElement.checked = r.autoRedirect; themeElement.value = r.theme; + protocolElement.value = r.protocol; + protocolFallbackElement.checked = r.protocolFallback; // firstPartyIsolate.checked = r.firstPartyIsolate; + + if (protocolElement.value == "normal") { + protocolFallbackElement.style.display = 'none'; + } else { + protocolFallbackElement.style.display = 'block'; + } + instanceTypeElement.addEventListener("change", event => { diff --git a/src/pages/options/widgets/general.pug b/src/pages/options/widgets/general.pug index 920d2b54..e6e80afb 100644 --- a/src/pages/options/widgets/general.pug +++ b/src/pages/options/widgets/general.pug @@ -15,6 +15,19 @@ section#general_page.option-block input#firstPartyIsolate(type="checkbox") .some-block.option-block + h4(data-localise="__MSG_protocol__") + select#protocol + option(value="normal" data-localise="__MSG_normal__") Normal + option(value="tor") Tor + option(value="i2p") I2P + option(value="loki") Lokinet + + #protocol-fallback + .some-block.option-block + h4(data-localise="__MSG_protocolFallback__") Fallback to normal if no frontends are available for the current protocol + input#protocol-fallback(type="checkbox") + + .some-block.option-block h4(data-localise="__MSG_autoRedirect__") input#auto-redirect(type="checkbox") @@ -188,4 +201,4 @@ section#general_page.option-block input#sendTargets(type="checkbox") - script(type="module" src="./widgets/general.js") \ No newline at end of file + script(type="module" src="./widgets/general.js") diff --git a/src/pages/options/widgets/imdb.js b/src/pages/options/widgets/imdb.js index f2c6cba5..ad115e93 100644 --- a/src/pages/options/widgets/imdb.js +++ b/src/pages/options/widgets/imdb.js @@ -1,42 +1,61 @@ import utils from "../../../assets/javascripts/utils.js"; +// UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST + +const frontends = new Array("libremdb") +const protocols = new Array("normal", "tor", "i2p", "loki") + const enable = document.getElementById("imdb-enable"); -const protocol = document.getElementById("imdb-protocol") const imdb = document.getElementById('imdb_page'); +//const frontend = document.getElementById("imdb-frontend"); +let protocol -function changeProtocolSettings() { - const normalDiv = imdb.getElementsByClassName("normal")[0]; - const torDiv = imdb.getElementsByClassName("tor")[0]; - if (protocol.value == 'normal') { - normalDiv.style.display = 'block'; - torDiv.style.display = 'none'; - } - else if (protocol.value == 'tor') { - normalDiv.style.display = 'none'; - torDiv.style.display = 'block'; +/* +function changeFrontendsSettings() { + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + if (frontends[i] == frontend.value) { + frontendDiv.style.display = 'block' + } else { + frontendDiv.style.display = 'none' + } } } +*/ -imdb.addEventListener("change", () => { - changeProtocolSettings(); - browser.storage.local.set({ - disableImdb: !enable.checked, - imdbProtocol: protocol.value, - }) -}) +function changeProtocolSettings() { + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + for (let x = 0; x < protocols.length; x++) { + const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] + if (protocols[x] == protocol) { + protocolDiv.style.display = 'block' + } else { + protocolDiv.style.display = 'none' + } + } + } +} browser.storage.local.get( [ "disableImdb", - "imdbProtocol" + "protocol" ], r => { enable.checked = !r.disableImdb; - protocol.value = r.imdbProtocol; + protocol = r.protocol; changeProtocolSettings(); } ) -utils.processDefaultCustomInstances('imdb', 'libremdb', 'normal', document); -utils.processDefaultCustomInstances('imdb', 'libremdb', 'tor', document); -utils.latency('imdb', 'libremdb', document, location) \ No newline at end of file +imdb.addEventListener("change", () => { + browser.storage.local.set({ disableImdb: !enable.checked }) +}) + +for (let i = 0; i < frontends.length; i++) { + for (let x = 0; x < protocols.length; x++){ + utils.processDefaultCustomInstances('imdb', frontends[i], protocols[x], document) + } + utils.latency('imdb', frontends[i], document, location) +} diff --git a/src/pages/options/widgets/imdb.pug b/src/pages/options/widgets/imdb.pug index 07749144..008e1c00 100644 --- a/src/pages/options/widgets/imdb.pug +++ b/src/pages/options/widgets/imdb.pug @@ -6,12 +6,6 @@ section#imdb_page.option-block h4(data-localise="__MSG_enable__") Enable input#imdb-enable(type="checkbox") - .some-block.option-block - h4(data-localise="__MSG_protocol__") Protocol - select#imdb-protocol - option(value="normal" data-localise="__MSG_normal__") Normal - option(value="tor" data-localise="__MSG_tor__") Tor - #libremdb hr .normal @@ -21,6 +15,12 @@ section#imdb_page.option-block +latency('libremdb') .tor include ../../widgets/instances.pug - +instances('https://libremdb.onion') + +instances('http://libremdb.onion') + .i2p + include ../../widgets/instances.pug + +instances('http://libremdb.i2p') + .loki + include ../../widgets/instances.pug + +instances('http://libremdb.loki') - script(type="module" src="./widgets/imdb.js") \ No newline at end of file + script(type="module" src="./widgets/imdb.js") diff --git a/src/pages/options/widgets/imgur.js b/src/pages/options/widgets/imgur.js index ffb28405..475bf472 100644 --- a/src/pages/options/widgets/imgur.js +++ b/src/pages/options/widgets/imgur.js @@ -1,53 +1,61 @@ import utils from "../../../assets/javascripts/utils.js"; +// UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST + +const frontends = new Array("rimgo") +const protocols = new Array("normal", "tor", "i2p", "loki") + const enable = document.getElementById("imgur-enable"); -const protocol = document.getElementById("imgur-protocol") const imgur = document.getElementById('imgur_page'); +//const frontend = document.getElementById("imgur-frontend"); +let protocol -const normalDiv = imgur.getElementsByClassName("normal")[0]; -const torDiv = imgur.getElementsByClassName("tor")[0]; -const i2pDiv = imgur.getElementsByClassName("i2p")[0]; +/* +function changeFrontendsSettings() { + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + if (frontends[i] == frontend.value) { + frontendDiv.style.display = 'block' + } else { + frontendDiv.style.display = 'none' + } + } +} +*/ function changeProtocolSettings() { - if (protocol.value == 'normal') { - normalDiv.style.display = 'block'; - torDiv.style.display = 'none'; - i2pDiv.style.display = 'none'; - } - else if (protocol.value == 'tor') { - normalDiv.style.display = 'none'; - torDiv.style.display = 'block'; - i2pDiv.style.display = 'none'; - } - else if (protocol.value == 'i2p') { - normalDiv.style.display = 'none'; - torDiv.style.display = 'none'; - i2pDiv.style.display = 'block'; + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + for (let x = 0; x < protocols.length; x++) { + const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] + if (protocols[x] == protocol) { + protocolDiv.style.display = 'block' + } else { + protocolDiv.style.display = 'none' + } + } } } browser.storage.local.get( [ "disableImgur", - "imgurProtocol", + "protocol" ], r => { enable.checked = !r.disableImgur; - protocol.value = r.imgurProtocol; + protocol = r.protocol; changeProtocolSettings(); } ); imgur.addEventListener("change", () => { - changeProtocolSettings(); - browser.storage.local.set({ - disableImgur: !enable.checked, - imgurProtocol: protocol.value, - }); + browser.storage.local.set({ disableImgur: !enable.checked }); }) -utils.processDefaultCustomInstances('imgur', 'rimgo', 'normal', document); -utils.processDefaultCustomInstances('imgur', 'rimgo', 'tor', document); -utils.processDefaultCustomInstances('imgur', 'rimgo', 'i2p', document); - -utils.latency('imgur', 'rimgo', document, location) \ No newline at end of file +for (let i = 0; i < frontends.length; i++) { + for (let x = 0; x < protocols.length; x++){ + utils.processDefaultCustomInstances('imgur', frontends[i], protocols[x], document) + } + utils.latency('imgur', frontends[i], document, location) +} diff --git a/src/pages/options/widgets/imgur.pug b/src/pages/options/widgets/imgur.pug index 5e514341..eacd066e 100644 --- a/src/pages/options/widgets/imgur.pug +++ b/src/pages/options/widgets/imgur.pug @@ -7,13 +7,6 @@ section#imgur_page.option-block h4(data-localise="__MSG_enable__") Enable input#imgur-enable(type="checkbox") - .some-block.option-block - h4(data-localise="__MSG_protocol__") Protocol - select#imgur-protocol - option(value="normal" data-localise="__MSG_normal__") Normal - option(value="tor" data-localise="__MSG_tor__") Tor - option(value="i2p" data-localise="__MSG_i2p__") I2P - #rimgo hr .normal @@ -23,10 +16,12 @@ section#imgur_page.option-block +latency('rimgo') .tor include ../../widgets/instances.pug - +instances('https://rimgo.onion') - + +instances('http://rimgo.onion') .i2p include ../../widgets/instances.pug - +instances('https://rimgo.onion') + +instances('http://rimgo.onion') + .loki + include ../../widgets/instances.pug + +instances('http://rimgo.loki') - script(type="module" src="./widgets/imgur.js") \ No newline at end of file + script(type="module" src="./widgets/imgur.js") diff --git a/src/pages/options/widgets/instagram.js b/src/pages/options/widgets/instagram.js index 8bd1a101..84456845 100644 --- a/src/pages/options/widgets/instagram.js +++ b/src/pages/options/widgets/instagram.js @@ -1,45 +1,61 @@ import utils from "../../../assets/javascripts/utils.js"; -const enable = document.getElementById("instagram-enable"); -const protocol = document.getElementById("instagram-protocol"); +// UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST + +const frontends = new Array("bibliogram") +const protocols = new Array("normal", "tor", "i2p", "loki") +const enable = document.getElementById("instagram-enable"); const instagram = document.getElementById('instagram_page') -const normalDiv = instagram.getElementsByClassName("normal")[0]; -const torDiv = instagram.getElementsByClassName("tor")[0]; +//const frontend = document.getElementById("instagram-frontend"); +let protocol + +/* +function changeFrontendsSettings() { + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + if (frontends[i] == frontend.value) { + frontendDiv.style.display = 'block' + } else { + frontendDiv.style.display = 'none' + } + } +} +*/ function changeProtocolSettings() { - if (protocol.value == 'normal') { - normalDiv.style.display = 'block'; - torDiv.style.display = 'none'; - } - else if (protocol.value == 'tor') { - normalDiv.style.display = 'none'; - torDiv.style.display = 'block'; + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + for (let x = 0; x < protocols.length; x++) { + const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] + if (protocols[x] == protocol) { + protocolDiv.style.display = 'block' + } else { + protocolDiv.style.display = 'none' + } + } } } browser.storage.local.get( [ "disableInstagram", - "instagramProtocol" + "protocol" ], r => { enable.checked = !r.disableInstagram; - protocol.value = r.instagramProtocol; + protocol = r.protocol; changeProtocolSettings(); } ) instagram.addEventListener("change", () => { - changeProtocolSettings(); - browser.storage.local.set({ - disableInstagram: !enable.checked, - instagramProtocol: protocol.value, - }) + browser.storage.local.set({ disableInstagram: !enable.checked }) }) - -utils.processDefaultCustomInstances('instagram', 'bibliogram', 'normal', document); -utils.processDefaultCustomInstances('instagram', 'bibliogram', 'tor', document); - -utils.latency('instagram', 'bibliogram', document, location) \ No newline at end of file +for (let i = 0; i < frontends.length; i++) { + for (let x = 0; x < protocols.length; x++){ + utils.processDefaultCustomInstances('instagram', frontends[i], protocols[x], document) + } + utils.latency('instagram', frontends[i], document, location) +} diff --git a/src/pages/options/widgets/instagram.pug b/src/pages/options/widgets/instagram.pug index 47cfcdbc..cc72f787 100644 --- a/src/pages/options/widgets/instagram.pug +++ b/src/pages/options/widgets/instagram.pug @@ -7,12 +7,6 @@ section#instagram_page.option-block h4(data-localise="__MSG_enable__") Enable input#instagram-enable(type="checkbox") - .some-block.option-block - h4(data-localise="__MSG_protocol__") Protocol - select#instagram-protocol - option(value="normal" data-localise="__MSG_normal__") Normal - option(value="tor" data-localise="__MSG_tor__") Tor - #bibliogram hr .normal @@ -21,6 +15,13 @@ section#instagram_page.option-block include ../../widgets/latency.pug +latency('bibliogram') .tor + include ../../widgets/instances.pug +instances('https://bibliogram.onion') + .i2p + include ../../widgets/instances.pug + +instances('http://bibliogram.onion') + .loki + include ../../widgets/instances.pug + +instances('http://bibliogram.loki') - script(type="module" src="./widgets/instagram.js") \ No newline at end of file + script(type="module" src="./widgets/instagram.js") diff --git a/src/pages/options/widgets/lbry.js b/src/pages/options/widgets/lbry.js index 131aa566..645017ff 100644 --- a/src/pages/options/widgets/lbry.js +++ b/src/pages/options/widgets/lbry.js @@ -1,44 +1,61 @@ import utils from "../../../assets/javascripts/utils.js"; -const enable = document.getElementById("lbry-enable"); -const protocol = document.getElementById("lbry-protocol") +// UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST + +const frontends = new Array("librarian") +const protocols = new Array("normal", "tor", "i2p", "loki") +const enable = document.getElementById("lbry-enable"); const lbry = document.getElementById('lbry_page'); -const normalDiv = lbry.getElementsByClassName("normal")[0]; -const torDiv = lbry.getElementsByClassName("tor")[0]; +//const frontend = document.getElementById("lbry-frontend"); +let protocol -function changeProtocolSettings() { - if (protocol.value == 'normal') { - normalDiv.style.display = 'block'; - torDiv.style.display = 'none'; +/* +function changeFrontendsSettings() { + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + if (frontends[i] == frontend.value) { + frontendDiv.style.display = 'block' + } else { + frontendDiv.style.display = 'none' + } } - else if (protocol.value == 'tor') { - normalDiv.style.display = 'none'; - torDiv.style.display = 'block'; +} +*/ + +function changeProtocolSettings() { + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + for (let x = 0; x < protocols.length; x++) { + const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] + if (protocols[x] == protocol) { + protocolDiv.style.display = 'block' + } else { + protocolDiv.style.display = 'none' + } + } } } browser.storage.local.get( [ "disableLbryTargets", - "lbryTargetsProtocol" + "protocol" ], r => { enable.checked = !r.disableLbryTargets; - protocol.value = r.lbryTargetsProtocol; + protocol = r.protocol; changeProtocolSettings(); } ) lbry.addEventListener("change", () => { - changeProtocolSettings() - browser.storage.local.set({ - disableLbryTargets: !enable.checked, - lbryTargetsProtocol: protocol.value, - }); + browser.storage.local.set({ disableLbryTargets: !enable.checked }); }) -utils.processDefaultCustomInstances('lbryTargets', 'librarian', 'normal', document); -utils.processDefaultCustomInstances('lbryTargets', 'librarian', 'tor', document); - -utils.latency('lbryTargets', 'librarian', document, location) \ No newline at end of file +for (let i = 0; i < frontends.length; i++) { + for (let x = 0; x < protocols.length; x++){ + utils.processDefaultCustomInstances('lbryTargets', frontends[i], protocols[x], document) + } + utils.latency('lbryTargets', frontends[i], document, location) +} diff --git a/src/pages/options/widgets/lbry.pug b/src/pages/options/widgets/lbry.pug index 4e88d2bf..2bdccb5a 100644 --- a/src/pages/options/widgets/lbry.pug +++ b/src/pages/options/widgets/lbry.pug @@ -6,12 +6,6 @@ section#lbry_page.option-block h4(data-localise="__MSG_enable__") Enable input#lbry-enable(type="checkbox") - .some-block.option-block - h4(data-localise="__MSG_protocol__") Protocol - select#lbry-protocol - option(value="normal" data-localise="__MSG_normal__") Normal - option(value="tor" data-localise="__MSG_tor__") Tor - #librarian hr .normal @@ -22,5 +16,11 @@ section#lbry_page.option-block .tor include ../../widgets/instances.pug +instances('https://librarian.onion') + .i2p + include ../../widgets/instances.pug + +instances('http://librarian.onion') + .loki + include ../../widgets/instances.pug + +instances('http://librarian.loki') - script(type="module" src="./widgets/lbry.js") \ No newline at end of file + script(type="module" src="./widgets/lbry.js") diff --git a/src/pages/options/widgets/maps.js b/src/pages/options/widgets/maps.js index b9825fb0..9e4be6d3 100644 --- a/src/pages/options/widgets/maps.js +++ b/src/pages/options/widgets/maps.js @@ -1,34 +1,64 @@ import utils from "../../../assets/javascripts/utils.js"; +const frontends = new Array("facil") +const protocols = new Array("normal", "tor", "i2p", "loki") + const enable = document.getElementById("maps-enable"); +const maps = document.getElementById('maps_page'); const frontend = document.getElementById("maps-frontend"); +let protocol -const maps = document.getElementById('maps_page'); -const facilDiv = document.getElementById("facil") +function changeProtocolSettings() { + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + for (let x = 0; x < protocols.length; x++) { + const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] + if (protocols[x] == protocol) { + protocolDiv.style.display = 'block' + } else { + protocolDiv.style.display = 'none' + } + } + } +} function changeFrontendsSettings() { - if (frontend.value == 'facil') facilDiv.style.display = 'block'; - else if (frontend.value == 'osm') facilDiv.style.display = 'none'; + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + if (frontends[i] == frontend.value) { + frontendDiv.style.display = 'block' + } else { + frontendDiv.style.display = 'none' + } + } } browser.storage.local.get( [ "disableMaps", - "mapsFrontend", + "protocol", + "mapsFrontend" ], r => { enable.checked = !r.disableMaps; + protocol = r.protocol; frontend.value = r.mapsFrontend; changeFrontendsSettings(); + changeProtocolSettings(); } ) maps.addEventListener("change", () => { - changeFrontendsSettings(); browser.storage.local.set({ disableMaps: !enable.checked, - mapsFrontend: frontend.value, - }) + mapsFrontend: frontend.value + }); + changeFrontendsSettings(); }) -utils.processDefaultCustomInstances('maps', 'facil', 'normal', document); \ No newline at end of file +for (let i = 0; i < frontends.length; i++) { + for (let x = 0; x < protocols.length; x++) { + utils.processDefaultCustomInstances('maps', frontends[i], protocols[x], document) + } + utils.latency('maps', frontends[i], document, location) +} diff --git a/src/pages/options/widgets/maps.pug b/src/pages/options/widgets/maps.pug index 42c81d8e..f220e35e 100644 --- a/src/pages/options/widgets/maps.pug +++ b/src/pages/options/widgets/maps.pug @@ -19,5 +19,14 @@ section#maps_page.option-block +instances('https://facilmap.com') include ../../widgets/latency.pug +latency('facilmap') + .tor + +instances('http://facilmap.onion') + include ../../widgets/instances.pug + .i2p + include ../../widgets/instances.pug + +instances('http://facilmap.i2p') + .loki + include ../../widgets/instances.pug + +instances('http://facilmap.loki') - script(type="module" src="./widgets/maps.js") \ No newline at end of file + script(type="module" src="./widgets/maps.js") diff --git a/src/pages/options/widgets/medium.js b/src/pages/options/widgets/medium.js index ef5965be..765a956c 100644 --- a/src/pages/options/widgets/medium.js +++ b/src/pages/options/widgets/medium.js @@ -1,42 +1,61 @@ import utils from "../../../assets/javascripts/utils.js"; +// UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST + +const frontends = new Array("scribe") +const protocols = new Array("normal", "tor", "i2p", "loki") + const enable = document.getElementById("medium-enable"); -const protocol = document.getElementById("medium-protocol") const medium = document.getElementById('medium_page'); +//const frontend = document.getElementById("medium-frontend"); +let protocol -function changeProtocolSettings() { - const normalDiv = medium.getElementsByClassName("normal")[0]; - const torDiv = medium.getElementsByClassName("tor")[0]; - if (protocol.value == 'normal') { - normalDiv.style.display = 'block'; - torDiv.style.display = 'none'; - } - else if (protocol.value == 'tor') { - normalDiv.style.display = 'none'; - torDiv.style.display = 'block'; +/* +function changeFrontendsSettings() { + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + if (frontends[i] == frontend.value) { + frontendDiv.style.display = 'block' + } else { + frontendDiv.style.display = 'none' + } } } +*/ -medium.addEventListener("change", () => { - changeProtocolSettings(); - browser.storage.local.set({ - disableMedium: !enable.checked, - mediumProtocol: protocol.value, - }) -}) +function changeProtocolSettings() { + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + for (let x = 0; x < protocols.length; x++) { + const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] + if (protocols[x] == protocol) { + protocolDiv.style.display = 'block' + } else { + protocolDiv.style.display = 'none' + } + } + } +} browser.storage.local.get( [ "disableMedium", - "mediumProtocol" + "protocol" ], r => { enable.checked = !r.disableMedium; - protocol.value = r.mediumProtocol; + protocol = r.protocol; changeProtocolSettings(); } ) -utils.processDefaultCustomInstances('medium', 'scribe', 'normal', document); -utils.processDefaultCustomInstances('medium', 'scribe', 'tor', document); -utils.latency('medium', 'scribe', document, location) \ No newline at end of file +medium.addEventListener("change", () => { + browser.storage.local.set({ disableMedium: !enable.checked }) +}) + +for (let i = 0; i < frontends.length; i++) { + for (let x = 0; x < protocols.length; x++){ + utils.processDefaultCustomInstances('medium', frontends[i], protocols[x], document) + } + utils.latency('medium', frontends[i], document, location) +} diff --git a/src/pages/options/widgets/medium.pug b/src/pages/options/widgets/medium.pug index f0a1ad55..4eef0511 100644 --- a/src/pages/options/widgets/medium.pug +++ b/src/pages/options/widgets/medium.pug @@ -6,12 +6,6 @@ section#medium_page.option-block h4(data-localise="__MSG_enable__") Enable input#medium-enable(type="checkbox") - .some-block.option-block - h4(data-localise="__MSG_protocol__") Protocol - select#medium-protocol - option(value="normal" data-localise="__MSG_normal__") Normal - option(value="tor" data-localise="__MSG_tor__") Tor - #scribe hr .normal @@ -21,6 +15,12 @@ section#medium_page.option-block +latency('scribe') .tor include ../../widgets/instances.pug - +instances('https://scribe.onion') + +instances('http://scribe.onion') + .i2p + include ../../widgets/instances.pug + +instances('http://scribe.i2p') + .loki + include ../../widgets/instances.pug + +instances('http://scribe.loki') - script(type="module" src="./widgets/medium.js") \ No newline at end of file + script(type="module" src="./widgets/medium.js") diff --git a/src/pages/options/widgets/peertube.js b/src/pages/options/widgets/peertube.js index 01b4f6b5..9e994119 100644 --- a/src/pages/options/widgets/peertube.js +++ b/src/pages/options/widgets/peertube.js @@ -1,42 +1,61 @@ import utils from "../../../assets/javascripts/utils.js"; +// UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST + +const frontends = new Array("simpleertube") +const protocols = new Array("normal", "tor", "i2p", "loki") + const enable = document.getElementById("peertube-enable"); -const protocol = document.getElementById("peertube-protocol"); const peertube = document.getElementById('peertube_page'); +//const frontend = document.getElementById("peertube-frontend"); +let protocol -function changeProtocolSettings() { - const normalDiv = peertube.getElementsByClassName("normal")[0]; - const torDiv = peertube.getElementsByClassName("tor")[0]; - if (protocol.value == 'normal') { - normalDiv.style.display = 'block'; - torDiv.style.display = 'none'; +/* +function changeFrontendsSettings() { + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + if (frontends[i] == frontend.value) { + frontendDiv.style.display = 'block' + } else { + frontendDiv.style.display = 'none' + } } - else if (protocol.value == 'tor') { - normalDiv.style.display = 'none'; - torDiv.style.display = 'block'; +} +*/ + +function changeProtocolSettings() { + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + for (let x = 0; x < protocols.length; x++) { + const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] + if (protocols[x] == protocol) { + protocolDiv.style.display = 'block' + } else { + protocolDiv.style.display = 'none' + } + } } } browser.storage.local.get( [ "disablePeertubeTargets", - "peertubeTargetsProtocol" + "protocol" ], r => { enable.checked = !r.disablePeertubeTargets; - protocol.value = r.peertubeTargetsProtocol; + protocol = r.protocol; changeProtocolSettings(); } ) peertube.addEventListener("change", () => { - changeProtocolSettings(); - browser.storage.local.set({ - disablePeertubeTargets: !enable.checked, - peertubeTargetsProtocol: protocol.value - }) + browser.storage.local.set({ disablePeertubeTargets: !enable.checked }) }) -utils.processDefaultCustomInstances('peertube', 'simpleertube', 'normal', document); -utils.processDefaultCustomInstances('peertube', 'simpleertube', 'tor', document); -utils.latency('peertube', 'simpleertube', document, location) \ No newline at end of file +for (let i = 0; i < frontends.length; i++) { + for (let x = 0; x < protocols.length; x++){ + utils.processDefaultCustomInstances('peertube', frontends[i], protocols[x], document) + } + utils.latency('peertube', frontends[i], document, location) +} diff --git a/src/pages/options/widgets/peertube.pug b/src/pages/options/widgets/peertube.pug index 0beec59c..38690d04 100644 --- a/src/pages/options/widgets/peertube.pug +++ b/src/pages/options/widgets/peertube.pug @@ -6,12 +6,6 @@ section#peertube_page.option-block h4(data-localise="__MSG_enable__") Enable input#peertube-enable(type="checkbox") - .some-block.option-block - h4(data-localise="__MSG_protocol__") Protocol - select#peertube-protocol - option(value="normal" data-localise="__MSG_normal__") Normal - option(value="tor" data-localise="__MSG_tor__") Tor - #simpleertube hr .normal @@ -21,6 +15,12 @@ section#peertube_page.option-block +latency('simpleertube') .tor include ../../widgets/instances.pug - +instances('https://simpleertube.onion') + +instances('http://simpleertube.onion') + .i2p + include ../../widgets/instances.pug + +instances('http://simpleertube.i2p') + .loki + include ../../widgets/instances.pug + +instances('http://simpleertube.loki') - script(type="module" src="./widgets/peertube.js") \ No newline at end of file + script(type="module" src="./widgets/peertube.js") diff --git a/src/pages/options/widgets/quora.js b/src/pages/options/widgets/quora.js index dfa1b6aa..ded21e57 100644 --- a/src/pages/options/widgets/quora.js +++ b/src/pages/options/widgets/quora.js @@ -1,42 +1,61 @@ import utils from "../../../assets/javascripts/utils.js"; +// UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST + +const frontends = new Array("quetre") +const protocols = new Array("normal", "tor", "i2p", "loki") + const enable = document.getElementById("quora-enable"); -const protocol = document.getElementById("quora-protocol") const quora = document.getElementById('quora_page'); +//const frontend = document.getElementById("quora-frontend"); +let protocol -function changeProtocolSettings() { - const normalDiv = quora.getElementsByClassName("normal")[0]; - const torDiv = quora.getElementsByClassName("tor")[0]; - if (protocol.value == 'normal') { - normalDiv.style.display = 'block'; - torDiv.style.display = 'none'; - } - else if (protocol.value == 'tor') { - normalDiv.style.display = 'none'; - torDiv.style.display = 'block'; +/* +function changeFrontendsSettings() { + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + if (frontends[i] == frontend.value) { + frontendDiv.style.display = 'block' + } else { + frontendDiv.style.display = 'none' + } } } +*/ -quora.addEventListener("change", () => { - changeProtocolSettings(); - browser.storage.local.set({ - disableQuora: !enable.checked, - quoraProtocol: protocol.value, - }) -}) +function changeProtocolSettings() { + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + for (let x = 0; x < protocols.length; x++) { + const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] + if (protocols[x] == protocol) { + protocolDiv.style.display = 'block' + } else { + protocolDiv.style.display = 'none' + } + } + } +} browser.storage.local.get( [ "disableQuora", - "quoraProtocol" + "protocol" ], r => { enable.checked = !r.disableQuora; - protocol.value = r.quoraProtocol; + protocol = r.protocol; changeProtocolSettings(); } ) -utils.processDefaultCustomInstances('quora', 'quetre', 'normal', document); -utils.processDefaultCustomInstances('quora', 'quetre', 'tor', document); -utils.latency('quora', 'quetre', document, location) \ No newline at end of file +quora.addEventListener("change", () => { + browser.storage.local.set({ disableQuora: !enable.checked }) +}) + +for (let i = 0; i < frontends.length; i++) { + for (let x = 0; x < protocols.length; x++){ + utils.processDefaultCustomInstances('quora', frontends[i], protocols[x], document) + } + utils.latency('quora', frontends[i], document, location) +} diff --git a/src/pages/options/widgets/quora.pug b/src/pages/options/widgets/quora.pug index 8f5fe639..9e45abc9 100644 --- a/src/pages/options/widgets/quora.pug +++ b/src/pages/options/widgets/quora.pug @@ -6,12 +6,6 @@ section#quora_page.option-block h4(data-localise="__MSG_enable__") Enable input#quora-enable(type="checkbox") - .some-block.option-block - h4(data-localise="__MSG_protocol__") Protocol - select#quora-protocol - option(value="normal" data-localise="__MSG_normal__") Normal - option(value="tor" data-localise="__MSG_tor__") Tor - #quetre hr .normal @@ -21,6 +15,12 @@ section#quora_page.option-block +latency('quetre') .tor include ../../widgets/instances.pug - +instances('https://quetre.onion') + +instances('http://quetre.onion') + .i2p + include ../../widgets/instances.pug + +instances('http://quetre.i2p') + .loki + include ../../widgets/instances.pug + +instances('http://quetre.loki') - script(type="module" src="./widgets/quora.js") \ No newline at end of file + script(type="module" src="./widgets/quora.js") diff --git a/src/pages/options/widgets/reddit.js b/src/pages/options/widgets/reddit.js index 9e4dfedd..a32632d2 100644 --- a/src/pages/options/widgets/reddit.js +++ b/src/pages/options/widgets/reddit.js @@ -1,52 +1,47 @@ import utils from "../../../assets/javascripts/utils.js"; -const libredditDivElement = document.getElementById("libreddit") -const tedditDivElement = document.getElementById("teddit") +const frontends = new Array("libreddit", "teddit") +const protocols = new Array("normal", "tor", "i2p", "loki") const enable = document.getElementById("reddit-enable"); -const frontend = document.getElementById("reddit-frontend"); -const protocol = document.getElementById("reddit-protocol"); const reddit = document.getElementById('reddit_page'); +const frontend = document.getElementById("reddit-frontend"); +let protocol -function changeProtocolSettings() { - const normalLibredditDiv = libredditDivElement.getElementsByClassName("normal")[0]; - const torLibredditDiv = libredditDivElement.getElementsByClassName("tor")[0]; - const normalTedditDiv = tedditDivElement.getElementsByClassName("normal")[0]; - const torTedditDiv = tedditDivElement.getElementsByClassName("tor")[0]; - if (protocol.value == 'normal') { - normalLibredditDiv.style.display = 'block'; - normalTedditDiv.style.display = 'block'; - torTedditDiv.style.display = 'none'; - torLibredditDiv.style.display = 'none'; - } - else if (protocol.value == 'tor') { - normalLibredditDiv.style.display = 'none'; - normalTedditDiv.style.display = 'none'; - torTedditDiv.style.display = 'block'; - torLibredditDiv.style.display = 'block'; +function changeFrontendsSettings() { + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + if (frontends[i] == frontend.value) { + frontendDiv.style.display = 'block' + } else { + frontendDiv.style.display = 'none' + } } } -function changeFrontendsSettings() { - if (frontend.value == 'libreddit') { - libredditDivElement.style.display = 'block'; - tedditDivElement.style.display = 'none'; - } - else if (frontend.value == 'teddit') { - libredditDivElement.style.display = 'none'; - tedditDivElement.style.display = 'block'; +function changeProtocolSettings() { + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + for (let x = 0; x < protocols.length; x++) { + const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] + if (protocols[x] == protocol) { + protocolDiv.style.display = 'block' + } else { + protocolDiv.style.display = 'none' + } + } } } browser.storage.local.get( [ "disableReddit", - "redditProtocol", + "protocol", "redditFrontend", ], r => { enable.checked = !r.disableReddit - protocol.value = r.redditProtocol + protocol = r.protocol frontend.value = r.redditFrontend changeFrontendsSettings(); changeProtocolSettings(); @@ -56,17 +51,14 @@ browser.storage.local.get( reddit.addEventListener("change", () => { browser.storage.local.set({ disableReddit: !enable.checked, - redditProtocol: protocol.value, - redditFrontend: frontend.value, + redditFrontend: frontend.value }); changeFrontendsSettings(); - changeProtocolSettings(); }) -utils.processDefaultCustomInstances('reddit', 'libreddit', 'normal', document); -utils.processDefaultCustomInstances('reddit', 'libreddit', 'tor', document); -utils.processDefaultCustomInstances('reddit', 'teddit', 'normal', document); -utils.processDefaultCustomInstances('reddit', 'teddit', 'tor', document); - -utils.latency('reddit', 'libreddit', document, location, true) -utils.latency('reddit', 'teddit', document, location, true) \ No newline at end of file +for (let i = 0; i < frontends.length; i++) { + for (let x = 0; x < protocols.length; x++){ + utils.processDefaultCustomInstances('reddit', frontends[i], protocols[x], document) + } + utils.latency('reddit', frontends[i], document, location) +} diff --git a/src/pages/options/widgets/reddit.pug b/src/pages/options/widgets/reddit.pug index 74b8d82e..1726f9ce 100644 --- a/src/pages/options/widgets/reddit.pug +++ b/src/pages/options/widgets/reddit.pug @@ -12,12 +12,6 @@ section#reddit_page.option-block option(value="libreddit") Libreddit option(value="teddit") Teddit - .some-block.option-block - h4(data-localise="__MSG_protocol__") Protocol - select#reddit-protocol - option(value="normal" data-localise="__MSG_normal__") Normal - option(value="tor" data-localise="__MSG_tor__") Tor - #libreddit hr .normal @@ -27,7 +21,13 @@ section#reddit_page.option-block +latency('libreddit') .tor include ../../widgets/instances.pug - +instances('https://libreddit.onion') + +instances('http://libreddit.onion') + .i2p + include ../../widgets/instances.pug + +instances('http://libreddit.i2p') + .loki + include ../../widgets/instances.pug + +instances('http://libreddit.loki') #teddit hr @@ -37,6 +37,12 @@ section#reddit_page.option-block +latency('teddit') .tor include ../../widgets/instances.pug - +instances('https://teddit.onion') + +instances('http://teddit.onion') + .i2p + include ../../widgets/instances.pug + +instances('http://teddit.i2p') + .loki + include ../../widgets/instances.pug + +instances('http://teddit.loki') - script(type="module" src="./widgets/reddit.js") \ No newline at end of file + script(type="module" src="./widgets/reddit.js") diff --git a/src/pages/options/widgets/reuters.js b/src/pages/options/widgets/reuters.js index 08e8f988..297e3e70 100644 --- a/src/pages/options/widgets/reuters.js +++ b/src/pages/options/widgets/reuters.js @@ -1,43 +1,61 @@ import utils from "../../../assets/javascripts/utils.js"; +// UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST + +const frontends = new Array("neuters") +const protocols = new Array("normal", "tor", "i2p", "loki") + const enable = document.getElementById("reuters-enable"); -const protocol = document.getElementById("reuters-protocol") const reuters = document.getElementById('reuters_page'); +//const frontend = document.getElementById("reuters-frontend"); +let protocol -function changeProtocolSettings() { - const normalDiv = reuters.getElementsByClassName("normal")[0]; - const torDiv = reuters.getElementsByClassName("tor")[0]; - if (protocol.value == 'normal') { - - normalDiv.style.display = 'block'; - torDiv.style.display = 'none'; - } - else if (protocol.value == 'tor') { - normalDiv.style.display = 'none'; - torDiv.style.display = 'block'; +/* +function changeFrontendsSettings() { + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + if (frontends[i] == frontend.value) { + frontendDiv.style.display = 'block' + } else { + frontendDiv.style.display = 'none' + } } } +*/ -reuters.addEventListener("change", () => { - changeProtocolSettings(); - browser.storage.local.set({ - disableReuters: !enable.checked, - reutersProtocol: protocol.value, - }) -}) +function changeProtocolSettings() { + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + for (let x = 0; x < protocols.length; x++) { + const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] + if (protocols[x] == protocol) { + protocolDiv.style.display = 'block' + } else { + protocolDiv.style.display = 'none' + } + } + } +} browser.storage.local.get( [ "disableReuters", - "reutersProtocol" + "protocol" ], r => { enable.checked = !r.disableReuters; - protocol.value = r.reutersProtocol; + protocol = r.protocol; changeProtocolSettings(); } ) -utils.processDefaultCustomInstances('reuters', 'neuters', 'normal', document); -utils.processDefaultCustomInstances('reuters', 'neuters', 'tor', document); -utils.latency('reuters', 'neuters', document, location) \ No newline at end of file +reuters.addEventListener("change", () => { + browser.storage.local.set({ disableReuters: !enable.checked }) +}) + +for (let i = 0; i < frontends.length; i++) { + for (let x = 0; x < protocols.length; x++){ + utils.processDefaultCustomInstances('reuters', frontends[i], protocols[x], document) + } + utils.latency('reuters', frontends[i], document, location) +} diff --git a/src/pages/options/widgets/reuters.pug b/src/pages/options/widgets/reuters.pug index c1a1ee43..08a37d50 100644 --- a/src/pages/options/widgets/reuters.pug +++ b/src/pages/options/widgets/reuters.pug @@ -6,12 +6,6 @@ section#reuters_page.option-block h4(data-localise="__MSG_enable__") Enable input#reuters-enable(type="checkbox") - .some-block.option-block - h4(data-localise="__MSG_protocol__") Protocol - select#reuters-protocol - option(value="normal" data-localise="__MSG_normal__") Normal - option(value="tor" data-localise="__MSG_tor__") Tor - #neuters hr .normal @@ -21,6 +15,12 @@ section#reuters_page.option-block +latency('neuters') .tor include ../../widgets/instances.pug - +instances('https://neuters.onion') + +instances('http://neuters.onion') + .i2p + include ../../widgets/instances.pug + +instances('http://neuters.i2p') + .loki + include ../../widgets/instances.pug + +instances('http://neuters.loki') - script(type="module" src="./widgets/reuters.js") \ No newline at end of file + script(type="module" src="./widgets/reuters.js") diff --git a/src/pages/options/widgets/search.js b/src/pages/options/widgets/search.js index 0af37343..7cadf143 100644 --- a/src/pages/options/widgets/search.js +++ b/src/pages/options/widgets/search.js @@ -5,7 +5,7 @@ import utils from "../../../assets/javascripts/utils.js"; // ONCE FINISHED: add librex and see if it works const frontends = new Array("searx", "searxng", "whoogle", "librex") // Add librex once /javascripts/search.js is made agnostic -const protocols = new Array("normal", "tor", "i2p") +const protocols = new Array("normal", "tor", "i2p", "loki") //let frontendProtocols = (frontends.length) // I will leave comments of my privious attemps so that people can learn from my mistakes. :) @@ -36,11 +36,9 @@ const whoogleDiv = document.getElementById("whoogle"); */ const enable = document.getElementById("search-enable"); -const frontend = document.getElementById("search-frontend"); -const protocol = document.getElementById("search-protocol"); - const search = document.getElementById('search_page'); - +const frontend = document.getElementById("search-frontend"); +let protocol function changeFrontendsSettings() { for (let i = 0; i < frontends.length; i++) { @@ -88,18 +86,20 @@ function changeProtocolSettings() { for (let i = 0; i < frontends.length; i++) { const frontendDiv = document.getElementById(frontends[i]) - if (frontends[i] == frontend.value) { // Here we are checking if the frontend matches the current one. This skips the protocol checking for that frontend, speeding things up. + //if (frontends[i] == frontend.value) { // Here we are checking if the frontend matches the current one. This skips the protocol checking for that frontend, speeding things up. I no longer do this as protocol setting is only set once in the ui so every frontend needs to get their protocols setup immidiately. for (let x = 0; x < protocols.length; x++) { const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] - if (protocols[x] == protocol.value) { //if the frontend value equals the selected one, it will show. Otherwise, it will be hidden + if (protocols[x] == protocol) { //if the frontend value equals the selected one, it will show. Otherwise, it will be hidden protocolDiv.style.display = 'block' } else { protocolDiv.style.display = 'none' } } + /* } else { continue } + */ } @@ -172,12 +172,12 @@ browser.storage.local.get( [ "disableSearch", "searchFrontend", - "searchProtocol", + "protocol", ], r => { enable.checked = !r.disableSearch; frontend.value = r.searchFrontend; - protocol.value = r.searchProtocol; + protocol = r.protocol; changeFrontendsSettings(); changeProtocolSettings(); @@ -188,17 +188,15 @@ for (let i = 0; i < frontends.length; i++) { for (let x = 0; x < protocols.length; x++){ utils.processDefaultCustomInstances('search', frontends[i], protocols[x], document) } - utils.latency('search', frontends[i], document, location, true) + utils.latency('search', frontends[i], document, location) } search.addEventListener("change", () => { browser.storage.local.set({ disableSearch: !enable.checked, searchFrontend: frontend.value, - searchProtocol: protocol.value, }); - changeFrontendsSettings(frontend.value); - changeProtocolSettings(protocol.value); + changeFrontendsSettings(); }) /* diff --git a/src/pages/options/widgets/search.pug b/src/pages/options/widgets/search.pug index ec075f79..8f23350e 100644 --- a/src/pages/options/widgets/search.pug +++ b/src/pages/options/widgets/search.pug @@ -1,4 +1,3 @@ - section#search_page.option-block .some-block.option-block h1(data-localise="__MSG_search__") Search @@ -15,13 +14,6 @@ section#search_page.option-block option(value="whoogle") Whoogle option(value="librex") LibreX - .some-block.option-block - h4(data-localise="__MSG_protocol__") Protocol - select#search-protocol - option(value="normal" data-localise="__MSG_normal__") Normal - option(value="tor" data-localise="__MSG_tor__") Tor - option(value="i2p" data-localise="__MSG_i2p__") I2P - .some-block h4(data-localise="__MSG_searchNote__") Note: To use Search, make LibRedirect the Default Search Engine @@ -38,6 +30,9 @@ section#search_page.option-block .i2p include ../../widgets/instances.pug +instances('http://searx.i2p') + .loki + include ../../widgets/instances.pug + +instances('http://searx.loki') #searxng hr @@ -51,6 +46,9 @@ section#search_page.option-block .i2p include ../../widgets/instances.pug +instances('http://searxng.i2p') + .loki + include ../../widgets/instances.pug + +instances('http://searxng.loki') #whoogle hr @@ -64,6 +62,9 @@ section#search_page.option-block .i2p include ../../widgets/instances.pug +instances('http://whoogle.i2p') + .loki + include ../../widgets/instances.pug + +instances('http://whoogle.loki') #librex hr @@ -77,5 +78,8 @@ section#search_page.option-block .i2p include ../../widgets/instances.pug +instances('http://librex.i2p') + .loki + include ../../widgets/instances.pug + +instances('http://librex.loki') script(type="module" src="./widgets/search.js") diff --git a/src/pages/options/widgets/sendTargets.js b/src/pages/options/widgets/sendTargets.js index 1cb1e74e..27c90d4e 100644 --- a/src/pages/options/widgets/sendTargets.js +++ b/src/pages/options/widgets/sendTargets.js @@ -1,43 +1,61 @@ import utils from "../../../assets/javascripts/utils.js"; +// UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST + +const frontends = new Array("send") +const protocols = new Array("normal", "tor", "i2p", "loki") + const enable = document.getElementById("sendTargets-enable"); -const protocol = document.getElementById("sendTargets-protocol") const sendTargets = document.getElementById('sendTargets_page'); +//const frontend = document.getElementById("sendTargets-frontend"); +let protocol -function changeProtocolSettings() { - let normalDiv = sendTargets.getElementsByClassName("normal")[0]; - let torDiv = sendTargets.getElementsByClassName("tor")[0]; - if (protocol.value == 'normal') { - normalDiv.style.display = 'block'; - torDiv.style.display = 'none'; +/* +function changeFrontendsSettings() { + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + if (frontends[i] == frontend.value) { + frontendDiv.style.display = 'block' + } else { + frontendDiv.style.display = 'none' + } } - else if (protocol.value == 'tor') { - normalDiv.style.display = 'none'; - torDiv.style.display = 'block'; +} +*/ + +function changeProtocolSettings() { + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + for (let x = 0; x < protocols.length; x++) { + const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] + if (protocols[x] == protocol) { + protocolDiv.style.display = 'block' + } else { + protocolDiv.style.display = 'none' + } + } } } browser.storage.local.get( [ "disableSendTarget", - "sendTargetsProtocol", + "protocol" ], r => { enable.checked = !r.disableSendTarget; - protocol.value = r.sendTargetsProtocol; + protocol = r.protocol; changeProtocolSettings(); } ) sendTargets.addEventListener("change", () => { - changeProtocolSettings(); - browser.storage.local.set({ - disableSendTarget: !enable.checked, - sendTargetsProtocol: protocol.value, - }) + browser.storage.local.set({ disableSendTarget: !enable.checked }) }) -utils.processDefaultCustomInstances('sendTargets', 'send', 'normal', document); -utils.processDefaultCustomInstances('sendTargets', 'send', 'tor', document); - -utils.latency('sendTargets', 'send', document, location) \ No newline at end of file +for (let i = 0; i < frontends.length; i++) { + for (let x = 0; x < protocols.length; x++){ + utils.processDefaultCustomInstances('sendTargets', frontends[i], protocols[x], document) + } + utils.latency('sendTargets', frontends[i], document, location) +} diff --git a/src/pages/options/widgets/sendTargets.pug b/src/pages/options/widgets/sendTargets.pug index 5b776b0a..fc2e9e73 100644 --- a/src/pages/options/widgets/sendTargets.pug +++ b/src/pages/options/widgets/sendTargets.pug @@ -6,12 +6,6 @@ section#sendTargets_page.option-block h4(data-localise="__MSG_enable__") Enable input#sendTargets-enable(type="checkbox") - .some-block.option-block - h4(data-localise="__MSG_protocol__") Protocol - select#sendTargets-protocol - option(value="normal" data-localise="__MSG_normal__") Normal - option(value="tor" data-localise="__MSG_tor__") Tor - #send hr .normal @@ -21,6 +15,12 @@ section#sendTargets_page.option-block +latency('send') .tor include ../../widgets/instances.pug - +instances('https://send.onion') + +instances('http://send.onion') + .i2p + include ../../widgets/instances.pug + +instances('http://send.i2p') + .loki + include ../../widgets/instances.pug + +instances('http://send.loki') - script(type="module" src="./widgets/sendTargets.js") \ No newline at end of file + script(type="module" src="./widgets/sendTargets.js") diff --git a/src/pages/options/widgets/tiktok.js b/src/pages/options/widgets/tiktok.js index f4c31832..37c36366 100644 --- a/src/pages/options/widgets/tiktok.js +++ b/src/pages/options/widgets/tiktok.js @@ -1,53 +1,61 @@ import utils from "../../../assets/javascripts/utils.js"; +// UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST + +const frontends = new Array("proxiTok") +const protocols = new Array("normal", "tor", "i2p", "loki") + const enable = document.getElementById("tiktok-enable"); -const protocol = document.getElementById("tiktok-protocol") const tiktok = document.getElementById('tiktok_page'); +//const frontend = document.getElementById("tiktok-frontend"); +let protocol -function changeProtocolSettings() { - let normalDiv = tiktok.getElementsByClassName("normal")[0]; - let torDiv = tiktok.getElementsByClassName("tor")[0]; - if (protocol.value == 'normal') { - normalDiv.style.display = 'block'; - torDiv.style.display = 'none'; - } - else if (protocol.value == 'tor') { - normalDiv.style.display = 'none'; - torDiv.style.display = 'block'; +/* +function changeFrontendsSettings() { + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + if (frontends[i] == frontend.value) { + frontendDiv.style.display = 'block' + } else { + frontendDiv.style.display = 'none' + } } } +*/ -tiktok.addEventListener("change", () => { - browser.storage.local.set({ - disableTiktok: !enable.checked, - tiktokProtocol: protocol.value, - }); - changeProtocolSettings(); -}) +function changeProtocolSettings() { + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + for (let x = 0; x < protocols.length; x++) { + const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] + if (protocols[x] == protocol) { + protocolDiv.style.display = 'block' + } else { + protocolDiv.style.display = 'none' + } + } + } +} browser.storage.local.get( [ "disableTiktok", - "tiktokProtocol", + "protocol" ], r => { enable.checked = !r.disableTiktok; - protocol.value = r.tiktokProtocol; + protocol = r.protocol; changeProtocolSettings(); - let normalDiv = document.getElementsByClassName("normal")[0]; - let torDiv = document.getElementsByClassName("tor")[0]; - if (r.tiktokProtocol == 'normal') { - normalDiv.style.display = 'block'; - torDiv.style.display = 'none'; - } - else if (r.tiktokProtocol == 'tor') { - normalDiv.style.display = 'none'; - torDiv.style.display = 'block'; - } - } + } ) -utils.processDefaultCustomInstances('tiktok', 'proxiTok', 'normal', document); -utils.processDefaultCustomInstances('tiktok', 'proxiTok', 'tor', document); +tiktok.addEventListener("change", () => { + browser.storage.local.set({ disableTiktok: !enable.checked }); +}) -utils.latency('tiktok', 'proxiTok', document, location) \ No newline at end of file +for (let i = 0; i < frontends.length; i++) { + for (let x = 0; x < protocols.length; x++){ + utils.processDefaultCustomInstances('tiktok', frontends[i], protocols[x], document) + } + utils.latency('tiktok', frontends[i], document, location) +} diff --git a/src/pages/options/widgets/tiktok.pug b/src/pages/options/widgets/tiktok.pug index f0cc39c6..29ab5e2a 100644 --- a/src/pages/options/widgets/tiktok.pug +++ b/src/pages/options/widgets/tiktok.pug @@ -6,12 +6,6 @@ section#tiktok_page.option-block h4(data-localise="__MSG_enable__") Enable input#tiktok-enable(type="checkbox") - .some-block.option-block - h4(data-localise="__MSG_protocol__") Protocol - select#tiktok-protocol - option(value="normal" data-localise="__MSG_normal__") Normal - option(value="tor" data-localise="__MSG_tor__") Tor - #proxiTok hr .normal @@ -21,6 +15,12 @@ section#tiktok_page.option-block +latency('proxiTok') .tor include ../../widgets/instances.pug - +instances('https://proxitok.onion') + +instances('http://proxitok.onion') + .i2p + include ../../widgets/instances.pug + +instances('http://proxitok.i2p') + .loki + include ../../widgets/instances.pug + +instances('http://proxitok.loki') script(type="module" src="./widgets/tiktok.js") diff --git a/src/pages/options/widgets/translate.js b/src/pages/options/widgets/translate.js index 04869b63..87b8bb8d 100644 --- a/src/pages/options/widgets/translate.js +++ b/src/pages/options/widgets/translate.js @@ -1,64 +1,35 @@ import utils from "../../../assets/javascripts/utils.js"; -const enable = document.getElementById("translate-enable"); -const frontend = document.getElementById("translate-frontend"); -const protocol = document.getElementById("translate-protocol"); -const simplyTranslateDiv = document.getElementById("simplyTranslate"); -const lingvaDiv = document.getElementById("lingva"); +const frontends = new Array("simplyTranslate", "lingva") +const protocols = new Array("normal", "tor", "i2p", "loki") +const enable = document.getElementById("translate-enable"); const translate = document.getElementById('translate_page'); +const frontend = document.getElementById("translate-frontend"); +let protocol function changeFrontendsSettings() { - if (frontend.value == 'simplyTranslate') { - simplyTranslateDiv.style.display = 'block'; - lingvaDiv.style.display = 'none'; - } - else if (frontend.value == 'lingva') { - simplyTranslateDiv.style.display = 'none'; - lingvaDiv.style.display = 'block'; + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + if (frontends[i] == frontend.value) { + frontendDiv.style.display = 'block' + } else { + frontendDiv.style.display = 'none' + } } } function changeProtocolSettings() { - const normalSimplyTranslateDiv = document.getElementById("simplyTranslate").getElementsByClassName("normal")[0]; - const torSimplyTranslateDiv = document.getElementById("simplyTranslate").getElementsByClassName("tor")[0]; - const i2pSimplyTranslateDiv = document.getElementById("simplyTranslate").getElementsByClassName("i2p")[0]; - const lokiSimplyTranslateDiv = document.getElementById("simplyTranslate").getElementsByClassName("loki")[0]; - - const normalLingvaDiv = document.getElementById("lingva").getElementsByClassName("normal")[0]; - const torLingvaDiv = document.getElementById("lingva").getElementsByClassName("tor")[0]; - - if (protocol.value == 'normal') { - normalSimplyTranslateDiv.style.display = 'block'; - normalLingvaDiv.style.display = 'block'; - torSimplyTranslateDiv.style.display = 'none'; - torLingvaDiv.style.display = 'none'; - i2pSimplyTranslateDiv.style.display = 'none'; - lokiSimplyTranslateDiv.style.display = 'none'; - } - else if (protocol.value == 'tor') { - normalSimplyTranslateDiv.style.display = 'none'; - normalLingvaDiv.style.display = 'none'; - torSimplyTranslateDiv.style.display = 'block'; - torLingvaDiv.style.display = 'block'; - i2pSimplyTranslateDiv.style.display = 'none'; - lokiSimplyTranslateDiv.style.display = 'none'; - } - else if (protocol.value == 'i2p') { - normalSimplyTranslateDiv.style.display = 'none'; - normalLingvaDiv.style.display = 'none'; - torSimplyTranslateDiv.style.display = 'none'; - torLingvaDiv.style.display = 'none'; - i2pSimplyTranslateDiv.style.display = 'block'; - lokiSimplyTranslateDiv.style.display = 'none'; - } - else if (protocol.value == 'loki') { - normalSimplyTranslateDiv.style.display = 'none'; - normalLingvaDiv.style.display = 'none'; - torSimplyTranslateDiv.style.display = 'none'; - torLingvaDiv.style.display = 'none'; - i2pSimplyTranslateDiv.style.display = 'none'; - lokiSimplyTranslateDiv.style.display = 'block'; + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + for (let x = 0; x < protocols.length; x++) { + const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] + if (protocols[x] == protocol) { + protocolDiv.style.display = 'block' + } else { + protocolDiv.style.display = 'none' + } + } } } @@ -66,12 +37,12 @@ browser.storage.local.get( [ "translateDisable", "translateFrontend", - "translateProtocol", + "protocol" ], r => { enable.checked = !r.translateDisable; frontend.value = r.translateFrontend; - protocol.value = r.translateProtocol; + protocol = r.protocol; changeFrontendsSettings(); changeProtocolSettings(); } @@ -81,19 +52,13 @@ translate.addEventListener("change", () => { browser.storage.local.set({ translateDisable: !enable.checked, translateFrontend: frontend.value, - translateProtocol: protocol.value, }) - changeProtocolSettings(); changeFrontendsSettings(); }) - -utils.processDefaultCustomInstances('translate', 'simplyTranslate', 'normal', document); -utils.processDefaultCustomInstances('translate', 'simplyTranslate', 'tor', document); -utils.processDefaultCustomInstances('translate', 'simplyTranslate', 'i2p', document); -utils.processDefaultCustomInstances('translate', 'simplyTranslate', 'loki', document); -utils.processDefaultCustomInstances('translate', 'lingva', 'normal', document); -utils.processDefaultCustomInstances('translate', 'lingva', 'tor', document); - -utils.latency('translate', 'simplyTranslate', document, location, true) -utils.latency('translate', 'lingva', document, location, true) +for (let i = 0; i < frontends.length; i++) { + for (let x = 0; x < protocols.length; x++){ + utils.processDefaultCustomInstances('translate', frontends[i], protocols[x], document) + } + utils.latency('translate', frontends[i], document, location) +} diff --git a/src/pages/options/widgets/translate.pug b/src/pages/options/widgets/translate.pug index c29d75e1..4836c0f3 100644 --- a/src/pages/options/widgets/translate.pug +++ b/src/pages/options/widgets/translate.pug @@ -12,14 +12,6 @@ section#translate_page.option-block option(value="simplyTranslate") SimplyTranslate option(value="lingva") Lingva - .some-block.option-block - h4(data-localise="__MSG_protocol__") Protocol - select#translate-protocol - option(value="normal" data-localise="__MSG_normal__") Normal - option(value="tor" data-localise="__MSG_tor__") Tor - option(value="i2p" data-localise="__MSG_i2p__") I2P - option(value="loki" data-localise="__MSG_loki__") Lokinet - hr #simplyTranslate .normal @@ -44,6 +36,13 @@ section#translate_page.option-block +latency('lingva') .tor include ../../widgets/instances.pug - +instances('http://tyzxppdeoojdnaux.onion') + +instances('http://lingvatranslate.onion') + .i2p + include ../../widgets/instances.pug + +instances('http://lingvatranslate.i2p') + .loki + include ../../widgets/instances.pug + +instances('http://lingvatranslate.loki') + script(type="module" src="./widgets/translate.js") diff --git a/src/pages/options/widgets/twitter.js b/src/pages/options/widgets/twitter.js index aff108c8..d54fc928 100644 --- a/src/pages/options/widgets/twitter.js +++ b/src/pages/options/widgets/twitter.js @@ -1,32 +1,52 @@ import utils from "../../../assets/javascripts/utils.js"; +// UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST + +const frontends = new Array("nitter") +const protocols = new Array("normal", "tor", "i2p", "loki") + const enable = document.getElementById("twitter-enable"); -const protocol = document.getElementById("twitter-protocol"); -const redirectType = document.getElementById("twitter-redirect_type"); const twitter = document.getElementById('twitter_page'); +const redirectType = document.getElementById("twitter-redirect_type"); +//const frontend = document.getElementById("twitter-frontend"); +let protocol -function changeProtocolSettings() { - let normalDiv = twitter.getElementsByClassName("normal")[0]; - let torDiv = twitter.getElementsByClassName("tor")[0]; - if (protocol.value == 'normal') { - normalDiv.style.display = 'block'; - torDiv.style.display = 'none'; +/* +function changeFrontendsSettings() { + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + if (frontends[i] == frontend.value) { + frontendDiv.style.display = 'block' + } else { + frontendDiv.style.display = 'none' + } } - else if (protocol.value == 'tor') { - normalDiv.style.display = 'none'; - torDiv.style.display = 'block'; +} +*/ + +function changeProtocolSettings() { + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + for (let x = 0; x < protocols.length; x++) { + const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] + if (protocols[x] == protocol) { + protocolDiv.style.display = 'block' + } else { + protocolDiv.style.display = 'none' + } + } } } browser.storage.local.get( [ "disableTwitter", - "twitterProtocol", - "twitterRedirectType", + "protocol", + "twitterRedirectType" ], r => { enable.checked = !r.disableTwitter; - protocol.value = r.twitterProtocol; + protocol = r.protocol; redirectType.value = r.twitterRedirectType; changeProtocolSettings(); } @@ -35,13 +55,13 @@ browser.storage.local.get( twitter.addEventListener("change", () => { browser.storage.local.set({ disableTwitter: !enable.checked, - twitterProtocol: protocol.value, twitterRedirectType: redirectType.value, }); - changeProtocolSettings(); }) -utils.processDefaultCustomInstances('twitter', 'nitter', 'normal', document); -utils.processDefaultCustomInstances('twitter', 'nitter', 'tor', document) - -utils.latency('twitter', 'nitter', document, location, true) \ No newline at end of file +for (let i = 0; i < frontends.length; i++) { + for (let x = 0; x < protocols.length; x++){ + utils.processDefaultCustomInstances('twitter', frontends[i], protocols[x], document) + } + utils.latency('twitter', frontends[i], document, location) +} diff --git a/src/pages/options/widgets/twitter.pug b/src/pages/options/widgets/twitter.pug index c2e949ca..6e610545 100644 --- a/src/pages/options/widgets/twitter.pug +++ b/src/pages/options/widgets/twitter.pug @@ -7,12 +7,6 @@ section#twitter_page.option-block input#twitter-enable(type="checkbox") .some-block.option-block - h4(data-localise="__MSG_protocol__") Protocol - select#twitter-protocol - option(value="normal" data-localise="__MSG_normal__") Normal - option(value="tor" data-localise="__MSG_tor__") Tor - - .some-block.option-block h4(data-localise="__MSG_redirectType__") Redirect Type select#twitter-redirect_type option(value="both" data-localise="__MSG_both__") both @@ -27,6 +21,13 @@ section#twitter_page.option-block include ../../widgets/latency.pug +latency('nitter') .tor - +instances('https://nitter.onion') + include ../../widgets/instances.pug + +instances('http://nitter.onion') + .i2p + include ../../widgets/instances.pug + +instances('http://nitter.i2p') + .loki + include ../../widgets/instances.pug + +instances('http://nitter.loki') script(type="module" src="./widgets/twitter.js") diff --git a/src/pages/options/widgets/wikipedia.js b/src/pages/options/widgets/wikipedia.js index c9e582be..09b21d02 100644 --- a/src/pages/options/widgets/wikipedia.js +++ b/src/pages/options/widgets/wikipedia.js @@ -1,52 +1,61 @@ import utils from "../../../assets/javascripts/utils.js"; +// UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST + +const frontends = new Array("wikiless") +const protocols = new Array("normal", "tor", "i2p", "loki") + const enable = document.getElementById("wikipedia-enable"); -const protocolElement = document.getElementById("wikipedia-protocol"); const wikipedia = document.getElementById('wikipedia_page'); +//const frontend = document.getElementById("wikipedia-frontend"); +let protocol -function changeProtocolSettings(protocol) { - const normalDiv = wikipedia.getElementsByClassName("normal")[0]; - const torDiv = wikipedia.getElementsByClassName("tor")[0]; - const i2pDiv = wikipedia.getElementsByClassName("i2p")[0]; - if (protocol == 'normal') { - normalDiv.style.display = 'block'; - torDiv.style.display = 'none'; - i2pDiv.style.display = 'none'; +/* +function changeFrontendsSettings() { + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + if (frontends[i] == frontend.value) { + frontendDiv.style.display = 'block' + } else { + frontendDiv.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'; +} +*/ + +function changeProtocolSettings() { + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + for (let x = 0; x < protocols.length; x++) { + const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] + if (protocols[x] == protocol) { + protocolDiv.style.display = 'block' + } else { + protocolDiv.style.display = 'none' + } + } } } browser.storage.local.get( [ "disableWikipedia", - "wikipediaProtocol", + "protocol" ], r => { enable.checked = !r.disableWikipedia; - protocolElement.value = r.wikipediaProtocol; - changeProtocolSettings(r.wikipediaProtocol); + protocol = r.protocol; + changeProtocolSettings(); } ) wikipedia.addEventListener("change", () => { - browser.storage.local.set({ - disableWikipedia: !enable.checked, - wikipediaProtocol: protocolElement.value, - }) - changeProtocolSettings(protocolElement.value) + browser.storage.local.set({ disableWikipedia: !enable.checked }) }) -utils.processDefaultCustomInstances('wikipedia', 'wikiless', 'normal', document); -utils.processDefaultCustomInstances('wikipedia', 'wikiless', 'tor', document); -utils.processDefaultCustomInstances('wikipedia', 'wikiless', 'i2p', document); - -utils.latency('wikipedia', 'wikiless', document, location) \ No newline at end of file +for (let i = 0; i < frontends.length; i++) { + for (let x = 0; x < protocols.length; x++) { + utils.processDefaultCustomInstances('wikipedia', frontends[i], protocols[x], document) + } + utils.latency('wikipedia', frontends[i], document, location) +} diff --git a/src/pages/options/widgets/wikipedia.pug b/src/pages/options/widgets/wikipedia.pug index a0315739..c9aee64c 100644 --- a/src/pages/options/widgets/wikipedia.pug +++ b/src/pages/options/widgets/wikipedia.pug @@ -6,13 +6,6 @@ section#wikipedia_page.option-block h4(data-localise="__MSG_enable__") Enable input#wikipedia-enable(type="checkbox") - .some-block.option-block - h4(data-localise="__MSG_protocol__") Protocol - select#wikipedia-protocol - option(value="normal" data-localise="__MSG_normal__") Normal - option(value="tor" data-localise="__MSG_tor__") Tor - option(value="i2p" data-localise="__MSG_i2p__") I2P - #wikiless hr .normal @@ -22,10 +15,12 @@ section#wikipedia_page.option-block +latency('wikiless') .tor include ../../widgets/instances.pug - +instances('https://wikiless.onion') - + +instances('http://wikiless.onion') .i2p include ../../widgets/instances.pug +instances('https://wikiless.i2p') + .loki + include ../../widgets/instances.pug + +instances('http://wikiless.loki') script(type="module" src="./widgets/wikipedia.js") diff --git a/src/pages/options/widgets/youtube.js b/src/pages/options/widgets/youtube.js index 26867643..76b673bd 100644 --- a/src/pages/options/widgets/youtube.js +++ b/src/pages/options/widgets/youtube.js @@ -1,114 +1,66 @@ -import youtubeHelper from "../../../assets/javascripts/youtube/youtube.js"; import utils from "../../../assets/javascripts/utils.js"; +const frontends = new Array("invidious", "piped", "pipedMaterial") +const protocols = new Array("normal", "tor", "i2p", "loki") +const singleInstanceFrontends = new Array("freetube", "yatte") + const enable = document.getElementById("youtube-enable"); -const frontend = document.getElementById("youtube-frontend"); +const youtube = document.getElementById('youtube_page'); const youtubeEmbedFrontend = document.getElementById("youtube-embed_frontend"); const onlyEmbeddedVideo = document.getElementById("youtube-redirect_type"); -const protocol = document.getElementById("youtube-protocol"); -const youtube = document.getElementById('youtube_page'); - -const invidiousDiv = document.getElementById("invidious"); -const pipedDiv = document.getElementById("piped"); -const pipedMaterialDiv = document.getElementById("pipedMaterial"); -const freetubeYatteeDiv = document.getElementById("freetube-yatte"); +const embeddedFrontendDiv = document.getElementById("youtube-embedded_frontend"); +const frontend = document.getElementById("youtube-frontend"); +let protocol -function changeFrontendsSettings() { - if (frontend.value == 'invidious') { - invidiousDiv.style.display = 'block'; - pipedDiv.style.display = 'none'; - pipedMaterialDiv.style.display = 'none'; - freetubeYatteeDiv.style.display = 'none'; - } - else if (frontend.value == 'piped') { - invidiousDiv.style.display = 'none'; - pipedDiv.style.display = 'block'; - pipedMaterialDiv.style.display = 'none'; - freetubeYatteeDiv.style.display = 'none'; - } - else if (frontend.value == 'pipedMaterial') { - invidiousDiv.style.display = 'none'; - pipedDiv.style.display = 'none'; - pipedMaterialDiv.style.display = 'block'; - freetubeYatteeDiv.style.display = 'none'; - } - else if (frontend.value == 'freetube' || frontend.value == 'yatte') { - invidiousDiv.style.display = 'none'; - pipedDiv.style.display = 'none'; - pipedMaterialDiv.style.display = 'none'; - freetubeYatteeDiv.style.display = 'block'; - changeYoutubeEmbedFrontendsSettings(); +function changeProtocolSettings() { + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + for (let x = 0; x < protocols.length; x++) { + const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] + if (protocols[x] == protocol) { + protocolDiv.style.display = 'block' + } else { + protocolDiv.style.display = 'none' + } + } } } -function changeYoutubeEmbedFrontendsSettings() { - if (youtubeEmbedFrontend.value == 'invidious') { - pipedDiv.style.display = 'none'; - pipedMaterialDiv.style.display = 'none'; - invidiousDiv.style.display = 'block'; - } - if (youtubeEmbedFrontend.value == 'piped') { - pipedDiv.style.display = 'block'; - pipedMaterialDiv.style.display = 'none'; - invidiousDiv.style.display = 'none'; - } - if (youtubeEmbedFrontend.value == 'pipedMaterial') { - pipedDiv.style.display = 'none'; - pipedMaterialDiv.style.display = 'block'; - invidiousDiv.style.display = 'none'; - } - else if (youtubeEmbedFrontend.value == 'youtube') { - pipedDiv.style.display = 'none'; - pipedMaterialDiv.style.display = 'none'; - invidiousDiv.style.display = 'none'; +function changeEmbedFrontendsSettings() { + if (embeddedFrontendDiv.style.display == 'block') { + for (let i = 0; i < frontends.length; i++) { + const embeddedFrontendDiv = document.getElementById(frontends[i]) + if (frontends[i] == youtubeEmbedFrontend.value) { + embeddedFrontendDiv.style.display = 'block' + } else { + embeddedFrontendDiv.style.display = 'none' + } + } } } -function changeProtocolSettings() { - const normalPipedDiv = document.getElementById('piped').getElementsByClassName("normal")[0]; - const torPipedDiv = document.getElementById('piped').getElementsByClassName("tor")[0]; - - const normalPipedMaterialDiv = document.getElementById('pipedMaterial').getElementsByClassName("normal")[0]; - const torPipedMaterialDiv = document.getElementById('pipedMaterial').getElementsByClassName("tor")[0]; - - const normalInvidiousDiv = document.getElementById('invidious').getElementsByClassName("normal")[0]; - const torInvidiousDiv = document.getElementById('invidious').getElementsByClassName("tor")[0]; - - if (protocol.value == 'normal') { - normalInvidiousDiv.style.display = 'block'; - torInvidiousDiv.style.display = 'none'; - - normalPipedDiv.style.display = 'block'; - torPipedDiv.style.display = 'none'; - - normalPipedMaterialDiv.style.display = 'block'; - torPipedMaterialDiv.style.display = 'none'; +function changeFrontendsSettings() { + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + if (frontends[i] == frontend.value) { + frontendDiv.style.display = 'block' + } else { + frontendDiv.style.display = 'none' + } } - else if (protocol.value == 'tor') { - normalInvidiousDiv.style.display = 'none'; - torInvidiousDiv.style.display = 'block'; - - normalPipedDiv.style.display = 'none'; - torPipedDiv.style.display = 'block'; - - normalPipedMaterialDiv.style.display = 'none'; - torPipedMaterialDiv.style.display = 'block'; + let singleInstanceFrontend = false + for (let i = 0; i < singleInstanceFrontends.length; i++) { + if (singleInstanceFrontends[i] == frontend.value) { + singleInstanceFrontend = true + } + } + if (singleInstanceFrontend == true) { + embeddedFrontendDiv.style.display = 'block' + } else { + embeddedFrontendDiv.style.display = 'none' } } -youtube.addEventListener("change", () => { - browser.storage.local.set({ - disableYoutube: !enable.checked, - youtubeFrontend: frontend.value, - youtubeEmbedFrontend: youtubeEmbedFrontend.value, - onlyEmbeddedVideo: onlyEmbeddedVideo.value, - youtubeProtocol: protocol.value, - }) - changeProtocolSettings(); - changeYoutubeEmbedFrontendsSettings(); - changeFrontendsSettings(); -}) - browser.storage.local.get( [ "disableYoutube", @@ -117,29 +69,33 @@ browser.storage.local.get( "youtubeFrontend", "youtubeEmbedFrontend", - "youtubeProtocol", + "protocol" ], r => { enable.checked = !r.disableYoutube; onlyEmbeddedVideo.value = r.onlyEmbeddedVideo; frontend.value = r.youtubeFrontend; - protocol.value = r.youtubeProtocol; + protocol = r.protocol; changeFrontendsSettings(); changeProtocolSettings(); - - youtubeEmbedFrontend.value = youtubeEmbedFrontend.value - if (r.frontend == "freetube" || r.frontend == "yatte") changeYoutubeEmbedFrontendsSettings() + changeEmbedFrontendsSettings(); } ); -utils.processDefaultCustomInstances('youtube', 'invidious', 'normal', document); -utils.processDefaultCustomInstances('youtube', 'invidious', 'tor', document); -utils.processDefaultCustomInstances('youtube', 'pipedMaterial', 'normal', document); -utils.processDefaultCustomInstances('youtube', 'pipedMaterial', 'tor', document); -utils.processDefaultCustomInstances('youtube', 'piped', 'normal', document); -utils.processDefaultCustomInstances('youtube', 'piped', 'tor', document); +youtube.addEventListener("change", () => { + browser.storage.local.set({ + disableYoutube: !enable.checked, + youtubeEmbedFrontend: youtubeEmbedFrontend.value, + onlyEmbeddedVideo: onlyEmbeddedVideo.value + }) + changeFrontendsSettings(); + changeEmbedFrontendsSettings(); +}) -utils.latency('youtube', 'invidious', document, location, true) -utils.latency('youtube', 'piped', document, location, true) -utils.latency('youtube', 'pipedMaterial', document, location, true) +for (let i = 0; i < frontends.length; i++) { + for (let x = 0; x < protocols.length; x++) { + utils.processDefaultCustomInstances('youtube', frontends[i], protocols[x], document) + } + utils.latency('youtube', frontends[i], document, location) +} diff --git a/src/pages/options/widgets/youtube.pug b/src/pages/options/widgets/youtube.pug index 7985244f..cf175629 100644 --- a/src/pages/options/widgets/youtube.pug +++ b/src/pages/options/widgets/youtube.pug @@ -15,38 +15,37 @@ section#youtube_page.option-block option(value="freetube") FreeTube option(value="yatte") Yattee - #freetube-yatte + #youtube-embedded_frontend .some-block.option-block h4(data-localise="__MSG_embeddedVids__") Embedded Videos Frontend select#youtube-embed_frontend option(value="invidious") Invidious option(value="piped") Piped option(value="pipedMaterial") Piped-Material - option(value="youtube") Youtube - #invidious-piped-pipedMaterial - .some-block.option-block - h4(data-localise="__MSG_protocol__") Protocol - select#youtube-protocol - option(value="normal" data-localise="__MSG_normal__") Normal - option(value="tor" data-localise="__MSG_tor__") Tor - - .some-block.option-block - h4(data-localise="__MSG_redirectType__") Redirect Type - select#youtube-redirect_type - option(value="both" data-localise="__MSG_both__") both - option(value="onlyEmbedded" data-localise="__MSG_onlyEmbedded__") Only Embedded - option(value="onlyNotEmbedded" data-localise="__MSG_onlyNotEmbedded__") Only Not Embedded + .some-block.option-block + h4(data-localise="__MSG_redirectType__") Redirect Type + select#youtube-redirect_type + option(value="both" data-localise="__MSG_both__") both + option(value="onlyEmbedded" data-localise="__MSG_onlyEmbedded__") Only Embedded + option(value="onlyNotEmbedded" data-localise="__MSG_onlyNotEmbedded__") Only Not Embedded #invidious hr .normal include ../../widgets/instances.pug - +instances('https://invidious.com') + +instances('http://invidious.com') include ../../widgets/latency.pug +latency('invidious') .tor - +instances('https://invidious.onion') + include ../../widgets/instances.pug + +instances('http://invidious.onion') + .i2p + include ../../widgets/instances.pug + +instances('http://invidious.i2p') + .loki + include ../../widgets/instances.pug + +instances('http://invidious.loki') #piped hr @@ -54,7 +53,14 @@ section#youtube_page.option-block +instances('https://piped.com') +latency('piped') .tor - +instances('https://piped.onion') + +instances('http://piped.onion') + include ../../widgets/instances.pug + .i2p + include ../../widgets/instances.pug + +instances('http://piped.i2p') + .loki + include ../../widgets/instances.pug + +instances('http://piped.loki') #pipedMaterial hr @@ -62,7 +68,13 @@ section#youtube_page.option-block +instances('https://piped-material.com') +latency('pipedMaterial') .tor - +instances('https://piped-material.onion') - + +instances('http://piped-material.onion') + include ../../widgets/instances.pug + .i2p + include ../../widgets/instances.pug + +instances('http://piped-material.i2p') + .loki + include ../../widgets/instances.pug + +instances('http://piped-material.loki') script(type="module" src="./widgets/youtube.js") diff --git a/src/pages/options/widgets/youtubeMusic.js b/src/pages/options/widgets/youtubeMusic.js index cb5ab1d7..4d33c1fa 100644 --- a/src/pages/options/widgets/youtubeMusic.js +++ b/src/pages/options/widgets/youtubeMusic.js @@ -1,23 +1,61 @@ import utils from "../../../assets/javascripts/utils.js"; +// UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST + +const frontends = new Array("beatbump") +const protocols = new Array("normal", "tor", "i2p", "loki") + let enable = document.getElementById("youtubeMusic-enable"); const youtubeMusic = document.getElementById('youtubeMusic_page'); +//const frontend = document.getElementById("youtubeMusic-frontend"); +let protocol + +/* +function changeFrontendsSettings() { + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + if (frontends[i] == frontend.value) { + frontendDiv.style.display = 'block' + } else { + frontendDiv.style.display = 'none' + } + } +} +*/ + +function changeProtocolSettings() { + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + for (let x = 0; x < protocols.length; x++) { + const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] + if (protocols[x] == protocol) { + protocolDiv.style.display = 'block' + } else { + protocolDiv.style.display = 'none' + } + } + } +} browser.storage.local.get( [ "disableYoutubeMusic", + "protocol" ], r => { - enable.checked = !r.disableYoutubeMusic; + enable.checked = !r.disableYoutubeMusic + protocol = r.protocol + changeProtocolSettings() } ); youtubeMusic.addEventListener("change", () => { - browser.storage.local.set({ - disableYoutubeMusic: !enable.checked, - }) + browser.storage.local.set({ disableYoutubeMusic: !enable.checked }) }) -utils.processDefaultCustomInstances('youtubeMusic', 'beatbump', 'normal', document); - -utils.latency('youtubeMusic', 'beatbump', document, location, true) \ No newline at end of file +for (let i = 0; i < frontends.length; i++) { + for (let x = 0; x < protocols.length; x++) { + utils.processDefaultCustomInstances('youtubeMusic', frontends[i], protocols[x], document) + } + utils.latency('youtubeMusic', frontends[i], document, location) +} diff --git a/src/pages/options/widgets/youtubeMusic.pug b/src/pages/options/widgets/youtubeMusic.pug index ac4d6403..f307ae9a 100644 --- a/src/pages/options/widgets/youtubeMusic.pug +++ b/src/pages/options/widgets/youtubeMusic.pug @@ -13,5 +13,14 @@ section#youtubeMusic_page.option-block +instances('https://beatbump.wewe') include ../../widgets/latency.pug +latency('beatbump') + .tor + +instances('http://beatbump.onion') + include ../../widgets/instances.pug + .i2p + include ../../widgets/instances.pug + +instances('http://beatbump.i2p') + .loki + include ../../widgets/instances.pug + +instances('http://beatbump.loki') script(type="module" src="./widgets/youtubeMusic.js") diff --git a/src/pages/popup/popup.js b/src/pages/popup/popup.js index e12e61e9..5e7b2336 100644 --- a/src/pages/popup/popup.js +++ b/src/pages/popup/popup.js @@ -130,7 +130,7 @@ browser.storage.local.get( "disablePeertubeTargets", "disableLbryTargets", "disableSendTarget", - 'popupFrontends', + "popupFrontends", ], r => { disableTwitterCurrentSite.checked = !r.disableTwitter; disableTwitterAllSites.checked = !r.disableTwitter; @@ -327,4 +327,4 @@ for (const a of document.getElementsByTagName('a')) { e.preventDefault(); } }) -} \ No newline at end of file +} |