From f4dc7ded61079a8d564bd804fad00a7f4f904319 Mon Sep 17 00:00:00 2001 From: BobIsMyManager Date: Thu, 21 Jul 2022 21:30:46 +0100 Subject: 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 --- src/_locales/en/messages.json | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'src/_locales/en') 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" } } -- cgit 1.4.1 From e08dd3d5a93074b70d002aa4d097cf2c6a653e34 Mon Sep 17 00:00:00 2001 From: BobIsMyManager Date: Sat, 23 Jul 2022 14:11:44 +0100 Subject: Resolve redirects for neuters and youtube --- src/_locales/en/messages.json | 2 +- src/assets/javascripts/reuters.js | 27 ++++++++++++++++++--------- src/assets/javascripts/youtube/youtube.js | 22 +++++++++++----------- src/instances/get_instances.py | 3 ++- src/pages/options/widgets/general.pug | 2 +- 5 files changed, 33 insertions(+), 23 deletions(-) (limited to 'src/_locales/en') diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index 024ba454..dfbede1a 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -206,6 +206,6 @@ "message": "Test Instances Latency" }, "protocolFallback": { - "message": "Fallback to normal if no frontends are available for the current protocol" + "message": "Fallback to normal if no instances are available for the current protocol" } } diff --git a/src/assets/javascripts/reuters.js b/src/assets/javascripts/reuters.js index aaae5d17..01e47010 100644 --- a/src/assets/javascripts/reuters.js +++ b/src/assets/javascripts/reuters.js @@ -6,18 +6,27 @@ const targets = [ /^https?:\/{2}(www\.|)reuters\.com.*/ ]; -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 redirects = { + "neuters": { + "normal": [ + "https://neuters.de" + ], + "tor": [], + "i2p": [], + "loki": [] } } +// 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]] = [] +// } +// } + function setRedirects(val) { browser.storage.local.get('cloudflareBlackList', r => { redirects.neuters = val; diff --git a/src/assets/javascripts/youtube/youtube.js b/src/assets/javascripts/youtube/youtube.js index 3d7cd892..439f5605 100644 --- a/src/assets/javascripts/youtube/youtube.js +++ b/src/assets/javascripts/youtube/youtube.js @@ -54,7 +54,7 @@ function setRedirects(val) { pipedNormalRedirectsChecks, pipedTorRedirectsChecks: redirects.piped.tor, pipedMaterialNormalRedirectsChecks, - pipedMaterialTorRedirectsChecks: redirects.pipedMaterial.tor + // pipedMaterialTorRedirectsChecks: redirects.pipedMaterial.tor }) }) } @@ -81,7 +81,7 @@ let pipedLokiCustomRedirects, pipedMaterialNormalRedirectsChecks, pipedMaterialNormalCustomRedirects, - pipedMaterialTorRedirectsChecks, + // pipedMaterialTorRedirectsChecks, pipedMaterialTorCustomRedirects, pipedMaterialI2pCustomRedirects, pipedMaterialLokiCustomRedirects; @@ -111,7 +111,7 @@ function init() { "pipedLokiCustomRedirects", "pipedMaterialNormalRedirectsChecks", "pipedMaterialNormalCustomRedirects", - "pipedMaterialTorRedirectsChecks", + // "pipedMaterialTorRedirectsChecks", "pipedMaterialTorCustomRedirects", "pipedMaterialI2pCustomRedirects", "pipedMaterialLokiCustomRedirects" @@ -138,7 +138,7 @@ function init() { pipedLokiCustomRedirects = r.pipedLokiCustomRedirects; pipedMaterialNormalRedirectsChecks = r.pipedMaterialNormalRedirectsChecks; pipedMaterialNormalCustomRedirects = r.pipedMaterialNormalCustomRedirects; - pipedMaterialTorRedirectsChecks = r.pipedMaterialTorRedirectsChecks; + // pipedMaterialTorRedirectsChecks = r.pipedMaterialTorRedirectsChecks; pipedMaterialTorCustomRedirects = r.pipedMaterialTorCustomRedirects; pipedMaterialI2pCustomRedirects - r.pipedMaterialI2pCustomRedirects; pipedMaterialLokiCustomRedirects = r.pipedMaterialLokiCustomRedirects; @@ -235,7 +235,7 @@ function redirect(url, type, initiator, disableOverride) { let instancesList = []; if (protocol == 'loki') instancesList = [...pipedMaterialLokiCustomRedirects]; else if (protocol == 'i2p') instancesList = [...pipedMaterialI2pCustomRedirects]; - else if (protocol == 'tor') instancesList = [...pipedMaterialTorRedirectsChecks, ...pipedMaterialTorCustomRedirects]; + else if (protocol == 'tor') instancesList = [...pipedMaterialTorCustomRedirects]; //...pipedMaterialTorRedirectsChecks, if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { instancesList = [...pipedMaterialNormalRedirectsChecks, ...pipedMaterialNormalCustomRedirects]; } @@ -275,7 +275,7 @@ function switchInstance(url, disableOverride) { else if (protocol == 'tor') { if (youtubeFrontend == 'invidious') instancesList = [...invidiousTorRedirectsChecks, ...invidiousTorCustomRedirects]; else if (youtubeFrontend == 'piped') instancesList = [...pipedTorRedirectsChecks, ...pipedTorCustomRedirects]; - else if (youtubeFrontend == 'pipedMaterial') instancesList = [...pipedMaterialTorRedirectsChecks, ...pipedMaterialTorCustomRedirects]; + else if (youtubeFrontend == 'pipedMaterial') instancesList = [...pipedMaterialTorCustomRedirects]; //...pipedMaterialTorRedirectsChecks, } if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { if (youtubeFrontend == 'invidious') instancesList = [...invidiousNormalRedirectsChecks, ...invidiousNormalCustomRedirects]; @@ -348,7 +348,7 @@ function initDefaults() { pipedMaterialNormalRedirectsChecks: pipedMaterialNormalRedirectsChecks, pipedMaterialNormalCustomRedirects: [], - pipedMaterialTorRedirectsChecks: [...redirects.pipedMaterial.tor], + //pipedMaterialTorRedirectsChecks: [...redirects.pipedMaterial.tor], pipedMaterialTorCustomRedirects: [], pipedMaterialI2pCustomRedirects: [], @@ -469,7 +469,7 @@ function copyPastePipedMaterialLocalStorage(test, url, tabId,) { if (![ ...pipedMaterialNormalRedirectsChecks, ...pipedMaterialNormalCustomRedirects, - ...pipedMaterialTorRedirectsChecks, + //...pipedMaterialTorRedirectsChecks, ...pipedMaterialTorCustomRedirects, ...pipedMaterialI2pCustomRedirects, ...pipedMaterialLokiCustomRedirects @@ -481,7 +481,7 @@ function copyPastePipedMaterialLocalStorage(test, url, tabId,) { let checkedInstances = []; if (protocol == 'loki') checkedInstances = [...pipedMaterialLokiCustomRedirects]; else if (protocol == 'i2p') checkedInstances = [...pipedMaterialI2pCustomRedirects]; - else if (protocol == 'tor') checkedInstances = [...pipedMaterialTorRedirectsChecks, ...pipedMaterialTorCustomRedirects] + else if (protocol == 'tor') checkedInstances = [...pipedMaterialTorCustomRedirects]; //...pipedMaterialTorRedirectsChecks, if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { checkedInstances = [...pipedMaterialNormalRedirectsChecks, ...pipedMaterialNormalCustomRedirects] } @@ -504,7 +504,7 @@ function pastePipedMaterialLocalStorage() { let checkedInstances = []; if (protocol == 'loki') checkedInstances = [...pipedMaterialLokiCustomRedirects]; else if (protocol == 'i2p') checkedInstances = [...pipedMaterialI2pCustomRedirects]; - else if (protocol == 'tor') checkedInstances = [...pipedMaterialTorRedirectsChecks, ...pipedMaterialTorCustomRedirects] + else if (protocol == 'tor') checkedInstances = [...pipedMaterialTorCustomRedirects]; //...pipedMaterialTorRedirectsChecks, if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { checkedInstances = [...pipedMaterialNormalRedirectsChecks, ...pipedMaterialNormalCustomRedirects] } @@ -536,7 +536,7 @@ function removeXFrameOptions(e) { else if (protocol == 'tor') { if (youtubeFrontend == 'invidious') instancesList = [...invidiousTorRedirectsChecks, ...invidiousTorCustomRedirects]; if (youtubeFrontend == 'piped') instancesList = [...pipedTorRedirectsChecks, ...pipedTorCustomRedirects]; - if (youtubeFrontend == 'pipedMaterial') instancesList = [...pipedMaterialTorRedirectsChecks, ...pipedMaterialTorCustomRedirects]; + if (youtubeFrontend == 'pipedMaterial') instancesList = [...pipedMaterialTorCustomRedirects]; //...pipedMaterialTorRedirectsChecks, } if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { if (youtubeFrontend == 'invidious') instancesList = [...invidiousNormalRedirectsChecks, ...invidiousNormalCustomRedirects]; diff --git a/src/instances/get_instances.py b/src/instances/get_instances.py index b7ff2432..1d1334a8 100644 --- a/src/instances/get_instances.py +++ b/src/instances/get_instances.py @@ -111,6 +111,7 @@ def pipedMaterial(): r"\| (https?:\/{2}(?:.+\.)+[a-zA-Z0-9]*) +\|", r.text) pipedMaterialList = {} pipedMaterialList['normal'] = [] + pipedMaterialList['tor'] = [] for item in tmp: pipedMaterialList['normal'].append(item) mightyList['pipedMaterial'] = pipedMaterialList @@ -174,7 +175,7 @@ def nitter(): def bibliogram(): - r = requests.get('https://bibliogram.pussthecat.org/api/instances') + r = requests.get('https://bibliogram.art/api/instances') rJson = json.loads(r.text) bibliogramList = {} bibliogramList['normal'] = [] diff --git a/src/pages/options/widgets/general.pug b/src/pages/options/widgets/general.pug index e6e80afb..11fbd0f9 100644 --- a/src/pages/options/widgets/general.pug +++ b/src/pages/options/widgets/general.pug @@ -24,7 +24,7 @@ section#general_page.option-block #protocol-fallback .some-block.option-block - h4(data-localise="__MSG_protocolFallback__") Fallback to normal if no frontends are available for the current protocol + h4(data-localise="__MSG_protocolFallback__") Fallback to normal if no instances are available for the current protocol input#protocol-fallback(type="checkbox") .some-block.option-block -- cgit 1.4.1