diff options
31 files changed, 364 insertions, 285 deletions
diff --git a/README.md b/README.md index a9e68391..4de39765 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,7 @@ npm run start ### Install temporarily open `about:addons`\ -click on the settings button below the addon search bar and select `debug add-on`\ +type in the address bar `about:debugging`\ press `load temporarily addon` ### Install in Firefox ESR, Developer Edition, Nightly diff --git a/src/assets/images/imgur-icon.png b/src/assets/images/imgur.png index c23a45b2..c23a45b2 100644 --- a/src/assets/images/imgur-icon.png +++ b/src/assets/images/imgur.png Binary files differdiff --git a/src/assets/javascripts/general.js b/src/assets/javascripts/general.js index 0b34c148..113dc6f7 100644 --- a/src/assets/javascripts/general.js +++ b/src/assets/javascripts/general.js @@ -32,6 +32,7 @@ async function initDefaults() { firstPartyIsolate: false, protocol: "normal", protocolFallback: true, + latencyThreshold: 1000 }, () => resolve() ) diff --git a/src/assets/javascripts/imdb.js b/src/assets/javascripts/imdb.js index 9981f1b9..1f6c7a5f 100644 --- a/src/assets/javascripts/imdb.js +++ b/src/assets/javascripts/imdb.js @@ -17,10 +17,10 @@ for (let i = 0; i < frontends.length; i++) { } function setRedirects(val) { - browser.storage.local.get("cloudflareBlackList", r => { + browser.storage.local.get(["cloudflareBlackList", "offlineBlackList"], r => { redirects.libremdb = val libremdbNormalRedirectsChecks = [...redirects.libremdb.normal] - for (const instance of r.cloudflareBlackList) { + for (const instance of [...r.cloudflareBlackList, ...r.offlineBlackList]) { const a = libremdbNormalRedirectsChecks.indexOf(instance) if (a > -1) libremdbNormalRedirectsChecks.splice(a, 1) } @@ -172,12 +172,18 @@ function initDefaults() { for (let i = 0; i < frontends.length; i++) { redirects[frontends[i]] = dataJson[frontends[i]] } + browser.storage.local.get(["cloudflareBlackList", "offlineBlackList"], async r => { + libremdbNormalRedirectsChecks = [...redirects.libremdb.normal] + for (const instance of [...r.cloudflareBlackList, ...r.offlineBlackList]) { + const a = libremdbNormalRedirectsChecks.indexOf(instance) + if (a > -1) libremdbNormalRedirectsChecks.splice(a, 1) + } browser.storage.local.set( { disableImdb: true, imdbRedirects: redirects, - libremdbNormalRedirectsChecks: [...redirects.libremdb.normal], + libremdbNormalRedirectsChecks, libremdbNormalCustomRedirects: [], libremdbTorRedirectsChecks: [...redirects.libremdb.tor], @@ -192,6 +198,7 @@ function initDefaults() { () => resolve() ) }) + }) }) } diff --git a/src/assets/javascripts/imgur.js b/src/assets/javascripts/imgur.js index 9ccd24af..25f61f06 100644 --- a/src/assets/javascripts/imgur.js +++ b/src/assets/javascripts/imgur.js @@ -16,39 +16,18 @@ for (let i = 0; i < frontends.length; i++) { } } -function setRedirects() { - return new Promise(resolve => { - fetch("/instances/data.json") - .then(response => response.text()) - .then(async data => { - let dataJson = JSON.parse(data) - redirects.rimgo = dataJson.rimgo - - rimgoNormalRedirectsChecks = [...redirects.rimgo.normal] - rimgoTorRedirectsChecks = [...redirects.rimgo.tor] - rimgoI2pRedirectsChecks = [...redirects.rimgo.i2p] - - for (const instance of r.cloudflareBlackList) { - const a = rimgoNormalRedirectsChecks.indexOf(instance) - if (a > -1) rimgoNormalRedirectsChecks.splice(a, 1) - - const b = rimgoTorRedirectsChecks.indexOf(instance) - if (b > -1) rimgoTorRedirectsChecks.splice(b, 1) - - const c = rimgoI2pRedirectsChecks.indexOf(instance) - if (c > -1) rimgoI2pRedirectsChecks.splice(c, 1) - } - - browser.storage.local.set( - { - imgurRedirects: redirects, - rimgoNormalRedirectsChecks, - rimgoTorRedirectsChecks, - rimgoI2pRedirectsChecks, - }, - () => resolve() - ) - }) +function setRedirects(val) { + browser.storage.local.get(["cloudflareBlackList", "offlineBlackList"], r => { + redirects.rimgo = val + rimgoNormalRedirectsChecks = [...redirects.rimgo.normal] + for (const instance of [...r.cloudflareBlackList, ...r.offlineBlackList]) { + const a = rimgoNormalRedirectsChecks.indexOf(instance) + if (a > -1) rimgoNormalRedirectsChecks.splice(a, 1) + } + browser.storage.local.set({ + imgurRedirects: redirects, + rimgoNormalRedirectsChecks, + }) }) } @@ -195,12 +174,12 @@ function initDefaults() { 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) { - const i = rimgoNormalRedirectsChecks.indexOf(instance) - if (i > -1) rimgoNormalRedirectsChecks.splice(i, 1) - } + browser.storage.local.get(["cloudflareBlackList", "offlineBlackList"], async r => { + rimgoNormalRedirectsChecks = [...redirects.rimgo.normal] + for (const instance of [...r.cloudflareBlackList, ...r.offlineBlackList]) { + const a = rimgoNormalRedirectsChecks.indexOf(instance) + if (a > -1) rimgoNormalRedirectsChecks.splice(a, 1) + } browser.storage.local.set( { disableImgur: false, diff --git a/src/assets/javascripts/instagram.js b/src/assets/javascripts/instagram.js index 00042074..a65dac80 100644 --- a/src/assets/javascripts/instagram.js +++ b/src/assets/javascripts/instagram.js @@ -16,10 +16,10 @@ for (let i = 0; i < frontends.length; i++) { } function setRedirects(val) { - browser.storage.local.get("cloudflareBlackList", async r => { + browser.storage.local.get(["cloudflareBlackList", "offlineBlackList"], async r => { redirects.bibliogram = val bibliogramNormalRedirectsChecks = [...redirects.bibliogram.normal] - for (const instance of r.cloudflareBlackList) { + for (const instance of [...r.cloudflareBlackList, ...r.offlineBlackList]) { const a = bibliogramNormalRedirectsChecks.indexOf(instance) if (a > -1) bibliogramNormalRedirectsChecks.splice(a, 1) } @@ -203,17 +203,17 @@ function initDefaults() { 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) { - const i = bibliogramNormalRedirectsChecks.indexOf(instance) - if (i > -1) bibliogramNormalRedirectsChecks.splice(i, 1) - } + browser.storage.local.get(["cloudflareBlackList", "offlineBlackList"], async r => { + bibliogramNormalRedirectsChecks = [...redirects.bibliogram.normal] + for (const instance of [...r.cloudflareBlackList, ...r.offlineBlackList]) { + const a = bibliogramNormalRedirectsChecks.indexOf(instance) + if (a > -1) bibliogramNormalRedirectsChecks.splice(a, 1) + } browser.storage.local.set({ disableInstagram: false, instagramRedirects: redirects, - bibliogramNormalRedirectsChecks: bibliogramNormalRedirectsChecks, + bibliogramNormalRedirectsChecks, bibliogramNormalCustomRedirects: [], bibliogramTorRedirectsChecks: [...redirects.bibliogram.tor], diff --git a/src/assets/javascripts/lbry.js b/src/assets/javascripts/lbry.js index 0c4d34cc..b1e6f477 100644 --- a/src/assets/javascripts/lbry.js +++ b/src/assets/javascripts/lbry.js @@ -17,10 +17,10 @@ for (let i = 0; i < frontends.length; i++) { } function setRedirects(val) { - browser.storage.local.get("cloudflareBlackList", r => { + browser.storage.local.get(["cloudflareBlackList", "offlineBlackList"], r => { redirects.librarian = val librarianNormalRedirectsChecks = [...redirects.librarian.normal] - for (const instance of r.cloudflareBlackList) { + for (const instance of [...r.cloudflareBlackList, ...r.offlineBlackList]) { const a = librarianNormalRedirectsChecks.indexOf(instance) if (a > -1) librarianNormalRedirectsChecks.splice(a, 1) } @@ -175,6 +175,12 @@ function initDefaults() { for (let i = 0; i < frontends.length; i++) { redirects[frontends[i]] = dataJson[frontends[i]] } + browser.storage.local.get(["cloudflareBlackList", "offlineBlackList"], async r => { + librarianNormalRedirectsChecks = [...redirects.librarian.normal] + for (const instance of [...r.cloudflareBlackList, ...r.offlineBlackList]) { + const a = librarianNormalRedirectsChecks.indexOf(instance) + if (a > -1) librarianNormalRedirectsChecks.splice(a, 1) + } browser.storage.local.set( { disableLbryTargets: true, @@ -182,7 +188,7 @@ function initDefaults() { lbryTargetsRedirects: redirects, lbryRedirectType: "both", - librarianNormalRedirectsChecks: [...redirects.librarian.normal], + librarianNormalRedirectsChecks, librarianNormalCustomRedirects: [], librarianTorRedirectsChecks: [...redirects.librarian.tor], @@ -197,6 +203,7 @@ function initDefaults() { () => resolve() ) }) + }) }) } diff --git a/src/assets/javascripts/maps.js b/src/assets/javascripts/maps.js index 9fb10b9d..6627faff 100644 --- a/src/assets/javascripts/maps.js +++ b/src/assets/javascripts/maps.js @@ -21,10 +21,10 @@ redirects.osm = {} redirects.osm.normal = ["https://www.openstreetmap.org"] function setRedirects(val) { - browser.storage.local.get("cloudflareBlackList", r => { + browser.storage.local.get(["cloudflareBlackList", "offlineBlackList"], r => { redirects.facil = val facilNormalRedirectsChecks = [...redirects.facil.normal] - for (const instance of r.cloudflareBlackList) { + for (const instance of [...r.cloudflareBlackList, ...r.offlineBlackList]) { const a = facilNormalRedirectsChecks.indexOf(instance) if (a > -1) facilNormalRedirectsChecks.splice(a, 1) } @@ -264,12 +264,18 @@ function initDefaults() { for (let i = 0; i < frontends.length; i++) { redirects[frontends[i]] = dataJson[frontends[i]] } + browser.storage.local.get(["cloudflareBlackList", "offlineBlackList"], async r => { + facilNormalRedirectsChecks = [...redirects.facil.normal] + for (const instance of [...r.cloudflareBlackList, ...r.offlineBlackList]) { + const a = facilNormalRedirectsChecks.indexOf(instance) + if (a > -1) facilNormalRedirectsChecks.splice(a, 1) + } browser.storage.local.set( { disableMaps: false, mapsFrontend: "osm", mapsRedirects: redirects, - facilNormalRedirectsChecks: [...redirects.facil.normal], + facilNormalRedirectsChecks, facilNormalCustomRedirects: [], facilTorRedirectsChecks: [...redirects.facil.tor], @@ -284,6 +290,7 @@ function initDefaults() { () => resolve() ) }) + }) }) } diff --git a/src/assets/javascripts/medium.js b/src/assets/javascripts/medium.js index 4c03471c..f1dcf2e2 100644 --- a/src/assets/javascripts/medium.js +++ b/src/assets/javascripts/medium.js @@ -40,10 +40,10 @@ for (let i = 0; i < frontends.length; i++) { } function setRedirects(val) { - browser.storage.local.get("cloudflareBlackList", r => { + browser.storage.local.get(["cloudflareBlackList", "offlineBlackList"], r => { redirects.scribe = val scribeNormalRedirectsChecks = [...redirects.scribe.normal] - for (const instance of r.cloudflareBlackList) { + for (const instance of [...r.cloudflareBlackList, ...r.offlineBlackList]) { const a = scribeNormalRedirectsChecks.indexOf(instance) if (a > -1) scribeNormalRedirectsChecks.splice(a, 1) } @@ -181,18 +181,18 @@ function initDefaults() { 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] - for (const instance of r.cloudflareBlackList) { - let i = scribeNormalRedirectsChecks.indexOf(instance) - if (i > -1) scribeNormalRedirectsChecks.splice(i, 1) - } + browser.storage.local.get(["cloudflareBlackList", "offlineBlackList"], async r => { + scribeNormalRedirectsChecks = [...redirects.scribe.normal] + for (const instance of [...r.cloudflareBlackList, ...r.offlineBlackList]) { + const a = scribeNormalRedirectsChecks.indexOf(instance) + if (a > -1) scribeNormalRedirectsChecks.splice(a, 1) + } browser.storage.local.set( { disableMedium: false, mediumRedirects: redirects, - scribeNormalRedirectsChecks: scribeNormalRedirectsChecks, + scribeNormalRedirectsChecks, scribeNormalCustomRedirects: [], scribeTorRedirectsChecks: [...redirects.scribe.tor], diff --git a/src/assets/javascripts/peertube.js b/src/assets/javascripts/peertube.js index de25cfaa..df95611c 100644 --- a/src/assets/javascripts/peertube.js +++ b/src/assets/javascripts/peertube.js @@ -15,10 +15,10 @@ for (let i = 0; i < frontends.length; i++) { } function setRedirects(val) { - browser.storage.local.get("cloudflareBlackList", r => { + browser.storage.local.get(["cloudflareBlackList", "offlineBlackList"], r => { redirects.simpleertube = val simpleertubeNormalRedirectsChecks = [...redirects.simpleertube.normal] - for (const instance of r.cloudflareBlackList) { + for (const instance of [...r.cloudflareBlackList, ...r.offlineBlackList]) { const a = simpleertubeNormalRedirectsChecks.indexOf(instance) if (a > -1) simpleertubeNormalRedirectsChecks.splice(a, 1) } @@ -162,19 +162,19 @@ function initDefaults() { for (let i = 0; i < frontends.length; i++) { redirects[frontends[i]] = dataJson[frontends[i]] } - browser.storage.local.get("cloudflareBlackList", async r => { - simpleertubeNormalRedirectsChecks = [...redirects.simpleertube.normal] - for (const instance of r.cloudflareBlackList) { - let i = simpleertubeNormalRedirectsChecks.indexOf(instance) - if (i > -1) simpleertubeNormalRedirectsChecks.splice(i, 1) - } + browser.storage.local.get(["cloudflareBlackList", "offlineBlackList"], async r => { + simpleertubeNormalRedirectsChecks = [...redirects.simpleertube.normal] + for (const instance of [...r.cloudflareBlackList, ...r.offlineBlackList]) { + const a = simpleertubeNormalRedirectsChecks.indexOf(instance) + if (a > -1) simpleertubeNormalRedirectsChecks.splice(a, 1) + } browser.storage.local.set( { peerTubeTargets: ["https://search.joinpeertube.org", ...dataJson.peertube], disablePeertubeTargets: true, peertubeRedirects: redirects, - simpleertubeNormalRedirectsChecks: simpleertubeNormalRedirectsChecks, + simpleertubeNormalRedirectsChecks, simpleertubeNormalCustomRedirects: [], simpleertubeTorRedirectsChecks: [...redirects.simpleertube.tor], diff --git a/src/assets/javascripts/quora.js b/src/assets/javascripts/quora.js index 3f9e4189..4d8249f8 100644 --- a/src/assets/javascripts/quora.js +++ b/src/assets/javascripts/quora.js @@ -17,10 +17,10 @@ for (let i = 0; i < frontends.length; i++) { } function setRedirects(val) { - browser.storage.local.get("cloudflareBlackList", r => { + browser.storage.local.get(["cloudflareBlackList", "offlineBlackList"], r => { redirects.quetre = val quetreNormalRedirectsChecks = [...redirects.quetre.normal] - for (const instance of r.cloudflareBlackList) { + for (const instance of [...r.cloudflareBlackList, ...r.offlineBlackList]) { const a = quetreNormalRedirectsChecks.indexOf(instance) if (a > -1) quetreNormalRedirectsChecks.splice(a, 1) } @@ -157,13 +157,19 @@ function initDefaults() { for (let i = 0; i < frontends.length; i++) { redirects[frontends[i]] = dataJson[frontends[i]] } + browser.storage.local.get(["cloudflareBlackList", "offlineBlackList"], async r => { + quetreNormalRedirectsChecks = [...redirects.quetre.normal] + for (const instance of [...r.cloudflareBlackList, ...r.offlineBlackList]) { + const a = quetreNormalRedirectsChecks.indexOf(instance) + if (a > -1) quetreNormalRedirectsChecks.splice(a, 1) + } browser.storage.local.set( { disableQuora: false, quoraRedirects: redirects, - quetreNormalRedirectsChecks: [...redirects.quetre.normal], + quetreNormalRedirectsChecks, quetreNormalCustomRedirects: [], quetreTorRedirectsChecks: [...redirects.quetre.tor], @@ -178,6 +184,7 @@ function initDefaults() { () => resolve() ) }) + }) }) } diff --git a/src/assets/javascripts/reddit.js b/src/assets/javascripts/reddit.js index d1bf7b99..2a07dffb 100644 --- a/src/assets/javascripts/reddit.js +++ b/src/assets/javascripts/reddit.js @@ -16,11 +16,11 @@ for (let i = 0; i < frontends.length; i++) { } function setRedirects(val) { - browser.storage.local.get("cloudflareBlackList", r => { + browser.storage.local.get(["cloudflareBlackList", "offlineBlackList"], r => { redirects = val libredditNormalRedirectsChecks = [...redirects.libreddit.normal] tedditNormalRedirectsChecks = [...redirects.teddit.normal] - for (const instance of r.cloudflareBlackList) { + for (const instance of [...r.cloudflareBlackList, ...r.offlineBlackList]) { const a = libredditNormalRedirectsChecks.indexOf(instance) if (a > -1) libredditNormalRedirectsChecks.splice(a, 1) @@ -330,25 +330,23 @@ function initDefaults() { 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] - for (const instance of r.cloudflareBlackList) { - let i - - i = libredditNormalRedirectsChecks.indexOf(instance) - if (i > -1) libredditNormalRedirectsChecks.splice(i, 1) - - i = tedditNormalRedirectsChecks.indexOf(instance) - if (i > -1) tedditNormalRedirectsChecks.splice(i, 1) - } + browser.storage.local.get(["cloudflareBlackList", "offlineBlackList"], async r => { + libredditNormalRedirectsChecks = [...redirects.libreddit.normal] + tedditNormalRedirectsChecks = [...redirects.teddit.normal] + for (const instance of [...r.cloudflareBlackList, ...r.offlineBlackList]) { + const a = libredditNormalRedirectsChecks.indexOf(instance) + if (a > -1) libredditNormalRedirectsChecks.splice(a, 1) + + const b = tedditNormalRedirectsChecks.indexOf(instance) + if (b > -1) tedditNormalRedirectsChecks.splice(b, 1) + } browser.storage.local.set( { disableReddit: false, redditFrontend: "libreddit", redditRedirects: redirects, - libredditNormalRedirectsChecks: libredditNormalRedirectsChecks, + libredditNormalRedirectsChecks, libredditNormalCustomRedirects: [], libredditTorRedirectsChecks: [...redirects.libreddit.tor], @@ -360,7 +358,7 @@ function initDefaults() { libredditLokiRedirectsChecks: [...redirects.libreddit.loki], libredditLokiCustomRedirects: [], - tedditNormalRedirectsChecks: tedditNormalRedirectsChecks, + tedditNormalRedirectsChecks, tedditNormalCustomRedirects: [], tedditTorRedirectsChecks: [...redirects.teddit.tor], diff --git a/src/assets/javascripts/reuters.js b/src/assets/javascripts/reuters.js index e4afa19c..78f5077b 100644 --- a/src/assets/javascripts/reuters.js +++ b/src/assets/javascripts/reuters.js @@ -17,10 +17,10 @@ for (let i = 0; i < frontends.length; i++) { } function setRedirects(val) { - browser.storage.local.get("cloudflareBlackList", r => { + browser.storage.local.get(["cloudflareBlackList", "offlineBlackList"], r => { redirects.neuters = val neutersNormalRedirectsChecks = [...redirects.neuters.normal] - for (const instance of r.cloudflareBlackList) { + for (const instance of [...r.cloudflareBlackList, ...r.offlineBlackList]) { const a = neutersNormalRedirectsChecks.indexOf(instance) if (a > -1) neutersNormalRedirectsChecks.splice(a, 1) } @@ -109,13 +109,19 @@ function initDefaults() { for (let i = 0; i < frontends.length; i++) { redirects[frontends[i]] = dataJson[frontends[i]] } + browser.storage.local.get(["cloudflareBlackList", "offlineBlackList"], async r => { + neutersNormalRedirectsChecks = [...redirects.neuters.normal] + for (const instance of [...r.cloudflareBlackList, ...r.offlineBlackList]) { + const a = neutersNormalRedirectsChecks.indexOf(instance) + if (a > -1) neutersNormalRedirectsChecks.splice(a, 1) + } browser.storage.local.set( { disableReuters: true, reutersRedirects: redirects, - neutersNormalRedirectsChecks: [...redirects.neuters.normal], + neutersNormalRedirectsChecks, neutersNormalCustomRedirects: [], neutersTorRedirectsChecks: [...redirects.neuters.tor], @@ -130,6 +136,7 @@ function initDefaults() { () => resolve() ) }) + }) }) } diff --git a/src/assets/javascripts/search.js b/src/assets/javascripts/search.js index 2a5f4867..04b5b8d4 100644 --- a/src/assets/javascripts/search.js +++ b/src/assets/javascripts/search.js @@ -8,52 +8,22 @@ const frontends = new Array("searx", "searxng", "whoogle", "librex") const protocols = new Array("normal", "tor", "i2p", "loki") const redirects = {} -/* - "searx": { - "normal": [], - "tor": [], - "i2p": [] - }, - "searxng": { - "normal": [], - "tor": [], - "i2p": [] - }, - "whoogle": { - "normal": [], - "tor": [], - "i2p": [] - } - */ -//}; - -//let tmp = "{" for (let i = 0; i < frontends.length; i++) { - //redirects.frontends[i] = {} - //redirects.push(frontends[i]) - //tmp = frontends[i] - //tmp = tmp + '\n"' + frontends[i] + '": {' redirects[frontends[i]] = {} for (let x = 0; x < protocols.length; x++) { - //redirects.frontends[i].protocols = [] - //tmp = tmp + '\n"' + protocols[x] + '": [],' redirects[frontends[i]][protocols[x]] = [] } - //tmp = tmp + "\n}," } -//tmp = tmp + "\n}" - -//const redirects = JSON.parse(tmp) function setRedirects(val) { - browser.storage.local.get("cloudflareBlackList", r => { + browser.storage.local.get(["cloudflareBlackList", "offlineBlackList"], r => { redirects = val searxNormalRedirectsChecks = [...redirects.searx.normal] searxngNormalRedirectsChecks = [...redirects.searxng.normal] whoogleNormalRedirectsChecks = [...redirects.whoogle.normal] librexNormalRedirectsChecks = [...redirects.librex.normal] - for (const instance of r.cloudflareBlackList) { + for (const instance of [...r.cloudflareBlackList, ...r.offlineBlackList]) { const a = searxNormalRedirectsChecks.indexOf(instance) if (a > -1) searxNormalRedirectsChecks.splice(a, 1) @@ -499,35 +469,28 @@ function initDefaults() { .then(response => response.text()) .then(async data => { let dataJson = JSON.parse(data) - /* - redirects.searx = dataJson.searx; - redirects.searxng = dataJson.searxng; - redirects.whoogle = dataJson.whoogle; - */ for (let i = 0; i < frontends.length; i++) { redirects[frontends[i]] = dataJson[frontends[i]] } - browser.storage.local.get("cloudflareBlackList", async r => { - whoogleNormalRedirectsChecks = [...redirects.whoogle.normal] - searxNormalRedirectsChecks = [...redirects.searx.normal] - searxngNormalRedirectsChecks = [...redirects.searxng.normal] - librexNormalRedirectsChecks = [...redirects.librex.normal] - for (const instance of r.cloudflareBlackList) { - let i - - i = whoogleNormalRedirectsChecks.indexOf(instance) - if (i > -1) whoogleNormalRedirectsChecks.splice(i, 1) + browser.storage.local.get(["cloudflareBlackList", "offlineBlackList"], async r => { + searxNormalRedirectsChecks = [...redirects.searx.normal] + searxngNormalRedirectsChecks = [...redirects.searxng.normal] + whoogleNormalRedirectsChecks = [...redirects.whoogle.normal] + librexNormalRedirectsChecks = [...redirects.librex.normal] + for (const instance of [...r.cloudflareBlackList, ...r.offlineBlackList]) { + const a = searxNormalRedirectsChecks.indexOf(instance) + if (a > -1) searxNormalRedirectsChecks.splice(a, 1) - i = searxNormalRedirectsChecks.indexOf(instance) - if (i > -1) searxNormalRedirectsChecks.splice(i, 1) + const b = searxngNormalRedirectsChecks.indexOf(instance) + if (b > -1) searxngNormalRedirectsChecks.splice(b, 1) - i = searxngNormalRedirectsChecks.indexOf(instance) - if (i > -1) searxngNormalRedirectsChecks.splice(i, 1) + const c = whoogleNormalRedirectsChecks.indexOf(instance) + if (c > -1) whoogleNormalRedirectsChecks.splice(c, 1) - i = librexNormalRedirectsChecks.indexOf(instance) - if (i > -1) librexNormalRedirectsChecks.splice(i, 1) - } + const d = librexNormalRedirectsChecks.indexOf(instance) + if (d > -1) librexNormalRedirectsChecks.splice(d, 1) + } browser.storage.local.set( { disableSearch: false, @@ -535,7 +498,7 @@ function initDefaults() { searchRedirects: redirects, searxngCustomSettings: false, - whoogleNormalRedirectsChecks: whoogleNormalRedirectsChecks, + whoogleNormalRedirectsChecks, whoogleNormalCustomRedirects: [], whoogleTorRedirectsChecks: [...redirects.whoogle.tor], @@ -547,7 +510,7 @@ function initDefaults() { whoogleLokiRedirectsChecks: [...redirects.whoogle.loki], whoogleLokiCustomRedirects: [], - searxNormalRedirectsChecks: searxNormalRedirectsChecks, + searxNormalRedirectsChecks, searxNormalCustomRedirects: [], searxTorRedirectsChecks: [...redirects.searx.tor], @@ -559,7 +522,7 @@ function initDefaults() { searxLokiRedirectsChecks: [...redirects.searx.loki], searxLokiCustomRedirects: [], - searxngNormalRedirectsChecks: searxngNormalRedirectsChecks, + searxngNormalRedirectsChecks, searxngNormalCustomRedirects: [], searxngTorRedirectsChecks: [...redirects.searxng.tor], @@ -571,7 +534,7 @@ function initDefaults() { searxngLokiRedirectsChecks: [...redirects.searxng.loki], searxngLokiCustomRedirects: [], - librexNormalRedirectsChecks: librexNormalRedirectsChecks, + librexNormalRedirectsChecks, librexNormalCustomRedirects: [], librexTorRedirectsChecks: [...redirects.librex.tor], diff --git a/src/assets/javascripts/sendTargets.js b/src/assets/javascripts/sendTargets.js index ba892fe3..c9ddfe2d 100644 --- a/src/assets/javascripts/sendTargets.js +++ b/src/assets/javascripts/sendTargets.js @@ -17,10 +17,10 @@ for (let i = 0; i < frontends.length; i++) { } function setRedirects(val) { - browser.storage.local.get("cloudflareBlackList", r => { + browser.storage.local.get(["cloudflareBlackList", "offlineBlackList"], r => { redirects.send = val sendNormalRedirectsChecks = [...redirects.send.normal] - for (const instance of r.cloudflareBlackList) { + for (const instance of [...r.cloudflareBlackList, ...r.offlineBlackList]) { const a = sendNormalRedirectsChecks.indexOf(instance) if (a > -1) sendNormalRedirectsChecks.splice(a, 1) } @@ -154,18 +154,18 @@ function initDefaults() { 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) { - let i = sendNormalRedirectsChecks.indexOf(instance) - if (i > -1) sendNormalRedirectsChecks.splice(i, 1) - } + browser.storage.local.get(["cloudflareBlackList", "offlineBlackList"], async r => { + sendNormalRedirectsChecks = [...redirects.send.normal] + for (const instance of [...r.cloudflareBlackList, ...r.offlineBlackList]) { + const a = sendNormalRedirectsChecks.indexOf(instance) + if (a > -1) sendNormalRedirectsChecks.splice(a, 1) + } browser.storage.local.set( { disableSendTarget: false, sendTargetsRedirects: redirects, - sendNormalRedirectsChecks: sendNormalRedirectsChecks, + sendNormalRedirectsChecks, sendNormalCustomRedirects: [], sendTorRedirectsChecks: [...redirects.send.tor], diff --git a/src/assets/javascripts/tiktok.js b/src/assets/javascripts/tiktok.js index 9d2660d4..b7987422 100644 --- a/src/assets/javascripts/tiktok.js +++ b/src/assets/javascripts/tiktok.js @@ -17,10 +17,10 @@ for (let i = 0; i < frontends.length; i++) { } function setRedirects(val) { - browser.storage.local.get("cloudflareBlackList", r => { + browser.storage.local.get(["cloudflareBlackList", "offlineBlackList"], r => { redirects.proxiTok = val proxiTokNormalRedirectsChecks = [...redirects.proxiTok.normal] - for (const instance of r.cloudflareBlackList) { + for (const instance of [...r.cloudflareBlackList, ...r.offlineBlackList]) { const a = proxiTokNormalRedirectsChecks.indexOf(instance) if (a > -1) proxiTokNormalRedirectsChecks.splice(a, 1) } @@ -202,13 +202,20 @@ function initDefaults() { for (let i = 0; i < frontends.length; i++) { redirects[frontends[i]] = dataJson[frontends[i]] } + browser.storage.local.get(["cloudflareBlackList", "offlineBlackList"], async r => { + proxiTokNormalRedirectsChecks = [...redirects.proxiTok.normal] + console.log(r) + for (const instance of [...r.cloudflareBlackList, ...r.offlineBlackList]) { + const a = proxiTokNormalRedirectsChecks.indexOf(instance) + if (a > -1) proxiTokNormalRedirectsChecks.splice(a, 1) + } browser.storage.local.set( { disableTiktok: false, tiktokRedirects: redirects, - proxiTokNormalRedirectsChecks: [...redirects.proxiTok.normal], + proxiTokNormalRedirectsChecks, proxiTokNormalCustomRedirects: [], proxiTokTorRedirectsChecks: [...redirects.proxiTok.tor], @@ -223,6 +230,7 @@ function initDefaults() { () => resolve() ) }) + }) }) } diff --git a/src/assets/javascripts/translate/translate.js b/src/assets/javascripts/translate/translate.js index 893be4e2..8da81d10 100644 --- a/src/assets/javascripts/translate/translate.js +++ b/src/assets/javascripts/translate/translate.js @@ -91,21 +91,21 @@ init() browser.storage.onChanged.addListener(init) function setRedirects(val) { - browser.storage.local.get("cloudflareBlackList", r => { + browser.storage.local.get(["cloudflareBlackList", "offlineBlackList"], r => { redirects = val + simplyTranslateNormalRedirectsChecks = [...redirects.simplyTranslate.normal] lingvaNormalRedirectsChecks = [...redirects.lingva.normal] - for (const instance of r.cloudflareBlackList) { + for (const instance of [...r.cloudflareBlackList, ...r.offlineBlackList]) { + const a = simplyTranslateNormalCustomRedirects.indexOf(instance) + if (a > -1) simplyTranslateNormalCustomRedirects.splice(a, 1) + const i = lingvaNormalRedirectsChecks.indexOf(instance) if (i > -1) lingvaNormalRedirectsChecks.splice(i, 1) } browser.storage.local.set({ translateRedirects: redirects, - simplyTranslateNormalRedirectsChecks: redirects.simplyTranslate.normal, - simplyTranslateTorRedirectsChecks: redirects.simplyTranslate.tor, - simplyTranslateI2pRedirectsChecks: redirects.simplyTranslate.i2p, - simplyTranslateLokiRedirectsChecks: redirects.simplyTranslate.loki, + simplyTranslateNormalRedirectsChecks, lingvaNormalRedirectsChecks, - lingvaTorRedirectsChecks: redirects.lingva.tor, }) }) } @@ -271,7 +271,7 @@ function switchInstance(url, disableOverride) { return } - let instancesList + let instancesList = [] if (protocol == "loki") { if (translateFrontend == "simplyTranslate") instancesList = [...simplyTranslateLokiRedirectsChecks, ...simplyTranslateLokiCustomRedirects] @@ -309,19 +309,24 @@ function initDefaults() { 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] - for (const instance of r.cloudflareBlackList) { - const i = lingvaNormalRedirectsChecks.indexOf(instance) - if (i > -1) lingvaNormalRedirectsChecks.splice(i, 1) - } + browser.storage.local.get(["cloudflareBlackList", "offlineBlackList"], async r => { + simplyTranslateNormalCustomRedirects = [...redirects.simplyTranslate.normal] + lingvaNormalRedirectsChecks = [...redirects.lingva.normal] + console.log(r.offlineBlackList) + for (const instance of [...r.cloudflareBlackList, ...r.offlineBlackList]) { + const a = simplyTranslateNormalCustomRedirects.indexOf(instance) + if (a > -1) simplyTranslateNormalCustomRedirects.splice(a, 1) + + const b = lingvaNormalRedirectsChecks.indexOf(instance) + if (b > -1) lingvaNormalRedirectsChecks.splice(b, 1) + } browser.storage.local.set( { translateDisable: false, translateFrontend: "simplyTranslate", translateRedirects: redirects, - simplyTranslateNormalRedirectsChecks: [...redirects.simplyTranslate.normal], + simplyTranslateNormalRedirectsChecks, simplyTranslateNormalCustomRedirects: [], simplyTranslateTorRedirectsChecks: [...redirects.simplyTranslate.tor], @@ -333,7 +338,7 @@ function initDefaults() { simplyTranslateLokiRedirectsChecks: [...redirects.simplyTranslate.loki], simplyTranslateLokiCustomRedirects: [], - lingvaNormalRedirectsChecks: lingvaNormalRedirectsChecks, + lingvaNormalRedirectsChecks, lingvaNormalCustomRedirects: [], lingvaTorRedirectsChecks: [...redirects.lingva.tor], diff --git a/src/assets/javascripts/twitter.js b/src/assets/javascripts/twitter.js index b3c33560..83a9685d 100644 --- a/src/assets/javascripts/twitter.js +++ b/src/assets/javascripts/twitter.js @@ -17,17 +17,16 @@ for (let i = 0; i < frontends.length; i++) { } function setRedirects(val) { - browser.storage.local.get(["cloudflareBlackList", "authenticateBlackList"], r => { + browser.storage.local.get(["cloudflareBlackList", "authenticateBlackList", "offlineBlackList"], r => { redirects.nitter = val nitterNormalRedirectsChecks = [...redirects.nitter.normal] - for (const instance of [...r.cloudflareBlackList, ...r.authenticateBlackList]) { + for (const instance of [...r.cloudflareBlackList, ...r.authenticateBlackList, ...r.offlineBlackList]) { let i = nitterNormalRedirectsChecks.indexOf(instance) if (i > -1) nitterNormalRedirectsChecks.splice(i, 1) } browser.storage.local.set({ twitterRedirects: redirects, nitterNormalRedirectsChecks, - nitterTorRedirectsChecks: [...redirects.nitter.tor], }) }) } @@ -224,19 +223,19 @@ function initDefaults() { 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]) { - let i = nitterNormalRedirectsChecks.indexOf(instance) - if (i > -1) nitterNormalRedirectsChecks.splice(i, 1) - } + browser.storage.local.get(["cloudflareBlackList", "authenticateBlackList", "offlineBlackList"], async r => { + nitterNormalRedirectsChecks = [...redirects.nitter.normal] + for (const instance of [...r.cloudflareBlackList, ...r.authenticateBlackList, ...r.offlineBlackList]) { + let i = nitterNormalRedirectsChecks.indexOf(instance) + if (i > -1) nitterNormalRedirectsChecks.splice(i, 1) + } browser.storage.local.set( { disableTwitter: false, twitterRedirects: redirects, twitterRedirectType: "both", - nitterNormalRedirectsChecks: nitterNormalRedirectsChecks, + nitterNormalRedirectsChecks, nitterNormalCustomRedirects: [], nitterTorRedirectsChecks: [...redirects.nitter.tor], @@ -251,7 +250,7 @@ function initDefaults() { () => resolve() ) }) - }) +}) }) } diff --git a/src/assets/javascripts/utils.js b/src/assets/javascripts/utils.js index e9a30400..c6cecc05 100644 --- a/src/assets/javascripts/utils.js +++ b/src/assets/javascripts/utils.js @@ -25,7 +25,7 @@ function getRandomInstance(instances) { let cloudflareBlackList = [] let authenticateBlackList = [] -let offlineBlacklist = [] +let offlineBlackList = [] async function initBlackList() { return new Promise(resolve => { fetch("/instances/blacklist.json") @@ -33,7 +33,7 @@ async function initBlackList() { .then(data => { cloudflareBlackList = JSON.parse(data).cloudflare authenticateBlackList = JSON.parse(data).authenticate - offlineBlacklist = JSON.parse(data).offlineBlacklist + offlineBlackList = JSON.parse(data).offline resolve() }) }) @@ -62,6 +62,7 @@ function updateInstances() { invidious: instances.invidious, piped: instances.piped, pipedMaterial: instances.pipedMaterial, + cloudtube: instances.cloudtube }) twitterHelper.setRedirects(instances.nitter) instagramHelper.setRedirects(instances.bibliogram) @@ -164,7 +165,7 @@ async function processDefaultCustomInstances(target, name, protocol, document) { ...redirects[name][protocol].map(x => { const cloudflare = cloudflareBlackList.includes(x) ? ' <span style="color:red;">cloudflare</span>' : "" const authenticate = authenticateBlackList.includes(x) ? ' <span style="color:orange;">authenticate</span>' : "" - const offline = offlineBlacklist.includes(x) ? ' <span style="color:grey;">offline</span>' : "" + const offline = offlineBlackList.includes(x) ? ' <span style="color:grey;">offline</span>' : "" let ms = instancesLatency[x] let latencyColor = ms <= 1000 ? "green" : ms <= 2000 ? "orange" : "red" @@ -250,34 +251,57 @@ async function processDefaultCustomInstances(target, name, protocol, document) { }) } -async function ping(href) { +function ping(href) { return new Promise(async resolve => { + let average = 0 + let time + for (let i = 0; i < 3; i++) { + time = await pingOnce(href) + if (i == 0) continue + if (time >= 5000) { + resolve(time) + return + } + average += time + } + average = parseInt(average / 3) + resolve(average) + }) +} + +function pingOnce(href) { + return new Promise(async resolve => { + let started let http = new XMLHttpRequest() - http.open("GET", `${href}?_=${new Date().getTime()}`, /*async*/ true) http.timeout = 5000 - let started = new Date().getTime() + http.ontimeout = () => resolve(5000) + http.onerror = () => resolve() http.onreadystatechange = () => { if (http.readyState == 2) { if (http.status == 200) { let ended = new Date().getTime() http.abort() resolve(ended - started) - } else resolve(5000 + http.status) + } else { + resolve(5000 + http.status) + } } } - http.ontimeout = () => resolve(5000) - http.onerror = () => resolve() - try { - http.send(null) - } catch (exception) { - resolve() - } + http.open("GET", `${href}?_=${new Date().getTime()}`, true) + started = new Date().getTime() + http.send(null) }) } -async function testLatency(element, instances) { +async function testLatency(element, instances, frontend) { return new Promise(async resolve => { let myList = {} + let latencyThreshold + let redirectsChecks = [] + browser.storage.local.get(["latencyThreshold", `${frontend}NormalRedirectsChecks`], r => { + latencyThreshold = r.latencyThreshold + redirectsChecks = r[`${frontend}NormalRedirectsChecks`] + }) for (const href of instances) await ping(href).then(time => { if (time) { @@ -287,6 +311,12 @@ async function testLatency(element, instances) { else if (time <= 2000) color = "orange" else color = "red" + if (time > latencyThreshold) { + redirectsChecks.splice(redirectsChecks.indexOf(href), 1) + } + + browser.storage.local.set({ [`${frontend}NormalRedirectsChecks`]: redirectsChecks }) + let text if (time == 5000) text = "5000ms+" else if (time > 5000) text = `ERROR: ${time - 5000}` @@ -486,8 +516,8 @@ function latency(name, frontend, document, location) { let redirects = r[key] const oldHtml = latencyLabel.innerHTML latencyLabel.innerHTML = "..." - testLatency(latencyLabel, redirects[frontend].normal).then(r => { - browser.storage.local.set({ [`${frontend} Latency`]: r }) + testLatency(latencyLabel, redirects[frontend].normal, frontend).then(r => { + browser.storage.local.set({ [`${frontend}Latency`]: r }) latencyLabel.innerHTML = oldHtml processDefaultCustomInstances(name, frontend, "normal", document) latencyElement.removeEventListener("click", reloadWindow) diff --git a/src/assets/javascripts/wikipedia.js b/src/assets/javascripts/wikipedia.js index 04191d1a..cecb3189 100644 --- a/src/assets/javascripts/wikipedia.js +++ b/src/assets/javascripts/wikipedia.js @@ -17,10 +17,10 @@ for (let i = 0; i < frontends.length; i++) { } function setRedirects(val) { - browser.storage.local.get("cloudflareBlackList", r => { + browser.storage.local.get(["cloudflareBlackList", "offlineBlackList"], r => { redirects.wikiless = val wikilessNormalRedirectsChecks = [...redirects.wikiless.normal] - for (const instance of r.cloudflareBlackList) { + for (const instance of [...r.cloudflareBlackList, ...r.offlineBlackList]) { const a = wikilessNormalRedirectsChecks.indexOf(instance) if (a > -1) wikilessNormalRedirectsChecks.splice(a, 1) } @@ -200,18 +200,18 @@ function initDefaults() { 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) { - let i = wikilessNormalRedirectsChecks.indexOf(instance) - if (i > -1) wikilessNormalRedirectsChecks.splice(i, 1) - } + browser.storage.local.get(["cloudflareBlackList", "offlineBlackList"], async r => { + wikilessNormalRedirectsChecks = [...redirects.wikiless.normal] + for (const instance of [...r.cloudflareBlackList, ...r.offlineBlackList]) { + const a = wikilessNormalRedirectsChecks.indexOf(instance) + if (a > -1) wikilessNormalRedirectsChecks.splice(a, 1) + } browser.storage.local.set( { disableWikipedia: true, wikipediaRedirects: redirects, - wikilessNormalRedirectsChecks: wikilessNormalRedirectsChecks, + wikilessNormalRedirectsChecks, wikilessNormalCustomRedirects: [], wikilessTorRedirectsChecks: [...redirects.wikiless.tor], diff --git a/src/assets/javascripts/youtube/youtube.js b/src/assets/javascripts/youtube/youtube.js index 7e02dcd2..63e58d5b 100644 --- a/src/assets/javascripts/youtube/youtube.js +++ b/src/assets/javascripts/youtube/youtube.js @@ -30,14 +30,13 @@ for (let i = 0; i < frontends.length; i++) { } function setRedirects(val) { - browser.storage.local.get("cloudflareBlackList", r => { - for (let i = 0; i < frontends.length; i++) { - redirects.frontends = val.frontends - } + browser.storage.local.get(["cloudflareBlackList", "offlineBlackList"], r => { + redirects = val invidiousNormalRedirectsChecks = [...redirects.invidious.normal] pipedNormalRedirectsChecks = [...redirects.piped.normal] pipedMaterialNormalRedirectsChecks = [...redirects.pipedMaterial.normal] - for (const instance of r.cloudflareBlackList) { + cloudtubeNormalRedirectsChecks = [...redirects.cloudtube.normal] + for (const instance of [...r.cloudflareBlackList, ...r.offlineBlackList]) { const a = invidiousNormalRedirectsChecks.indexOf(instance) if (a > -1) invidiousNormalRedirectsChecks.splice(a, 1) @@ -450,13 +449,12 @@ function initDefaults() { for (let i = 0; i < frontends.length; i++) { redirects[frontends[i]] = dataJson[frontends[i]] } - browser.storage.local.get("cloudflareBlackList", async r => { + browser.storage.local.get(["cloudflareBlackList", "offlineBlackList"], async r => { invidiousNormalRedirectsChecks = [...redirects.invidious.normal] pipedNormalRedirectsChecks = [...redirects.piped.normal] pipedMaterialNormalRedirectsChecks = [...redirects.pipedMaterial.normal] cloudtubeNormalRedirectsChecks = [...redirects.cloudtube.normal] - - for (const instance of r.cloudflareBlackList) { + for (const instance of [...r.cloudflareBlackList, ...r.offlineBlackList]) { const a = invidiousNormalRedirectsChecks.indexOf(instance) if (a > -1) invidiousNormalRedirectsChecks.splice(a, 1) @@ -467,9 +465,8 @@ function initDefaults() { if (c > -1) pipedMaterialNormalRedirectsChecks.splice(c, 1) const d = cloudtubeNormalRedirectsChecks.indexOf(instance) - if (d > -1) cloudtubeNormalRedirectsChecks.indexOf(instance) + if (c > -1) cloudtubeNormalRedirectsChecks.splice(d, 1) } - browser.storage.local.set( { disableYoutube: false, @@ -478,7 +475,7 @@ function initDefaults() { youtubeRedirects: redirects, youtubeFrontend: "invidious", - invidiousNormalRedirectsChecks: invidiousNormalRedirectsChecks, + invidiousNormalRedirectsChecks, invidiousNormalCustomRedirects: [], invidiousTorRedirectsChecks: [...redirects.invidious.tor], @@ -490,7 +487,7 @@ function initDefaults() { invidiousLokiRedirectsChecks: [...redirects.invidious.loki], invidiousLokiCustomRedirects: [], - pipedNormalRedirectsChecks: pipedNormalRedirectsChecks, + pipedNormalRedirectsChecks, pipedNormalCustomRedirects: [], pipedTorRedirectsChecks: [...redirects.piped.tor], diff --git a/src/assets/javascripts/youtubeMusic.js b/src/assets/javascripts/youtubeMusic.js index 3ff9a174..753ce7ad 100644 --- a/src/assets/javascripts/youtubeMusic.js +++ b/src/assets/javascripts/youtubeMusic.js @@ -19,11 +19,11 @@ for (let i = 0; i < frontends.length; i++) { } function setRedirects(val) { - browser.storage.local.get("cloudflareBlackList", r => { + browser.storage.local.get(["cloudflareBlackList", "offlineBlackList"], r => { redirects = val beatbumpNormalRedirectsChecks = [...redirects.beatbump.normal] hyperpipeNormalRedirectsChecks = [...redirects.hyperpipe.normal] - for (const instance of r.cloudflareBlackList) { + for (const instance of [...r.cloudflareBlackList, ...r.offlineBlackList]) { const a = beatbumpNormalRedirectsChecks.indexOf(instance) if (a > -1) beatbumpNormalRedirectsChecks.splice(a, 1) @@ -266,25 +266,23 @@ function initDefaults() { for (let i = 0; i < frontends.length; i++) { redirects[frontends[i]] = dataJson[frontends[i]] } - browser.storage.local.get("cloudflareBlackList", async r => { - beatbumpNormalRedirectsChecks = [...redirects.beatbump.normal] - hyperpipeNormalRedirectsChecks = [...redirects.hyperpipe.normal] - for (const instance of r.cloudflareBlackList) { - let i - - i = beatbumpNormalRedirectsChecks.indexOf(instance) - if (i > -1) beatbumpNormalRedirectsChecks.splice(i, 1) - - i = hyperpipeNormalRedirectsChecks.indexOf(instance) - if (i > -1) hyperpipeNormalRedirectsChecks.splice(i, 1) - } + browser.storage.local.get(["cloudflareBlackList", "offlineBlackList"], async r => { + beatbumpNormalRedirectsChecks = [...redirects.beatbump.normal] + hyperpipeNormalRedirectsChecks = [...redirects.hyperpipe.normal] + for (const instance of [...r.cloudflareBlackList, ...r.offlineBlackList]) { + const a = beatbumpNormalRedirectsChecks.indexOf(instance) + if (a > -1) beatbumpNormalRedirectsChecks.splice(a, 1) + + const b = hyperpipeNormalRedirectsChecks.indexOf(instance) + if (b > -1) hyperpipeNormalRedirectsChecks.splice(b, 1) + } browser.storage.local.set( { disableYoutubeMusic: false, youtubeMusicFrontend: "hyperpipe", youtubeMusicRedirects: redirects, - beatbumpNormalRedirectsChecks: beatbumpNormalRedirectsChecks, + beatbumpNormalRedirectsChecks, beatbumpNormalCustomRedirects: [], beatbumpTorRedirectsChecks: [...redirects.beatbump.tor], @@ -296,7 +294,7 @@ function initDefaults() { beatbumpLokiRedirectsChecks: [...redirects.beatbump.loki], beatbumpLokiCustomRedirects: [], - hyperpipeNormalRedirectsChecks: hyperpipeNormalRedirectsChecks, + hyperpipeNormalRedirectsChecks, hyperpipeNormalCustomRedirects: [], hyperpipeTorRedirectsChecks: [...redirects.hyperpipe.tor], diff --git a/src/instances/blacklist.json b/src/instances/blacklist.json index 221058ee..77aec738 100644 --- a/src/instances/blacklist.json +++ b/src/instances/blacklist.json @@ -4,8 +4,8 @@ "https://piped.kavin.rocks", "https://piped.tokhmi.xyz", "https://piped.moomoo.me", - "https://piped.syncpundit.com", "https://piped.mha.fi", + "https://de-piped.shimul.me", "https://jp-piped.shimul.me", "https://pipedus.palash.dev", "https://piped.waffle.wiki", @@ -81,4 +81,4 @@ "https://beatbump.ml", "https://stube.tokhmi.xyz" ] -} \ No newline at end of file +} diff --git a/src/instances/data.json b/src/instances/data.json index c5334a47..76c9f6d3 100644 --- a/src/instances/data.json +++ b/src/instances/data.json @@ -3,6 +3,13 @@ "normal": [ "https://yewtu.be", "https://vid.puffyan.us", +<<<<<<< HEAD +<<<<<<< HEAD +======= + "https://invidious.snopyta.org", +>>>>>>> 0b6c717 (update instances) +======= +>>>>>>> origin/master "https://invidious.kavin.rocks", "https://inv.riverside.rocks", "https://invidious.osi.kr", @@ -16,12 +23,25 @@ "https://invidious.nerdvpn.de", "https://inv.privacy.com.de", "https://invidious.slipfox.xyz", +<<<<<<< HEAD +<<<<<<< HEAD + "https://youtube.076.ne.jp", + "https://invidious.weblibre.org", + "https://invidious.snopyta.org", +======= "https://youtube.076.ne.jp", "https://invidious.weblibre.org", "https://invidious.snopyta.org", "https://invidious.projectsegfau.lt", +>>>>>>> origin/master "https://invidious.esmailelbob.xyz", "https://invidious.namazso.eu" +======= + "https://invidious.weblibre.org", + "https://youtube.076.ne.jp", + "https://invidious.namazso.eu", + "https://invidious.esmailelbob.xyz" +>>>>>>> 0b6c717 (update instances) ], "tor": [ "http://c7hqkpkpemu6e7emz5b4vyz7idjgdvgaaa3dyimmeojqbgpea3xqjoid.onion", @@ -43,13 +63,24 @@ "https://piped.tokhmi.xyz", "https://piped.moomoo.me", "https://il.ax", - "https://piped.syncpundit.com", "https://piped.mha.fi", +<<<<<<< HEAD + "https://de-piped.shimul.me", +======= "https://jp-piped.shimul.me", +>>>>>>> origin/master "https://pipedus.palash.dev", "https://piped.waffle.wiki", "https://watch.whatever.social", "https://yt.jae.fi", +<<<<<<< HEAD +<<<<<<< HEAD +======= + "https://piped.mint.lgbt", + "https://piped.privacy.com.de", +>>>>>>> 0b6c717 (update instances) +======= +>>>>>>> origin/master "https://piped.esmailelbob.xyz", "https://piped.projectsegfau.lt" ], @@ -484,6 +515,7 @@ "https://searx.bissisoft.com", "https://searx.divided-by-zero.eu", "https://searx.dresden.network", + "https://searx.ebnar.xyz", "https://searx.fossencdi.org", "https://searx.gnu.style", "https://searx.mastodontech.de", @@ -519,8 +551,17 @@ "http://yra4tke2pwcnatxjkufpw6kvebu3h3ti2jca2lcdpgx3mpwol326lzid.onion", "http://z5vawdol25vrmorm4yydmohsd4u6rdoj2sylvoi3e3nqvxkvpqul7bqd.onion", "http://zbuc3bbzbfdqqo2x46repx2ddajbha6fpsjeeptjhhhhzji3zopxdqyd.onion", +<<<<<<< HEAD +<<<<<<< HEAD + "http://f4qfqajszpx5b7itzxt6mb7kj4ktpgbdq7lq6xaiqyqx6a7de3epptad.onion" +======= + "http://f4qfqajszpx5b7itzxt6mb7kj4ktpgbdq7lq6xaiqyqx6a7de3epptad.onion", + "http://fub6vgedgeadlu3ctskrpkcqjruh76tckwtj5swfhyblgml2tzgzckqd.onion/searx" +>>>>>>> 0b6c717 (update instances) +======= "http://f4qfqajszpx5b7itzxt6mb7kj4ktpgbdq7lq6xaiqyqx6a7de3epptad.onion", "http://searx.micohauwkjbyw5meacrb4ipicwvwg4xtzl7y7viv53kig2mdcsvwkyyd.onion" +>>>>>>> origin/master ], "i2p": [ "http://ransack.i2p", @@ -565,7 +606,6 @@ "https://searx.be", "https://searx.becomesovran.com", "https://searx.chocoflan.net", - "https://searx.ebnar.xyz", "https://searx.ericaftereric.top", "https://searx.esmailelbob.xyz", "https://searx.fi", @@ -582,6 +622,10 @@ "https://searx.sev.monster", "https://searx.slipfox.xyz/searx", "https://searx.tiekoetter.com", +<<<<<<< HEAD + "https://searx.vimproved.me", +======= +>>>>>>> origin/master "https://searx.zcyph.cc", "https://searxng.au/searx", "https://searxng.tordenskjold.de", @@ -605,7 +649,6 @@ "http://searxdr3pqz4nydgnqocsia2xbywptxbkympa2emn7zlgggrir4bkfad.onion", "http://searx.privpw3tndpkw6pnp3g727zfgfdzbu3k6a7chv226s3xymv2p4eiuqyd.onion", "http://rq2w52kyrif3xpfihkgjnhqm3a5aqhoikpv72z3drpjglfzc2wr5z4yd.onion", - "http://fub6vgedgeadlu3ctskrpkcqjruh76tckwtj5swfhyblgml2tzgzckqd.onion/searx", "http://searx3aolosaf3urwnhpynlhuokqsgz47si4pzz5hvb7uuzyjncl2tid.onion", "http://4tz2vlnwk2apf2rpinkqv6uxvfgo5xjx6vl5vp7lxgaiooumetjpstqd.onion" ], @@ -733,7 +776,14 @@ "loki": [] }, "peertube": [ +<<<<<<< HEAD +<<<<<<< HEAD + "https://tube.nogafa.org", +======= +>>>>>>> 0b6c717 (update instances) +======= "https://tube.nogafa.org", +>>>>>>> origin/master "https://www.neptube.io", "https://tube.ghk-academy.info", "https://pcbu.nl", @@ -820,7 +870,6 @@ "https://tube-enseignement-professionnel.apps.education.fr", "https://socpeertube.ru", "https://videos.laliguepaysdelaloire.org", - "https://videotube.duckdns.org", "https://quantube.win", "https://twctube.twc-zone.eu", "https://vhs.absturztau.be", diff --git a/src/pages/background/background.js b/src/pages/background/background.js index a1b0c9c6..c6e9ab7a 100644 --- a/src/pages/background/background.js +++ b/src/pages/background/background.js @@ -32,25 +32,27 @@ browser.runtime.onInstalled.addListener(details => { browser.storage.local.clear(() => { browser.storage.local.set({ cloudflareBlackList: JSON.parse(data).cloudflare }, () => { browser.storage.local.set({ authenticateBlackList: JSON.parse(data).authenticate }, () => { - generalHelper.initDefaults() - youtubeHelper.initDefaults() - youtubeMusicHelper.initDefaults() - twitterHelper.initDefaults() - instagramHelper.initDefaults() - mapsHelper.initDefaults() - searchHelper.initDefaults() - translateHelper.initDefaults() - mediumHelper.initDefaults() - quoraHelper.initDefaults() - libremdbHelper.initDefaults() - reutersHelper.initDefaults() - redditHelper.initDefaults() - wikipediaHelper.initDefaults() - imgurHelper.initDefaults() - tiktokHelper.initDefaults() - sendTargetsHelper.initDefaults() - peertubeHelper.initDefaults() - lbryHelper.initDefaults() + browser.storage.local.set({ offlineBlackList: JSON.parse(data).offline }, () => { + generalHelper.initDefaults() + youtubeHelper.initDefaults() + youtubeMusicHelper.initDefaults() + twitterHelper.initDefaults() + instagramHelper.initDefaults() + mapsHelper.initDefaults() + searchHelper.initDefaults() + translateHelper.initDefaults() + mediumHelper.initDefaults() + quoraHelper.initDefaults() + libremdbHelper.initDefaults() + reutersHelper.initDefaults() + redditHelper.initDefaults() + wikipediaHelper.initDefaults() + imgurHelper.initDefaults() + tiktokHelper.initDefaults() + sendTargetsHelper.initDefaults() + peertubeHelper.initDefaults() + lbryHelper.initDefaults() + }) }) }) }) diff --git a/src/pages/options/index.html b/src/pages/options/index.html index a868ad3a..077b3da2 100644 --- a/src/pages/options/index.html +++ b/src/pages/options/index.html @@ -21,7 +21,7 @@ <div class="title"> <img src="../../../assets/images/instagram-icon.png"><a href="#instagram" data-localise="__MSG_instagram__">Instagram</a></div> <div class="title"> <img src="../../../assets/images/tiktok-icon.png"><a href="#tiktok" data-localise="__MSG_tiktok__">TikTok</a></div> <div class="title"> <img src="../../../assets/images/reddit-icon.png"><a href="#reddit" data-localise="__MSG_reddit__">Reddit</a></div> - <div class="title"> <img src="../../../assets/images/imgur-icon.png"><a href="#imgur" data-localise="__MSG_imgur__">Imgur</a></div> + <div class="title"> <img src="../../../assets/images/imgur.png"><a href="#imgur" data-localise="__MSG_imgur__">Imgur</a></div> <div class="title"> <img src="../../../assets/images/wikipedia-icon.svg"><a href="#wikipedia" data-localise="__MSG_wikipedia__">Wikipedia</a></div> <div class="title"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1770 1000" fill="currentColor"> @@ -34,7 +34,7 @@ <div class="title"><img src="../../../assets/images/imdb.svg"><a href="#imdb" data-localise="__MSG_imdb__">IMDb</a></div> <div class="title"><img src="../../../assets/images/reuters.svg"><a href="#reuters" data-localise="__MSG_reuters__">Reuters</a></div> <div class="title"> <img src="../../../assets/images/peertube-icon.svg"><a href="#peertube" data-localise="__MSG_peertube__">PeerTube</a></div> - <div class="title"> <img src="../../../assets/images/lbry-icon.png"><a href="#lbry" data-localise="__MSG_lbry__">LBRY/Odysee</a></div> + <div class="title"> <img src="../../../assets/images/lbry-icon.png"><a href="#lbry" data-localise="__MSG_lbry__">LBRY</a></div> <div class="title"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"> <path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"></path> @@ -94,6 +94,13 @@ <h4 data-localise="__MSG_autoRedirect__"></h4> <input id="auto-redirect" type="checkbox"> </div> + <form> + <div class="some-block option-block"> + <h4 data-localise="__MSG_latencyThreshold">Latency Threshold</h4> + <output id="latency-output" for="latencyInput" name="latencyOutput"></output> + <input id="latency-input" type="range" min="50" max="5000" value="1000" name="latencyInput" step="50"> + </div> + </form> <div class="some-block option-block"> <h4 data-localise="__MSG_exceptions__"></h4> </div> @@ -173,7 +180,7 @@ <input id="tiktok" type="checkbox"> </div> <div> - <div> <img src="../../../assets/images/imgur-icon.png"> + <div> <img src="../../../assets/images/imgur.png"> <x data-localise="__MSG_imgur__">Imgur</x> </div> <input id="imgur" type="checkbox"> @@ -254,7 +261,7 @@ </div> <div> <div> <img src="../../../assets/images/lbry-icon.png"> - <x data-localise="__MSG_lbry__">LBRY/Odysee</x> + <x data-localise="__MSG_lbry__">LBRY</x> </div> <input id="lbry" type="checkbox"> </div> @@ -3179,4 +3186,4 @@ </div> </body> <script type="module" src="./index.js"></script> -</html> \ No newline at end of file +</html> diff --git a/src/pages/options/index.pug b/src/pages/options/index.pug index 553f918f..3711fdac 100644 --- a/src/pages/options/index.pug +++ b/src/pages/options/index.pug @@ -33,4 +33,4 @@ html#elementToShowWithJavaScript(lang="en") include ./widgets/sendTargets.pug include ./widgets/about.pug - script(type="module" src="./index.js") \ No newline at end of file + script(type="module" src="./index.js") diff --git a/src/pages/options/widgets/general.js b/src/pages/options/widgets/general.js index c64eb25d..4ef30cec 100644 --- a/src/pages/options/widgets/general.js +++ b/src/pages/options/widgets/general.js @@ -81,6 +81,7 @@ resetSettings.addEventListener("click", async () => { .then(response => response.text()) .then(async data => { browser.storage.local.set({ cloudflareBlackList: JSON.parse(data).cloudflare }, () => { + browser.storage.local.set({ offlineBlackList: JSON.parse(data).offline }, () => { browser.storage.local.set({ authenticateBlackList: JSON.parse(data).authenticate }, async () => { await generalHelper.initDefaults() await youtubeHelper.initDefaults() @@ -103,6 +104,7 @@ resetSettings.addEventListener("click", async () => { await lbryHelper.initDefaults() location.reload() }) + }) }) }) }) diff --git a/src/pages/options/widgets/general.pug b/src/pages/options/widgets/general.pug index e04e9e2a..e523d5bb 100644 --- a/src/pages/options/widgets/general.pug +++ b/src/pages/options/widgets/general.pug @@ -31,6 +31,12 @@ section#general_page.option-block h4(data-localise="__MSG_autoRedirect__") input#auto-redirect(type="checkbox") + form + .some-block.option-block + h4(data-localise="__MSG_latencyThreshold") Latency Threshold + output#latency-output(for="latencyInput" name="latencyOutput") + input#latency-input(type="range" min="50" max="5000" value="1000" name="latencyInput" step="50") + .some-block.option-block h4(data-localise="__MSG_exceptions__") @@ -117,7 +123,7 @@ section#general_page.option-block div div - img(src="../../../assets/images/imgur-icon.png") + img(src="../../../assets/images/imgur.png") x(data-localise="__MSG_imgur__") Imgur input#imgur(type="checkbox") @@ -190,7 +196,7 @@ section#general_page.option-block div div img(src="../../../assets/images/lbry-icon.png") - x(data-localise="__MSG_lbry__") LBRY/Odysee + x(data-localise="__MSG_lbry__") LBRY input#lbry(type="checkbox") div diff --git a/src/pages/popup/popup.html b/src/pages/popup/popup.html index 7493ecbe..25f70f48 100644 --- a/src/pages/popup/popup.html +++ b/src/pages/popup/popup.html @@ -28,7 +28,7 @@ <h4 data-localise="__MSG_tiktok__">TikTok</h4></a> <input class="disable-tiktok" type="checkbox"/> </div> - <div class="imgur some-block"><a class="title" href="https://imgur.com"><img src="../../assets/images/imgur-icon.png"/> + <div class="imgur some-block"><a class="title" href="https://imgur.com"><img src="../../assets/images/imgur.png"/> <h4 data-localise="__MSG_imgur__">Imgur</h4></a> <input class="disable-imgur" type="checkbox"/> </div> @@ -122,7 +122,7 @@ <h4 data-localise="__MSG_tiktok__">TikTok</h4></a> <input class="disable-tiktok" type="checkbox"/> </div> - <div class="imgur some-block"><a class="title" href="https://imgur.com"><img src="../../assets/images/imgur-icon.png"/> + <div class="imgur some-block"><a class="title" href="https://imgur.com"><img src="../../assets/images/imgur.png"/> <h4 data-localise="__MSG_imgur__">Imgur</h4></a> <input class="disable-imgur" type="checkbox"/> </div> diff --git a/src/pages/popup/popup.pug b/src/pages/popup/popup.pug index cd4d3713..7da687cc 100644 --- a/src/pages/popup/popup.pug +++ b/src/pages/popup/popup.pug @@ -33,7 +33,7 @@ mixin services .imgur.some-block a.title(href="https://imgur.com") - img(src="../../assets/images/imgur-icon.png") + img(src="../../assets/images/imgur.png") h4(data-localise="__MSG_imgur__") Imgur input.disable-imgur(type="checkbox") |