diff options
author | BobIsMyManager <bimmgitsignature.nly8m@simplelogin.co> | 2022-07-22 19:39:08 +0100 |
---|---|---|
committer | BobIsMyManager <bimmgitsignature.nly8m@simplelogin.co> | 2022-07-22 19:39:08 +0100 |
commit | 3bc5cafe65caa86734f6ad9ef13d3a70f5effa4c (patch) | |
tree | fe0fa3dda40b4499f55ba936216b4d06c5fee0b5 /src/assets/javascripts/reuters.js | |
parent | Fix workflows issue (diff) | |
download | libredirect-3bc5cafe65caa86734f6ad9ef13d3a70f5effa4c.zip |
Make almost all instances follow new protocol structre
Closes https://github.com/libredirect/libredirect/issues/238 Closes https://github.com/libredirect/libredirect/issues/391
Diffstat (limited to 'src/assets/javascripts/reuters.js')
-rw-r--r-- | src/assets/javascripts/reuters.js | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/src/assets/javascripts/reuters.js b/src/assets/javascripts/reuters.js index ee4f227c..aaae5d17 100644 --- a/src/assets/javascripts/reuters.js +++ b/src/assets/javascripts/reuters.js @@ -18,6 +18,21 @@ for (let i = 0; i < frontends.length; i++) { } } +function setRedirects(val) { + browser.storage.local.get('cloudflareBlackList', r => { + redirects.neuters = val; + neutersNormalRedirectsChecks = [...redirects.neuters.normal]; + for (const instance of r.cloudflareBlackList) { + const a = neutersNormalRedirectsChecks.indexOf(instance); + if (a > -1) neutersNormalRedirectsChecks.splice(a, 1); + } + browser.storage.local.set({ + neutersRedirects: redirects, + neutersNormalRedirectsChecks + }) + }) +} + let disableReuters, protocol, @@ -26,7 +41,9 @@ let neutersNormalRedirectsChecks, neutersNormalCustomRedirects, neutersTorRedirectsChecks, - neutersTorCustomRedirects; + neutersTorCustomRedirects, + neutersI2pCustomRedirects, + neutersLokiCustomRedirects; function init() { return new Promise(async resolve => { @@ -40,6 +57,8 @@ function init() { "neutersNormalCustomRedirects", "neutersTorRedirectsChecks", "neutersTorCustomRedirects", + "neutersI2pCustomRedirects", + "neutersLokiCustomRedirects" ], r => { disableReuters = r.disableReuters; @@ -50,6 +69,8 @@ function init() { neutersNormalCustomRedirects = r.neutersNormalCustomRedirects; neutersTorRedirectsChecks = r.neutersTorRedirectsChecks; neutersTorCustomRedirects = r.neutersTorCustomRedirects; + neutersI2pCustomRedirects = r.neutersI2pCustomRedirects; + neutersLokiCustomRedirects = r.neutersLokiCustomRedirects; resolve(); } ) @@ -70,7 +91,9 @@ function redirect(url, type, initiator, disableOverride) { if (!targets.some(rx => rx.test(url.href))) return; let instancesList = []; - if (protocol == 'tor') instancesList = [...neutersTorRedirectsChecks, ...neutersTorCustomRedirects]; + if (protocol == 'loki') instancesList = [...neutersLokiCustomRedirects]; + else if (protocol == 'i2p') instancesList = [...neutersI2pCustomRedirects]; + else if (protocol == 'tor') instancesList = [...neutersTorRedirectsChecks, ...neutersTorCustomRedirects]; if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') { instancesList = [...neutersNormalRedirectsChecks, ...neutersNormalCustomRedirects]; } @@ -103,11 +126,16 @@ function initDefaults() { neutersTorRedirectsChecks: [...redirects.neuters.tor], neutersTorCustomRedirects: [], + + neutersI2pCustomRedirects: [], + + neutersLokiCustomRedirects: [] }, () => resolve()); }); } export default { + setRedirects, redirect, initDefaults }; |