From 25de09a9359eda0c038640b2a792cd3c753f5511 Mon Sep 17 00:00:00 2001 From: Hygna Date: Sat, 10 Sep 2022 20:48:57 +0100 Subject: Further progress --- src/instances/beatbump.json | 4 +- src/instances/bibliogram.json | 6 +++ src/instances/cloudtube.json | 2 +- src/instances/facil.json | 2 +- src/instances/get_instances.py | 101 +++++++++++++++++++---------------------- src/instances/neuters.json | 2 +- 6 files changed, 58 insertions(+), 59 deletions(-) create mode 100644 src/instances/bibliogram.json (limited to 'src/instances') diff --git a/src/instances/beatbump.json b/src/instances/beatbump.json index 4c7f65a6..c5c78123 100644 --- a/src/instances/beatbump.json +++ b/src/instances/beatbump.json @@ -1,6 +1,6 @@ { - "normal": ["https://beatbump.ml"], - "tor": [], + "clearnet": ["https://beatbump.ml", "https://beatbump.esmailelbob.xyz"], + "tor": ["http://beatbump.lqs5fjmajyp7rvp4qvyubwofzi6d4imua7vs237rkc4m5qogitqwrgyd.onion"], "i2p": [], "loki": [] } diff --git a/src/instances/bibliogram.json b/src/instances/bibliogram.json new file mode 100644 index 00000000..b08aa7a0 --- /dev/null +++ b/src/instances/bibliogram.json @@ -0,0 +1,6 @@ +{ + "clearnet": ["https://bibliogram.1d4.us", "https://bibliogram.froth.zone", "https://ig.tokhmi.xyz", "https://ig.beparanoid.de", "https://bibliogram.priv.pw"], + "tor": [], + "i2p": [], + "loki": [] +} diff --git a/src/instances/cloudtube.json b/src/instances/cloudtube.json index 402adc39..caba9d9c 100644 --- a/src/instances/cloudtube.json +++ b/src/instances/cloudtube.json @@ -1,5 +1,5 @@ { - "normal": ["https://tube.cadence.moe", "https://yt.beparanoid.de"], + "clearnet": ["https://tube.cadence.moe", "https://yt.beparanoid.de"], "tor": ["http://yt.prnoid54e44a4bduq5due64jkk7wcnkxcp5kv3juncm7veptjcqudgyd.onion"], "i2p": [], "loki": [] diff --git a/src/instances/facil.json b/src/instances/facil.json index 798a9cfb..6c89eb17 100644 --- a/src/instances/facil.json +++ b/src/instances/facil.json @@ -1,5 +1,5 @@ { - "normal": ["https://facilmap.org"], + "clearnet": ["https://facilmap.org"], "tor": [], "i2p": [], "loki": [] diff --git a/src/instances/get_instances.py b/src/instances/get_instances.py index eab4a924..a95eb46f 100644 --- a/src/instances/get_instances.py +++ b/src/instances/get_instances.py @@ -107,13 +107,13 @@ def invidious(): r = requests.get('https://api.invidious.io/instances.json') rJson = json.loads(r.text) invidiousList = {} - invidiousList['normal'] = [] + invidiousList['clearnet'] = [] invidiousList['tor'] = [] invidiousList['i2p'] = [] invidiousList['loki'] = [] for instance in rJson: if instance[1]['type'] == 'https': - invidiousList['normal'].append(instance[1]['uri']) + invidiousList['clearnet'].append(instance[1]['uri']) elif instance[1]['type'] == 'onion': invidiousList['tor'].append(instance[1]['uri']) mightyList['invidious'] = invidiousList @@ -127,7 +127,7 @@ def piped(): tmp = re.findall( '(?:[^\s\/]+\.)+[a-zA-Z]+ (?:\(Official\) )?\| (https:\/{2}(?:[^\s\/]+\.)+[a-zA-Z]+) \| ', r.text) _list = {} - _list['normal'] = [] + _list['clearnet'] = [] _list['tor'] = [] _list['i2p'] = [] _list['loki'] = [] @@ -137,7 +137,7 @@ def piped(): if url.strip("/") == item: continue else: - _list['normal'].append(url) + _list['clearnet'].append(url) except: continue mightyList['piped'] = _list @@ -151,12 +151,12 @@ def pipedMaterial(): tmp = re.findall( r"\| (https?:\/{2}(?:\S+\.)+[a-zA-Z0-9]*) +\|", r.text) pipedMaterialList = {} - pipedMaterialList['normal'] = [] + pipedMaterialList['clearnet'] = [] pipedMaterialList['tor'] = [] pipedMaterialList['i2p'] = [] pipedMaterialList['loki'] = [] for item in tmp: - pipedMaterialList['normal'].append(item) + pipedMaterialList['clearnet'].append(item) mightyList['pipedMaterial'] = pipedMaterialList print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'pipedMaterial') @@ -175,12 +175,12 @@ def proxitok(): tmp = re.findall( r"\| \[.*\]\(([-a-zA-Z0-9@:%_\+.~#?&//=]{2,}\.[a-z]{2,}\b(?:\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?)\)*\|*[A-Z]{0,}.*\|.*\|", r.text) proxiTokList = {} - proxiTokList['normal'] = [] + proxiTokList['clearnet'] = [] proxiTokList['tor'] = [] proxiTokList['i2p'] = [] proxiTokList['loki'] = [] for item in tmp: - proxiTokList['normal'].append(re.sub(r'/$', '', item)) + proxiTokList['clearnet'].append(re.sub(r'/$', '', item)) mightyList['proxiTok'] = proxiTokList print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'ProxiTok') @@ -191,12 +191,12 @@ def send(): tmp = re.findall( r"- ([-a-zA-Z0-9@:%_\+.~#?&//=]{2,}\.[a-z0-9]{2,}\b(?:\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?)\)*\|*[A-Z]{0,}", r.text) sendList = {} - sendList['normal'] = [] + sendList['clearnet'] = [] sendList['tor'] = [] sendList['i2p'] = [] sendList['loki'] = [] for item in tmp: - sendList['normal'].append(item) + sendList['clearnet'].append(item) mightyList['send'] = sendList print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'Send') @@ -207,7 +207,7 @@ def nitter(): r"(?:(?:\| \[(?:\S+\.)+[a-zA-Z]+\]\((https?:\/{2}(?:\S+\.)+[a-zA-Z]+)\/?\) (?:\((?:\S+ ?\S*)\) )? *\| [^❌]{1,3} +\|(?:(?:\n)|(?: (?:❌)|(?: ✅)|(?: ❓)|(?: \[))))|(?:- \[(?:\S+\.)+(?:(?:i2p)|(?:loki))\]\((https?:\/{2}(?:\S+\.)(?:(?:i2p)|(?:loki)))\/?\)))", r.text) nitterList = {} - nitterList['normal'] = [] + nitterList['clearnet'] = [] nitterList['tor'] = [] nitterList['i2p'] = [] nitterList['loki'] = [] @@ -224,22 +224,15 @@ def nitter(): elif re.search(lokiRegex, item): nitterList['loki'].append(item) else: - nitterList['normal'].append(item) + nitterList['clearnet'].append(item) mightyList['nitter'] = nitterList print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'Nitter') def bibliogram(): - r = requests.get('https://bibliogram.art/api/instances') - rJson = json.loads(r.text) - bibliogramList = {} - bibliogramList['normal'] = [] - bibliogramList['tor'] = [] - bibliogramList['i2p'] = [] - bibliogramList['loki'] = [] - for item in rJson['data']: - bibliogramList['normal'].append(item['address']) - mightyList['bibliogram'] = bibliogramList + json_object = json.dumps(mightyList, ensure_ascii=False, indent=2) + with open('./src/instances/bibliogram.json') as file: + mightyList['bibliogram'] = json.load(file) print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'Bibliogram') @@ -247,7 +240,7 @@ def libreddit(): r = requests.get( 'https://raw.githubusercontent.com/spikecodes/libreddit/master/README.md') libredditList = {} - libredditList['normal'] = [] + libredditList['clearnet'] = [] libredditList['tor'] = [] libredditList['i2p'] = [] libredditList['loki'] = [] @@ -259,7 +252,7 @@ def libreddit(): if re.search(torRegex, item): libredditList['tor'].append(item) else: - libredditList['normal'].append(item) + libredditList['clearnet'].append(item) mightyList['libreddit'] = libredditList print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'LibReddit') @@ -269,14 +262,14 @@ def teddit(): 'https://codeberg.org/teddit/teddit/raw/branch/main/instances.json') rJson = json.loads(r.text) tedditList = {} - tedditList['normal'] = [] + tedditList['clearnet'] = [] tedditList['tor'] = [] tedditList['i2p'] = [] tedditList['loki'] = [] for item in rJson: url = item['url'] if url != '': - tedditList['normal'].append(url) + tedditList['clearnet'].append(url) if 'onion' in item: onion = item['onion'] if onion != '': @@ -290,14 +283,14 @@ def wikiless(): r = requests.get('https://wikiless.org/instances.json') rJson = json.loads(r.text) wikilessList = {} - wikilessList['normal'] = [] + wikilessList['clearnet'] = [] wikilessList['tor'] = [] wikilessList['i2p'] = [] wikilessList['loki'] = [] for item in rJson: if 'url' in item: if item['url'].strip() != "": - wikilessList['normal'].append(item['url']) + wikilessList['clearnet'].append(item['url']) if 'onion' in item: if item['onion'].strip() != "": wikilessList['tor'].append(item['onion']) @@ -313,12 +306,12 @@ def scribe(): 'https://git.sr.ht/~edwardloveall/scribe/blob/main/docs/instances.json') rJson = json.loads(r.text) scribeList = {} - scribeList['normal'] = [] + scribeList['clearnet'] = [] scribeList['tor'] = [] scribeList['i2p'] = [] scribeList['loki'] = [] for item in rJson: - scribeList['normal'].append(item) + scribeList['clearnet'].append(item) mightyList['scribe'] = scribeList print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'Scribe') @@ -327,7 +320,7 @@ def quetre(): r = requests.get( 'https://raw.githubusercontent.com/zyachel/quetre/main/README.md') _list = {} - _list['normal'] = [] + _list['clearnet'] = [] _list['tor'] = [] _list['i2p'] = [] _list['loki'] = [] @@ -340,7 +333,7 @@ def quetre(): if re.search(torRegex, item): _list['tor'].append(item) else: - _list['normal'].append(item) + _list['clearnet'].append(item) mightyList['quetre'] = _list print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'Quetre') @@ -349,7 +342,7 @@ def libremdb(): r = requests.get( 'https://raw.githubusercontent.com/zyachel/libremdb/main/README.md') _list = {} - _list['normal'] = [] + _list['clearnet'] = [] _list['tor'] = [] _list['i2p'] = [] _list['loki'] = [] @@ -364,7 +357,7 @@ def libremdb(): if re.search(torRegex, item): _list['tor'].append(item) else: - _list['normal'].append(item) + _list['clearnet'].append(item) mightyList['libremdb'] = _list print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'Libremdb') @@ -372,12 +365,12 @@ def libremdb(): def simpleertube(): r = requests.get('https://simple-web.org/instances/simpleertube') _list = {} - _list['normal'] = [] + _list['clearnet'] = [] _list['tor'] = [] _list['i2p'] = [] _list['loki'] = [] for item in r.text.strip().split('\n'): - _list['normal'].append('https://' + item) + _list['clearnet'].append('https://' + item) mightyList['simpleertube'] = _list print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'SimpleerTube') @@ -386,9 +379,9 @@ def simpleertube(): def simplytranslate(): r = requests.get('https://simple-web.org/instances/simplytranslate') simplyTranslateList = {} - simplyTranslateList['normal'] = [] + simplyTranslateList['clearnet'] = [] for item in r.text.strip().split('\n'): - simplyTranslateList['normal'].append('https://' + item) + simplyTranslateList['clearnet'].append('https://' + item) r = requests.get('https://simple-web.org/instances/simplytranslate_onion') simplyTranslateList['tor'] = [] @@ -414,12 +407,12 @@ def linvgatranslate(): 'https://raw.githubusercontent.com/TheDavidDelta/lingva-translate/main/instances.json') rJson = json.loads(r.text) lingvaList = {} - lingvaList['normal'] = [] + lingvaList['clearnet'] = [] lingvaList['tor'] = [] lingvaList['i2p'] = [] lingvaList['loki'] = [] for item in rJson: - lingvaList['normal'].append(item) + lingvaList['clearnet'].append(item) mightyList['lingva'] = lingvaList print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'LinvgaTranslate') @@ -429,12 +422,12 @@ def searx_searxng(): r = requests.get('https://searx.space/data/instances.json') rJson = json.loads(r.text) searxList = {} - searxList['normal'] = [] + searxList['clearnet'] = [] searxList['tor'] = [] searxList['i2p'] = [] searxList['loki'] = [] searxngList = {} - searxngList['normal'] = [] + searxngList['clearnet'] = [] searxngList['tor'] = [] searxngList['i2p'] = [] searxngList['loki'] = [] @@ -451,9 +444,9 @@ def searx_searxng(): searxList['i2p'].append(item[:-1]) else: if (rJson['instances'][item].get('generator') == 'searxng'): - searxngList['normal'].append(item[:-1]) + searxngList['clearnet'].append(item[:-1]) else: - searxList['normal'].append(item[:-1]) + searxList['clearnet'].append(item[:-1]) mightyList['searx'] = searxList mightyList['searxng'] = searxngList @@ -465,7 +458,7 @@ def whoogle(): 'https://raw.githubusercontent.com/benbusby/whoogle-search/main/misc/instances.txt') tmpList = r.text.strip().split('\n') whoogleList = {} - whoogleList['normal'] = [] + whoogleList['clearnet'] = [] whoogleList['tor'] = [] whoogleList['i2p'] = [] whoogleList['loki'] = [] @@ -475,7 +468,7 @@ def whoogle(): elif re.search(torRegex, item): whoogleList['i2p'].append(item) else: - whoogleList['normal'].append(item) + whoogleList['clearnet'].append(item) mightyList['whoogle'] = whoogleList print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'Whoogle') @@ -484,7 +477,7 @@ def librex(): r = requests.get( 'https://raw.githubusercontent.com/hnhx/librex/main/README.md') _list = {} - _list['normal'] = [] + _list['clearnet'] = [] _list['tor'] = [] _list['i2p'] = [] _list['loki'] = [] @@ -500,7 +493,7 @@ def librex(): elif re.search(i2pRegex, item): _list['i2p'].append(item) else: - _list['normal'].append(item) + _list['clearnet'].append(item) mightyList['librex'] = _list print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'Librex') @@ -510,13 +503,13 @@ def rimgo(): 'https://codeberg.org/video-prize-ranch/rimgo/raw/branch/main/instances.json') rJson = json.loads(r.text) rimgoList = {} - rimgoList['normal'] = [] + rimgoList['clearnet'] = [] rimgoList['tor'] = [] rimgoList['i2p'] = [] rimgoList['loki'] = [] for item in rJson: if 'url' in item: - rimgoList['normal'].append(item['url']) + rimgoList['clearnet'].append(item['url']) if 'onion' in item: rimgoList['tor'].append(item['onion']) if 'i2p' in item: @@ -530,7 +523,7 @@ def librarian(): 'https://codeberg.org/librarian/librarian/raw/branch/main/instances.json') rJson = json.loads(r.text) librarianList = {} - librarianList['normal'] = [] + librarianList['clearnet'] = [] librarianList['tor'] = [] librarianList['i2p'] = [] librarianList['loki'] = [] @@ -546,7 +539,7 @@ def librarian(): elif re.search(lokiRegex, url): librarianList['loki'].append(url) else: - librarianList['normal'].append(url) + librarianList['clearnet'].append(url) mightyList['librarian'] = librarianList print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'Librarian') @@ -570,7 +563,7 @@ def hyperpipe(): 'https://codeberg.org/Hyperpipe/pages/raw/branch/main/api/frontend.json') rJson = json.loads(r.text) hyperpipeList = {} - hyperpipeList['normal'] = [] + hyperpipeList['clearnet'] = [] hyperpipeList['tor'] = [] hyperpipeList['i2p'] = [] hyperpipeList['loki'] = [] @@ -585,7 +578,7 @@ def hyperpipe(): elif re.search(lokiRegex, url): hyperpipeList['loki'].append(url) else: - hyperpipeList['normal'].append(url) + hyperpipeList['clearnet'].append(url) mightyList['hyperpipe'] = hyperpipeList print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'Hyperpipe') diff --git a/src/instances/neuters.json b/src/instances/neuters.json index 9e224a52..8023079b 100644 --- a/src/instances/neuters.json +++ b/src/instances/neuters.json @@ -1,5 +1,5 @@ { - "normal": ["https://neuters.de"], + "clearnet": ["https://neuters.de"], "tor": [], "i2p": [], "loki": [] -- cgit 1.4.1 From 0c1595ec3a0f8f38f322f2e70598dbe208151554 Mon Sep 17 00:00:00 2001 From: Hygna Date: Mon, 19 Sep 2022 17:30:39 +0100 Subject: Changes Made get_instances.py more efficient Further work to get widgets/services.js to work properly --- src/assets/javascripts/services.js | 33 +- src/config/config.json | 171 ++-- src/instances/get_instances.py | 484 ++++-------- src/pages/options/index.ejs | 10 +- src/pages/options/index.html | 1326 ++++++++++---------------------- src/pages/options/widgets/general.ejs | 12 +- src/pages/options/widgets/services.ejs | 61 +- src/pages/options/widgets/services.js | 58 +- src/pages/widgets/links.ejs | 4 +- 9 files changed, 793 insertions(+), 1366 deletions(-) (limited to 'src/instances') diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js index 70928786..affe0d1a 100644 --- a/src/assets/javascripts/services.js +++ b/src/assets/javascripts/services.js @@ -28,8 +28,8 @@ function init() { //cur = current for (const service in config.services) { options[service] = {} - browser.storage.local.get([`disable${utils.camelCase(service)}`, `${service}RedirectType`, `${service}Frontend`], r => { - options[service].disabled = r["disable" + utils.camelCase(service)] + browser.storage.local.get([`${utils.camelCase(service)}Enable`, `${service}RedirectType`, `${service}Frontend`], r => { + options[service].enabled = r[utils.camelCase(service) + "Enable"] options[service].frontend = r[service + "Frontend"] options[service].redirectType = r[service + "RedirectType"] // console.log(r) @@ -60,19 +60,19 @@ function all(service) { return tmp } -getConfig() +await getConfig() init() browser.storage.onChanged.addListener(init) function redirect(url, type, initiator) { let randomInstance - let frontend = options[service].frontend + let frontend let network = options.network let networkFallback = options.networkFallback - let redirectType = options[service].redirectType + let redirectType if (url.pathname == "/") return for (const service in config.services) { - if (options[service].disabled && !disableOverride) continue + if (!options[service].enabled && !disableOverride) continue let targets = service.targets if (targets == "datajson") { browser.storage.local.get(`${service}Targets`, (targets = r[service + "Targets"])) @@ -81,11 +81,18 @@ function redirect(url, type, initiator) { if (initiator && (all(service).includes(initiator.origin) || targets.includes(initiator.host))) continue if (!targets.some(rx => rx.test(url.href))) continue if (type != redirectType && type != "both") continue + + frontend = options[service].frontend + redirectType = options[service].redirectType + // browser.storage.local.get(`${service}Frontend`, (frontend = r[service + "Frontend"])) - let instanceList = [...[service + utils.camelCase(network) + "RedirectsChecks"], ...[service + utils.camelCase(network) + "CustomRedirects"]] - if (instanceList.length === 0 && networkFallback) instanceList = [...[service + "ClearnetRedirectsChecks"], ...[service + "ClearnetCustomRedirects"]] - if (instanceList.length === 0 && redirects.indexOf(frontend) != -1) return - randomInstance = utils.getRandomInstance(instanceList) + + if (config.services[service].frontends[frontend].instanceList) { + let instanceList = [...[frontend + utils.camelCase(network) + "RedirectsChecks"], ...[frontend + utils.camelCase(network) + "CustomRedirects"]] + if (instanceList.length === 0 && networkFallback) instanceList = [...[frontend + "ClearnetRedirectsChecks"], ...[frontend + "ClearnetCustomRedirects"]] + if (instanceList.length === 0 && redirects.indexOf(frontend) != -1) return + randomInstance = utils.getRandomInstance(instanceList) + } } // Here is a (temperory) space for defining constants required in 2 or more switch cases. @@ -114,7 +121,7 @@ function redirect(url, type, initiator) { .replace("/watch?v=", "/listen?id=") .replace("/channel/", "/artist/") .replace("/playlist?list=", "/playlist/VL") - .replace(/\/search\?q=.*/, searchQuery => searchQuery.replace("?q=", "/") + "?filter=song") + .replace(/\/search\?q=.*/, searchQuery => searchQuery.replace("?q=", "/") + "?filter=all") case "hyperpipe": return `${randomInstance}${url.pathname}${url.search}`.replace(/\/search\?q=.*/, searchQuery => searchQuery.replace("?q=", "/")) case "bibliogram": @@ -386,7 +393,7 @@ function initDefaults() { // console.log(redirects) // console.log(config) browser.storage.local.set({ - redirects, + redirects: redirects.invidious, }) browser.storage.local.get(["cloudflareBlackList", "authenticateBlackList", "offlineBlackList"], async r => { // console.log(r) @@ -395,7 +402,7 @@ function initDefaults() { browser.storage.local.set({ [service + "Targets"]: redirects[service] }) } for (const defaultOption in config.services[service].defaults) { - browser.storage.local.set({ [defaultOption]: config.services[service].defaults[defaultOption] }) + browser.storage.local.set({ [service + camelCase(defaultOption)]: config.services[service].defaults[defaultOption] }) } for (const frontend in config.services[service].frontends) { let clearnetChecks = redirects[frontend].clearnet diff --git a/src/config/config.json b/src/config/config.json index 7c391552..d0bf7edd 100644 --- a/src/config/config.json +++ b/src/config/config.json @@ -24,7 +24,10 @@ "invidious": { "preferences": { "cookies": ["PREFS"] - } + }, + "name": "Invidious", + "embeddable": true, + "instanceList": true }, "piped": { "preferences": { @@ -48,19 +51,38 @@ "volume", "watchHistory" ] - } + }, + "name": "Piped", + "embeddable": true, + "instanceList": true }, "pipedMaterial": { "preferences": { "localstorage": ["PREFERENCES"] - } + }, + "name": "Piped-Material", + "embeddable": false, + "instanceList": true }, "cloudtube": { "preferences": { "token": "token", "fetchEndpoint": "/api/settings", "setEndpoint": "/settings" - } + }, + "name": "CloudTube", + "embeddable": false, + "instanceList": true + }, + "freetube": { + "name": "FreeTube", + "embeddable": false, + "instanceList": false + }, + "yattee": { + "name": "Yattee", + "embeddable": false, + "instanceList": false } }, "singleInstanceFrontends": ["freetube", "yatte"], @@ -74,7 +96,7 @@ ], "name": "Youtube", "options": { - "disabled": false, + "enabled": true, "redirectType": "both", "frontend": "invidious", "embedFrontend": "invidious" @@ -88,19 +110,23 @@ "preferences": { "localstorage": ["settings"], "indexeddb": "beatbump" - } + }, + "name": "Beatbump", + "instanceList": true }, "hyperpipe": { "preferences": { "localstorage": ["api", "authapi", "codec", "locale", "next", "pipedapi", "quality", "theme", "vol"], "indexeddb": ["hyperpipedb"] - } + }, + "name": "HyperPipe", + "instanceList": true } }, "targets": ["^https?:\\/{2}music\\.youtube\\.com(\\/.*|$)"], "name": "YT Music", "options": { - "disabled": false, + "enabled": true, "frontend": "beatbump" }, "imageType": "png", @@ -130,13 +156,16 @@ "replaceTwitter", "replaceYouTube" ] - } + }, + "name": "Nitter", + "embeddable": true, + "instanceList": true } }, "targets": ["^https?:\\/{2}(www\\.|mobile\\.|)twitter\\.com", "^https?:\\/{2}(pbs\\.|video\\.|)twimg\\.com", "^https?:\\/{2}platform\\.twitter\\.com/embed", "^https?:\\/{2}t\\.co"], "name": "Twitter", "options": { - "disabled": false, + "enabled": true, "redirectType": "both" }, "imageType": "png", @@ -149,12 +178,14 @@ "token": "token", "fetchEndpoint": "/settings.json", "setEndpoint": "/applysettings" - } + }, + "name": "Bibliogram", + "instanceList": false } }, "targets": ["^https?:\\/{2}(www\\.)?instagram\\.com"], "name": "Instagram", - "options": { "disabled": false }, + "options": { "enabled": true }, "imageType": "png", "embeddable": false }, @@ -163,12 +194,14 @@ "proxiTok": { "preferences": { "cookies": ["api-test_endpoints", "theme"] - } + }, + "name": "ProxiTok", + "instanceList": true } }, "targets": ["^https?:\\/{2}(www\\.|)tiktok\\.com.*"], "name": "TikTok", - "options": { "disabled": false }, + "options": { "enabled": true }, "imageType": "png", "embeddable": false }, @@ -177,7 +210,9 @@ "libreddit": { "preferences": { "cookies": ["theme", "front_page", "layout", "wide", "post_sort", "comment_sort", "show_nsfw", "autoplay_videos", "use_hls", "hide_hls_notification", "subscriptions", "filters"] - } + }, + "name": "Libreddit", + "instanceList": true }, "teddit": { "preferences": { @@ -195,13 +230,15 @@ "theme", "videos_muted" ] - } + }, + "name": "Teddit", + "instanceList": true } }, "targets": ["^https?:\\/{2}(www\\.|old\\.|np\\.|new\\.|amp\\.|)reddit\\.com", "^https?:\\/{2}(i\\.|preview\\.)redd\\.it"], "name": "Reddit", "options": { - "disabled": false, + "enabled": true, "frontend": "libreddit" }, "imageType": "png", @@ -210,12 +247,14 @@ "imgur": { "frontends": { "rimgo": { - "preferences": {} + "preferences": {}, + "name": "rimgo", + "instanceList": true } }, "targets": ["^https?:\\/{2}([im]\\.)?imgur\\.(com|io)(\\/|$)"], "name": "Imgur", - "options": { "disabled": false }, + "options": { "enabled": true }, "imageType": "png", "embeddable": false }, @@ -224,19 +263,23 @@ "wikiless": { "preferences": { "cookies": ["theme", "default_lang"] - } + }, + "name": "Wikiless", + "instanceList": true } }, "targets": ["^https?:\\/{2}([a-z]+\\.)*wikipedia\\.org"], "name": "Wikipedia", - "options": { "disabled": true }, + "options": { "enabled": false }, "imageType": "svg", "embeddable": false }, "medium": { "frontends": { "scribe": { - "preferences": {} + "preferences": {}, + "name": "Scribe", + "instanceList": true } }, "targets": [ @@ -260,7 +303,7 @@ "^writingcooperative\\.com " ], "name": "Medium", - "options": { "disabled": false }, + "options": { "enabled": true }, "imageType": "svg", "embeddable": false }, @@ -269,12 +312,14 @@ "quetre": { "preferences": { "localstorage": ["theme"] - } + }, + "name": "Quetre", + "instanceList": true } }, "targets": ["^https?:\\/{2}([a-z]+\\.)*quora\\.com.*"], "name": "Quora", - "options": { "disabled": false }, + "options": { "enabled": true }, "imageType": "png", "embeddable": false }, @@ -283,36 +328,42 @@ "libremdb": { "preferences": { "localstorage": ["theme"] - } + }, + "name": "libremdb", + "instanceList": true } }, "targets": ["^https?:\\/{2}(?:www\\.|)imdb\\.com.*"], "name": "IMDb", - "options": { "disabled": true }, + "options": { "enabled": false }, "imageType": "svg", "embeddable": false }, "reuters": { "frontends": { "neuters": { - "preferences": {} + "preferences": {}, + "name": "Neuters", + "instanceList": true } }, "targets": ["^https?:\\/{2}(www\\.|)reuters\\.com.*"], "name": "Reuters", - "options": { "disabled": true }, + "options": { "enabled": false }, "imageType": "svg", "embeddable": false }, "peertube": { "frontends": { "simpleertube": { - "preferences": {} + "preferences": {}, + "name": "SimpleerTube", + "instanceList": true } }, "targets": "datajson", "name": "PeerTube", - "options": { "disabled": true }, + "options": { "enabled": false }, "imageType": "svg", "embeddable": false }, @@ -322,14 +373,21 @@ "preferences": { "cookies": ["nsfw", "theme"], "localstorage": ["autoplay", "autoplayNextVid", "collapseComments", "plyr", "sb_categories", "showRelated"] - } + }, + "name": "Librarian", + "embeddable": true, + "instanceList": true + }, + "lbryDesktop": { + "name": "LBRY Desktop", + "embeddable": false, + "instanceList": false } }, - "singleInstanceFrontends": ["lbryDesktop"], "targets": ["^https?:\\/{2}odysee\\.com", "^https?:\\/{2}lbry\\.tv"], "name": "LBRY", "options": { - "disabled": true, + "enabled": false, "frontend": "librarian", "redirectType": "both" }, @@ -359,7 +417,9 @@ "theme", "tokens" ] - } + }, + "name": "SearX", + "instanceList": true }, "searxng": { "preferences": { @@ -384,21 +444,27 @@ "theme", "tokens" ] - } + }, + "name": "SearXNG", + "instanceList": true }, "whoogle": { - "preferences": {} + "preferences": {}, + "name": "Whoogle", + "instanceList": true }, "librex": { "preferences": { "cookies": ["bibliogram", "disable_special", "invidious", "libreddit", "nitter", "proxitok", "theme", "wikiless"] - } + }, + "name": "LibreX", + "instanceList": true } }, "targets": ["^https?:\\/{2}search\\.libredirect\\.invalid"], "name": "Search", "options": { - "disabled": false, + "enabled": true, "frontend": "searxng" }, "imageType": "svg", @@ -409,18 +475,22 @@ "simplyTranslate": { "preferences": { "cookies": ["from_lang", "to_lang", "tts_enabled", "use_text_fields"] - } + }, + "name": "SimplyTranslate", + "instanceList": true }, "lingva": { "preferences": { "localstorage": ["isauto", "source", "target"] - } + }, + "name": "Lingva", + "instanceList": true } }, "targets": ["^https?:\\/{2}translate\\.google(\\.[a-z]{2,3}){1,2}\\/"], "name": "Translate", "options": { - "disabled": false, + "enabled": true, "frontend": "simplyTranslate" }, "imageType": "svg", @@ -429,14 +499,19 @@ "maps": { "frontends": { "facil": { - "preferences": {} + "preferences": {}, + "name": "FacilMap", + "instanceList": true + }, + "osm": { + "name": "OpenStreetMap", + "instanceList": false } }, - "singleInstanceFrontends": ["osm"], "targets": ["^https?:\\/{2}(((www|maps)\\.)?(google\\.).*(\\/maps)|maps\\.(google\\.).*)"], "name": "Maps", "options": { - "disabled": false, + "enabled": true, "frontend": "osm" }, "imageType": "svg", @@ -445,12 +520,14 @@ "sendTargets": { "frontends": { "send": { - "preferences": {} + "preferences": {}, + "name": "Send", + "instanceList": "true" } }, "targets": ["^https?:\\/{2}send\\.libredirect\\.invalid\\/$", "^https?:\\/{2}send\\.firefox\\.com\\/$", "^https?:\\/{2}sendfiles\\.online\\/$"], "name": "Send Files", - "options": { "disabled": false }, + "options": { "enabled": true }, "imageType": "svg", "embeddable": false } diff --git a/src/instances/get_instances.py b/src/instances/get_instances.py index a95eb46f..770f2581 100644 --- a/src/instances/get_instances.py +++ b/src/instances/get_instances.py @@ -3,12 +3,10 @@ import requests import json from urllib.parse import urlparse -from bs4 import BeautifulSoup import re from colorama import Fore, Back, Style from urllib.parse import urlparse import socket -import subprocess mightyList = {} @@ -18,6 +16,11 @@ torRegex = startRegex + "onion" + endRegex i2pRegex = startRegex + "i2p" + endRegex lokiRegex = startRegex + "loki" + endRegex authRegex = "https?:\/{2}\S+:\S+@(?:[^\s\/]+\.)+[a-zA-Z0-9]+" + endRegex +config = {} + +with open('./config/config.json') as file: + config = file + def filterLastSlash(urlList): tmp = {} @@ -102,70 +105,162 @@ def is_offline(url): except: return False +def fetchCache(frontend, name) : + # json_object = json.dumps(mightyList, ensure_ascii=False, indent=2) + with open('./src/instances/data.json') as file: + mightyList[frontend] = json.load(file).frontend + print(Fore.ORANGE + 'Failed' + Style.RESET_ALL + ' to fetch ' + name) + +def fetchFromFile(frontend, name): + #json_object = json.dumps(mightyList, ensure_ascii=False, indent=2) + with open('./src/instances/' + frontend + '.json') as file: + mightyList[frontend] = json.load(file) + print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + name) + +def fetchJsonList(frontend, name, url, urlItem): + try: + r = requests.get(url) + rJson = json.loads(r.text) + _list = {} + for network in config.networks: + _list[network] = [] + if type(urlItem) is 'str': + for item in rJson: + if urlItem is not None: + tmpUrl = item[urlItem] + else: + tmpUrl = item + if tmpUrl.strip() == "": + continue + elif re.search(torRegex, tmpUrl): + _list['tor'].append(tmpUrl) + elif re.search(i2pRegex, tmpUrl): + _list['i2p'].append(tmpUrl) + elif re.search(lokiRegex, tmpUrl): + _list['loki'].append(tmpUrl) + else: + _list['clearnet'].append(tmpUrl) + else: + for i in range(config.networks.length): + # The expected order is the same as in config.json. If the frontend doesn't have any instances for a specified network, use None + if urlItem != None: + for item in rJson: + if network in item: + if item[network].strip() != "": + _list[config.networks[i]].append(item[urlItem[i]]) + + mightyList[frontend] = _list + print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + name) + except: + fetchCache(frontend, name) + +def fetchRegexList(frontend, name, url, regex): + try: + r = requests.get(url) + _list = {} + for network in config.networks: + _list[network] = [] + + tmp = re.findall(regex, r.text) + + for item in tmp: + if item.strip() == "": + continue + elif re.search(torRegex, item): + _list['tor'].append(item) + elif re.search(i2pRegex, item): + _list['i2p'].append(item) + elif re.search(lokiRegex, item): + _list['loki'].append(item) + else: + _list['clearnet'].append(item) + mightyList[frontend] = _list + print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + name) + except: + fetchCache(frontend, name) + +def fetchTextList(frontend, name, url, prepend): + try: + r = requests.get(url) + tmp = r.text.strip().split('\n') + + _list = {} + for network in config.networks: + _list[network] = [] + + for item in tmp: + item = prepend + item + if re.search(torRegex, item): + _list['tor'].append(item) + elif re.search(i2pRegex, item): + _list['i2p'].append(item) + elif re.search(lokiRegex, item): + _list['loki'].append(item) + else: + _list['clearnet'].append(item) + mightyList[frontend] = _list + print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + name) + except: + fetchCache(frontend, name) + def invidious(): - r = requests.get('https://api.invidious.io/instances.json') - rJson = json.loads(r.text) - invidiousList = {} - invidiousList['clearnet'] = [] - invidiousList['tor'] = [] - invidiousList['i2p'] = [] - invidiousList['loki'] = [] - for instance in rJson: - if instance[1]['type'] == 'https': - invidiousList['clearnet'].append(instance[1]['uri']) - elif instance[1]['type'] == 'onion': - invidiousList['tor'].append(instance[1]['uri']) - mightyList['invidious'] = invidiousList - print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'Invidious') + name = 'Invidious' + frontend = 'invidious' + try: + _list = {} + _list['clearnet'] = [] + _list['tor'] = [] + _list['i2p'] = [] + _list['loki'] = [] + r = requests.get('https://api.invidious.io/instances.json') + rJson = json.loads(r.text) + for instance in rJson: + if instance[1]['type'] == 'https': + _list['clearnet'].append(instance[1]['uri']) + elif instance[1]['type'] == 'onion': + _list['tor'].append(instance[1]['uri']) + mightyList[frontend] = _list + print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + name) + except: + fetchCache(frontend, name) def piped(): - r = requests.get( - 'https://raw.githubusercontent.com/wiki/TeamPiped/Piped/Instances.md') - - tmp = re.findall( - '(?:[^\s\/]+\.)+[a-zA-Z]+ (?:\(Official\) )?\| (https:\/{2}(?:[^\s\/]+\.)+[a-zA-Z]+) \| ', r.text) - _list = {} - _list['clearnet'] = [] - _list['tor'] = [] - _list['i2p'] = [] - _list['loki'] = [] - for item in tmp: - try: - url = requests.get(item, timeout=5).url - if url.strip("/") == item: + frontend = 'piped' + name = 'Piped' + try: + _list = {} + _list['clearnet'] = [] + _list['tor'] = [] + _list['i2p'] = [] + _list['loki'] = [] + r = requests.get( + 'https://raw.githubusercontent.com/wiki/TeamPiped/Piped/Instances.md') + + tmp = re.findall( + '(?:[^\s\/]+\.)+[a-zA-Z]+ (?:\(Official\) )?\| (https:\/{2}(?:[^\s\/]+\.)+[a-zA-Z]+) \| ', r.text) + for item in tmp: + try: + url = requests.get(item, timeout=5).url + if url.strip("/") == item: + continue + else: + _list['clearnet'].append(url) + except: continue - else: - _list['clearnet'].append(url) - except: - continue - mightyList['piped'] = _list - print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'Piped') + mightyList[frontend] = _list + print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + name) + except: + fetchCache(frontend, name) def pipedMaterial(): - r = requests.get( - 'https://raw.githubusercontent.com/mmjee/Piped-Material/master/README.md') - - tmp = re.findall( - r"\| (https?:\/{2}(?:\S+\.)+[a-zA-Z0-9]*) +\|", r.text) - pipedMaterialList = {} - pipedMaterialList['clearnet'] = [] - pipedMaterialList['tor'] = [] - pipedMaterialList['i2p'] = [] - pipedMaterialList['loki'] = [] - for item in tmp: - pipedMaterialList['clearnet'].append(item) - mightyList['pipedMaterial'] = pipedMaterialList - print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'pipedMaterial') + fetchRegexList('pipedMaterial', 'Piped-Material', 'https://raw.githubusercontent.com/mmjee/Piped-Material/master/README.md', r"\| (https?:\/{2}(?:\S+\.)+[a-zA-Z0-9]*) +\|") def cloudtube(): - json_object = json.dumps(mightyList, ensure_ascii=False, indent=2) - with open('./src/instances/cloudtube.json') as file: - mightyList['cloudtube'] = json.load(file) - print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'CloudTube') + fetchCache('cloudtube', 'Cloudtube') def proxitok(): @@ -186,19 +281,7 @@ def proxitok(): def send(): - r = requests.get( - 'https://gitlab.com/timvisee/send-instances/-/raw/master/README.md') - tmp = re.findall( - r"- ([-a-zA-Z0-9@:%_\+.~#?&//=]{2,}\.[a-z0-9]{2,}\b(?:\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?)\)*\|*[A-Z]{0,}", r.text) - sendList = {} - sendList['clearnet'] = [] - sendList['tor'] = [] - sendList['i2p'] = [] - sendList['loki'] = [] - for item in tmp: - sendList['clearnet'].append(item) - mightyList['send'] = sendList - print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'Send') + fetchRegexList('send', 'Send', 'https://gitlab.com/timvisee/send-instances/-/raw/master/README.md', r"- ([-a-zA-Z0-9@:%_\+.~#?&//=]{2,}\.[a-z0-9]{2,}\b(?:\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?)\)*\|*[A-Z]{0,}") def nitter(): @@ -230,150 +313,35 @@ def nitter(): def bibliogram(): - json_object = json.dumps(mightyList, ensure_ascii=False, indent=2) - with open('./src/instances/bibliogram.json') as file: - mightyList['bibliogram'] = json.load(file) - print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'Bibliogram') + fetchFromFile('bibliogram', 'Bibliogram') def libreddit(): - r = requests.get( - 'https://raw.githubusercontent.com/spikecodes/libreddit/master/README.md') - libredditList = {} - libredditList['clearnet'] = [] - libredditList['tor'] = [] - libredditList['i2p'] = [] - libredditList['loki'] = [] - - 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 re.search(torRegex, item): - libredditList['tor'].append(item) - else: - libredditList['clearnet'].append(item) - mightyList['libreddit'] = libredditList - print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'LibReddit') + fetchRegexList('libreddit', 'Libreddit', 'https://raw.githubusercontent.com/spikecodes/libreddit/master/README.md', r"\| \[.*\]\(([-a-zA-Z0-9@:%_\+.~#?&//=]{2,}\.[a-z]{2,}\b(?:\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?)\)*\|*[A-Z]{0,}.*\|.*\|") def teddit(): - r = requests.get( - 'https://codeberg.org/teddit/teddit/raw/branch/main/instances.json') - rJson = json.loads(r.text) - tedditList = {} - tedditList['clearnet'] = [] - tedditList['tor'] = [] - tedditList['i2p'] = [] - tedditList['loki'] = [] - for item in rJson: - url = item['url'] - if url != '': - tedditList['clearnet'].append(url) - if 'onion' in item: - onion = item['onion'] - if onion != '': - tedditList['tor'].append(onion) - - mightyList['teddit'] = tedditList - print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'Teddit') + fetchJsonList('teddit', 'Teddit', 'https://codeberg.org/teddit/teddit/raw/branch/main/instances.json', ['url', 'onion', 'i2p', None]) def wikiless(): - r = requests.get('https://wikiless.org/instances.json') - rJson = json.loads(r.text) - wikilessList = {} - wikilessList['clearnet'] = [] - wikilessList['tor'] = [] - wikilessList['i2p'] = [] - wikilessList['loki'] = [] - for item in rJson: - if 'url' in item: - if item['url'].strip() != "": - wikilessList['clearnet'].append(item['url']) - if 'onion' in item: - if item['onion'].strip() != "": - wikilessList['tor'].append(item['onion']) - if 'i2p' in item: - if item['i2p'].strip() != "": - wikilessList['i2p'].append(item['i2p']) - mightyList['wikiless'] = wikilessList - print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'Wikiless') + fetchJsonList('wikiless', 'Wikiless', 'https://wikiless.org/instances.json', ['url', 'onion', 'i2p', None]) def scribe(): - r = requests.get( - 'https://git.sr.ht/~edwardloveall/scribe/blob/main/docs/instances.json') - rJson = json.loads(r.text) - scribeList = {} - scribeList['clearnet'] = [] - scribeList['tor'] = [] - scribeList['i2p'] = [] - scribeList['loki'] = [] - for item in rJson: - scribeList['clearnet'].append(item) - mightyList['scribe'] = scribeList - print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'Scribe') + fetchJsonList('scribe', 'Scribe', 'https://git.sr.ht/~edwardloveall/scribe/blob/main/docs/instances.json', None) def quetre(): - r = requests.get( - 'https://raw.githubusercontent.com/zyachel/quetre/main/README.md') - _list = {} - _list['clearnet'] = [] - _list['tor'] = [] - _list['i2p'] = [] - _list['loki'] = [] - - 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 re.search(torRegex, item): - _list['tor'].append(item) - else: - _list['clearnet'].append(item) - mightyList['quetre'] = _list - print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'Quetre') + fetchRegexList('quetre', 'Quetre', 'https://raw.githubusercontent.com/zyachel/quetre/main/README.md', r"\| \[.*\]\(([-a-zA-Z0-9@:%_\+.~#?&//=]{2,}\.[a-z]{2,}\b(?:\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?)\)*\|*[A-Z]{0,}.*\|.*\|") def libremdb(): - r = requests.get( - 'https://raw.githubusercontent.com/zyachel/libremdb/main/README.md') - _list = {} - _list['clearnet'] = [] - _list['tor'] = [] - _list['i2p'] = [] - _list['loki'] = [] - - tmp = re.findall( - r"\| ([-a-zA-Z0-9@:%_\+.~#?&//=]{2,}\.[a-z]{2,}\b(?:\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?)*\|*[A-Z]{0,}.*\|.*\|", r.text) + fetchRegexList('libremdb', 'libremdb', 'https://raw.githubusercontent.com/zyachel/libremdb/main/README.md', r"\| ([-a-zA-Z0-9@:%_\+.~#?&//=]{2,}\.[a-z]{2,}\b(?:\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?)*\|*[A-Z]{0,}.*\|.*\|") - for item in tmp: - if item.strip() == "": - continue - if re.search(torRegex, item): - _list['tor'].append(item) - else: - _list['clearnet'].append(item) - - mightyList['libremdb'] = _list - print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'Libremdb') - def simpleertube(): - r = requests.get('https://simple-web.org/instances/simpleertube') - _list = {} - _list['clearnet'] = [] - _list['tor'] = [] - _list['i2p'] = [] - _list['loki'] = [] - for item in r.text.strip().split('\n'): - _list['clearnet'].append('https://' + item) - - mightyList['simpleertube'] = _list - print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'SimpleerTube') + fetchTextList('simpleertube', 'SimpleerTube', 'https://simple-web.org/instances/simpleertube', 'https://') def simplytranslate(): @@ -403,19 +371,7 @@ def simplytranslate(): def linvgatranslate(): - r = requests.get( - 'https://raw.githubusercontent.com/TheDavidDelta/lingva-translate/main/instances.json') - rJson = json.loads(r.text) - lingvaList = {} - lingvaList['clearnet'] = [] - lingvaList['tor'] = [] - lingvaList['i2p'] = [] - lingvaList['loki'] = [] - for item in rJson: - lingvaList['clearnet'].append(item) - - mightyList['lingva'] = lingvaList - print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'LinvgaTranslate') + fetchJsonList('lingva', 'LingvaTranslate', 'https://raw.githubusercontent.com/TheDavidDelta/lingva-translate/main/instances.json', None) def searx_searxng(): @@ -454,140 +410,34 @@ def searx_searxng(): def whoogle(): - r = requests.get( - 'https://raw.githubusercontent.com/benbusby/whoogle-search/main/misc/instances.txt') - tmpList = r.text.strip().split('\n') - whoogleList = {} - whoogleList['clearnet'] = [] - whoogleList['tor'] = [] - whoogleList['i2p'] = [] - whoogleList['loki'] = [] - for item in tmpList: - if re.search(torRegex, item): - whoogleList['tor'].append(item) - elif re.search(torRegex, item): - whoogleList['i2p'].append(item) - else: - whoogleList['clearnet'].append(item) - mightyList['whoogle'] = whoogleList - print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'Whoogle') + fetchTextList('whoogle', 'Whoogle', 'https://raw.githubusercontent.com/benbusby/whoogle-search/main/misc/instances.txt', '') def librex(): - r = requests.get( - 'https://raw.githubusercontent.com/hnhx/librex/main/README.md') - _list = {} - _list['clearnet'] = [] - _list['tor'] = [] - _list['i2p'] = [] - _list['loki'] = [] - - 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) - - for item in tmp: - if item.strip() == "": - continue - elif re.search(torRegex, item): - _list['tor'].append(item) - elif re.search(i2pRegex, item): - _list['i2p'].append(item) - else: - _list['clearnet'].append(item) - mightyList['librex'] = _list - print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'Librex') + fetchRegexList('librex', 'LibreX', 'https://raw.githubusercontent.com/hnhx/librex/main/README.md', r"\| {1,2}\[(?:(?:[a-zA-Z0-9]+\.)+[a-zA-Z]{2,}|✅)\]\((https?:\/{2}(?:[a-zA-Z0-9]+\.)+[a-zA-Z0-9]{2,})") def rimgo(): - r = requests.get( - 'https://codeberg.org/video-prize-ranch/rimgo/raw/branch/main/instances.json') - rJson = json.loads(r.text) - rimgoList = {} - rimgoList['clearnet'] = [] - rimgoList['tor'] = [] - rimgoList['i2p'] = [] - rimgoList['loki'] = [] - for item in rJson: - if 'url' in item: - rimgoList['clearnet'].append(item['url']) - if 'onion' in item: - rimgoList['tor'].append(item['onion']) - if 'i2p' in item: - rimgoList['i2p'].append(item['i2p']) - mightyList['rimgo'] = rimgoList - print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'Rimgo') + fetchJsonList('rimgo', 'rimgo', 'https://codeberg.org/video-prize-ranch/rimgo/raw/branch/main/instances.json', ['url', 'onion', 'i2p', None]) def librarian(): - r = requests.get( - 'https://codeberg.org/librarian/librarian/raw/branch/main/instances.json') - rJson = json.loads(r.text) - librarianList = {} - librarianList['clearnet'] = [] - librarianList['tor'] = [] - librarianList['i2p'] = [] - librarianList['loki'] = [] - instances = rJson['instances'] - for item in instances: - url = item['url'] - if url.strip() == "": - continue - elif re.search(torRegex, url): - librarianList['tor'].append(url) - elif re.search(i2pRegex, url): - librarianList['i2p'].append(url) - elif re.search(lokiRegex, url): - librarianList['loki'].append(url) - else: - librarianList['clearnet'].append(url) - mightyList['librarian'] = librarianList - print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'Librarian') - + fetchJsonList('librarian', 'Librarian', 'https://codeberg.org/librarian/librarian/raw/branch/main/instances.json', 'url') def neuters(): - json_object = json.dumps(mightyList, ensure_ascii=False, indent=2) - with open('./src/instances/neuters.json') as file: - mightyList['neuters'] = json.load(file) - print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'Neuters') + fetchFromFile('neuters', 'Neuters') def beatbump(): - json_object = json.dumps(mightyList, ensure_ascii=False, indent=2) - with open('./src/instances/beatbump.json') as file: - mightyList['beatbump'] = json.load(file) - print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'Beatbump') + fetchFromFile('beatbump', 'Beatbump') def hyperpipe(): - r = requests.get( - 'https://codeberg.org/Hyperpipe/pages/raw/branch/main/api/frontend.json') - rJson = json.loads(r.text) - hyperpipeList = {} - hyperpipeList['clearnet'] = [] - hyperpipeList['tor'] = [] - hyperpipeList['i2p'] = [] - hyperpipeList['loki'] = [] - for item in rJson: - url = item['url'] - if url.strip() == "": - continue - elif re.search(torRegex, url): - hyperpipeList['tor'].append(url) - elif re.search(i2pRegex, url): - hyperpipeList['i2p'].append(url) - elif re.search(lokiRegex, url): - hyperpipeList['loki'].append(url) - else: - hyperpipeList['clearnet'].append(url) - mightyList['hyperpipe'] = hyperpipeList - print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'Hyperpipe') + fetchJsonList('hyperpipe', 'Hyperpipe', 'https://codeberg.org/Hyperpipe/pages/raw/branch/main/api/frontend.json', 'url') def facil(): - json_object = json.dumps(mightyList, ensure_ascii=False, indent=2) - with open('./src/instances/facil.json') as file: - mightyList['facil'] = json.load(file) - print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'FacilMap') + fetchFromFile('facil', 'FacilMap') def peertube(): diff --git a/src/pages/options/index.ejs b/src/pages/options/index.ejs index 0240f992..e0ce3c3c 100644 --- a/src/pages/options/index.ejs +++ b/src/pages/options/index.ejs @@ -1,12 +1,12 @@ - <%- include('src/pages/widgets/head') %> + <%- include('src/pages/widgets/head') -%> - <%- include('src/pages/widgets/links', {config: config}) %> + <%- include('src/pages/widgets/links', {config: config}) -%>
- <%- include('src/pages/options/widgets/general', {config: config}) %> - <%- include('src/pages/options/widgets/services', {config: config}) %> - <%- include('src/pages/options/widgets/about') %> + <%- include('src/pages/options/widgets/general', {config: config}) -%> + <%- include('src/pages/options/widgets/services', {config: config}) -%> + <%- include('src/pages/options/widgets/about') -%>
diff --git a/src/pages/options/index.html b/src/pages/options/index.html index 8908c9bf..df6bec2a 100644 --- a/src/pages/options/index.html +++ b/src/pages/options/index.html @@ -8,50 +8,29 @@ General - -
@@ -69,16 +48,12 @@

+
@@ -145,126 +120,108 @@

Customize Popup

- - -
+

Youtube


Enable

- +
-

Frontend

- +

Frontend

+
- - -
+

Embed Frontend

- - -
+

Redirect Type

- - - + +
- -
- -
- -
+
+
+

Default Instances

@@ -359,8 +294,7 @@
- -
+
- -
- -
+
+

Default Instances

@@ -392,10 +324,8 @@
- -
- -
+
+

Default Instances

@@ -415,10 +345,8 @@
- -
- -
+
+

Default Instances

@@ -438,14 +366,11 @@
- -
+
- -
- -
+
+

Default Instances

@@ -465,8 +390,7 @@
- -
+
- -
- -
+
+

Default Instances

@@ -498,10 +420,8 @@
- -
- -
+
+

Default Instances

@@ -521,10 +441,8 @@
- -
- -
+
+

Default Instances

@@ -544,14 +462,11 @@
- -
+
- -
- -
+
+

Default Instances

@@ -571,8 +486,7 @@
- -
+
- -
- -
+
+

Default Instances

@@ -604,10 +516,8 @@
- -
- -
+
+

Default Instances

@@ -627,10 +537,8 @@
- -
- -
+
+

Default Instances

@@ -650,14 +558,11 @@
- -
+ - -
- -
+
+

Default Instances

@@ -677,8 +582,7 @@
- -
+
- -
- -
+
+

Default Instances

@@ -710,10 +612,8 @@
- -
- -
+
+

Default Instances

@@ -733,10 +633,8 @@
- -
- -
+
+

Default Instances

@@ -756,13 +654,11 @@
- -
+ - + -

YT Music

@@ -770,28 +666,20 @@

Enable

- +
-

Frontend

- +

Frontend

+
- - - -
- -
- -
+
+
+

Default Instances

@@ -811,8 +699,7 @@
- -
+
- -
- -
+
+

Default Instances

@@ -844,10 +729,8 @@
- -
- -
+
+

Default Instances

@@ -867,10 +750,8 @@
- -
- -
+
+

Default Instances

@@ -890,14 +771,11 @@
- -
+
- -
- -
+
+

Default Instances

@@ -917,8 +795,7 @@
- -
+
- -
- -
+
+

Default Instances

@@ -950,10 +825,8 @@
- -
- -
+
+

Default Instances

@@ -973,10 +846,8 @@
- -
- -
+
+

Default Instances

@@ -996,13 +867,11 @@
- -
+ - +
-

Twitter

@@ -1010,25 +879,19 @@

Enable

- +
- - - -
+

Redirect Type

- - - + +
- -
- -
- -
+
+
+

Default Instances

@@ -1048,8 +911,7 @@
- -
+
- -
- -
+
+

Default Instances

@@ -1081,10 +941,8 @@
- -
- -
+
+

Default Instances

@@ -1104,10 +962,8 @@
- -
- -
+
+

Default Instances

@@ -1127,13 +983,11 @@
- -
+
- +
-

Instagram

@@ -1141,121 +995,11 @@

Enable

- +
- - - -
- -
- -
-
-

Default Instances

-
-
-
-
-

Custom Instances

-
-
-
- - -
-
-
- -
- - -
- -
- -
-
-

Default Instances

-
-

-
-

Custom Instances

-
-
-
- - -
-
-
-
- -
-
-

Default Instances

-
-
-
-
-

Custom Instances

-
-
-
- - -
-
-
- -
- -
-
-

Default Instances

-
-
-
-
-

Custom Instances

-
-
-
- - -
-
-
- -
- -
-
-

TikTok

@@ -1263,16 +1007,11 @@

Enable

- +
- - - -
- -
- -
+
+
+

Default Instances

@@ -1292,8 +1031,7 @@
- -
+
- -
- -
+
+

Default Instances

@@ -1325,10 +1061,8 @@
- -
- -
+
+

Default Instances

@@ -1348,10 +1082,8 @@
- -
- -
+
+

Default Instances

@@ -1371,13 +1103,11 @@
- -
+
- +
-

Reddit

@@ -1385,28 +1115,20 @@

Enable

- +
-

Frontend

- +

Frontend

+
- - - -
- -
- -
+
+
+

Default Instances

@@ -1426,8 +1148,7 @@
- -
+
- -
- -
+
+

Default Instances

@@ -1459,10 +1178,8 @@
- -
- -
+
+

Default Instances

@@ -1482,10 +1199,8 @@
- -
- -
+
+

Default Instances

@@ -1505,14 +1220,11 @@
- -
+
- -
- -
+
+

Default Instances

@@ -1532,8 +1244,7 @@
- -
+
- -
- -
+
+

Default Instances

@@ -1565,10 +1274,8 @@
- -
- -
+
+

Default Instances

@@ -1588,10 +1295,8 @@
- -
- -
+
+

Default Instances

@@ -1611,13 +1316,11 @@
- -
+ - +
-

Imgur

@@ -1625,16 +1328,11 @@

Enable

- +
- - - -
- -
- -
+
+
+

Default Instances

@@ -1654,8 +1352,7 @@
- -
+
- -
- -
+
+

Default Instances

@@ -1687,10 +1382,8 @@
- -
- -
+
+

Default Instances

@@ -1710,10 +1403,8 @@
- -
- -
+
+

Default Instances

@@ -1733,13 +1424,11 @@
- -
+
- +
-

Wikipedia

@@ -1747,16 +1436,11 @@

Enable

- +
- - - -
- -
- -
+
+
+

Default Instances

@@ -1776,8 +1460,7 @@
- -
+
- -
- -
+
+

Default Instances

@@ -1809,10 +1490,8 @@
- -
- -
+
+

Default Instances

@@ -1832,10 +1511,8 @@
- -
- -
+
+

Default Instances

@@ -1855,13 +1532,11 @@
- -
+
- +
-

Medium

@@ -1869,16 +1544,11 @@

Enable

- +
- - - -
- -
- -
+
+
+

Default Instances

@@ -1898,8 +1568,7 @@
- -
+
- -
- -
+
+

Default Instances

@@ -1931,10 +1598,8 @@
- -
- -
+
+

Default Instances

@@ -1954,10 +1619,8 @@
- -
- -
+
+

Default Instances

@@ -1977,13 +1640,11 @@
- -
+
- +
-

Quora

@@ -1991,16 +1652,11 @@

Enable

- +
- - - -
- -
- -
+
+
+

Default Instances

@@ -2020,8 +1676,7 @@
- -
+
- -
- -
+
+

Default Instances

@@ -2053,10 +1706,8 @@
- -
- -
+
+

Default Instances

@@ -2076,10 +1727,8 @@
- -
- -
+
+

Default Instances

@@ -2099,13 +1748,11 @@
- -
+
- +
-

IMDb

@@ -2113,16 +1760,11 @@

Enable

- +
- - - -
- -
- -
+
+
+

Default Instances

@@ -2142,8 +1784,7 @@
- -
+
- -
- -
+
+

Default Instances

@@ -2175,10 +1814,8 @@
- -
- -
+
+

Default Instances

@@ -2198,10 +1835,8 @@
- -
- -
+
+

Default Instances

@@ -2221,13 +1856,11 @@
- -
+
- +
-

Reuters

@@ -2235,16 +1868,11 @@

Enable

- +
- - - -
- -
- -
+
+
+

Default Instances

@@ -2264,8 +1892,7 @@
- -
+
- -
- -
+
+

Default Instances

@@ -2297,10 +1922,8 @@
- -
- -
+
+

Default Instances

@@ -2320,10 +1943,8 @@
- -
- -
+
+

Default Instances

@@ -2343,13 +1964,11 @@
- -
+
- +
-

PeerTube

@@ -2357,16 +1976,11 @@

Enable

- +
- - - -
- -
- -
+
+
+

Default Instances

@@ -2386,8 +2000,7 @@
- -
+
- -
- -
+
+

Default Instances

@@ -2419,10 +2030,8 @@
- -
- -
+
+

Default Instances

@@ -2442,10 +2051,8 @@
- -
- -
+
+

Default Instances

@@ -2465,13 +2072,11 @@
- -
+
- +
-

LBRY

@@ -2479,37 +2084,37 @@

Enable

- +
-

Frontend

- +

Frontend

+
- - - -
+
+
+

Embed Frontend

+ +
+
+

Redirect Type

- - - + +
- -
- -
- -
+
+
+

Default Instances

@@ -2529,8 +2134,7 @@
- -
+
- -
- -
+
+

Default Instances

@@ -2562,10 +2164,8 @@
- -
- -
+
+

Default Instances

@@ -2585,10 +2185,8 @@
- -
- -
+
+

Default Instances

@@ -2608,13 +2206,11 @@
- -
+
- +
-

Search

@@ -2622,32 +2218,22 @@

Enable

- +
-

Frontend

- +

Frontend

+
- - - -
- -
- -
+
+
+

Default Instances

@@ -2667,8 +2253,7 @@
- -
+
- -
- -
+
+

Default Instances

@@ -2700,10 +2283,8 @@
- -
- -
+
+

Default Instances

@@ -2723,10 +2304,8 @@
- -
- -
+
+

Default Instances

@@ -2746,14 +2325,11 @@
- -
+
- -
- -
+
+

Default Instances

@@ -2773,8 +2349,7 @@
- -
+
- -
- -
+
+

Default Instances

@@ -2806,10 +2379,8 @@
- -
- -
+
+

Default Instances

@@ -2829,10 +2400,8 @@
- -
- -
+
+

Default Instances

@@ -2852,14 +2421,11 @@
- -
+ - -
- -
+
+

Default Instances

@@ -2879,8 +2445,7 @@
- -
+
- -
- -
+
+

Default Instances

@@ -2912,10 +2475,8 @@
- -
- -
+
+

Default Instances

@@ -2935,10 +2496,8 @@
- -
- -
+
+

Default Instances

@@ -2958,14 +2517,11 @@
- -
+ - -
- -
+
+

Default Instances

@@ -2985,8 +2541,7 @@
- -
+
- -
- -
+
+

Default Instances

@@ -3018,10 +2571,8 @@
- -
- -
+
+

Default Instances

@@ -3041,10 +2592,8 @@
- -
- -
+
+

Default Instances

@@ -3064,13 +2613,11 @@
- -
+ - +
-

Translate

@@ -3078,28 +2625,20 @@

Enable

- +
-

Frontend

- +

Frontend

+
- - - -
- -
- -
+
+
+

Default Instances

@@ -3119,8 +2658,7 @@
- -
+
- -
- -
+
+

Default Instances

@@ -3152,10 +2688,8 @@
- -
- -
+
+

Default Instances

@@ -3175,10 +2709,8 @@
- -
- -
+
+

Default Instances

@@ -3198,14 +2730,11 @@
- -
+
- -
- -
+
+

Default Instances

@@ -3225,8 +2754,7 @@
- -
+
- -
- -
+
+

Default Instances

@@ -3258,10 +2784,8 @@
- -
- -
+
+

Default Instances

@@ -3281,10 +2805,8 @@
- -
- -
+
+

Default Instances

@@ -3304,13 +2826,11 @@
- -
+ - +
-

Maps

@@ -3318,28 +2838,20 @@

Enable

- +
-

Frontend

- +

Frontend

+
- - - -
- -
- -
+
+
+

Default Instances

@@ -3359,8 +2871,7 @@
- -
+
- -
- -
+
+

Default Instances

@@ -3392,10 +2901,8 @@
- -
- -
+
+

Default Instances

@@ -3415,10 +2922,8 @@
- -
- -
+
+

Default Instances

@@ -3438,13 +2943,11 @@
- -
+
- +
-

Send Files

@@ -3452,16 +2955,11 @@

Enable

- +
- - - -
- -
- -
+
+
+

Default Instances

@@ -3481,8 +2979,7 @@
- -
+
- -
- -
+
+

Default Instances

@@ -3514,10 +3009,8 @@
- -
- -
+
+

Default Instances

@@ -3537,10 +3030,8 @@
- -
- -
+
+

Default Instances

@@ -3560,15 +3051,13 @@
- -
+
- +
-

About

@@ -3593,7 +3082,6 @@
- diff --git a/src/pages/options/widgets/general.ejs b/src/pages/options/widgets/general.ejs index 05ef0959..d68a2280 100644 --- a/src/pages/options/widgets/general.ejs +++ b/src/pages/options/widgets/general.ejs @@ -14,10 +14,10 @@

+
@@ -84,14 +84,14 @@

Customize Popup

diff --git a/src/pages/options/widgets/services.ejs b/src/pages/options/widgets/services.ejs index aed5872b..bc75f288 100644 --- a/src/pages/options/widgets/services.ejs +++ b/src/pages/options/widgets/services.ejs @@ -1,4 +1,4 @@ -<% for (const service in config.services) { %> +<% for (const service in config.services) { -%>

<%= config.services[service].name %>

@@ -6,47 +6,47 @@

Enable

- +
- <% if ((Object.keys(config.services[service].frontends).length > 1) || config.services[service].singleInstanceFrontends) { %> + <% if (Object.keys(config.services[service].frontends).length > 1) { %>
-

Frontend

- +

Frontend

+
- <% } %> - <% if ((config.services[service].singleInstanceFrontends) && (Object.keys(config.services[service].frontends).length > 1)) { %> -
+ <% if (config.services[service].embeddable) { _%> +

Embed Frontend

- <% } %> - <% if (config.services[service].embeddable) { %> + <% } _%> + <% } _%> + <% if (config.services[service].embeddable) { _%>

Redirect Type

- - - + +
- <% } %> + <% } _%>
- <% for (const frontend in config.services[service].frontends) { %> + <% for (const frontend in config.services[service].frontends) { -%> + <% if (config.services[service].frontends[frontend].instanceList) { _%>
- <% for (const network in config.networks) { %> + <% for (const network in config.networks) { -%>

Default Instances

@@ -67,7 +67,7 @@
- <% if (network == "clearnet") { %> + <% if (network == "clearnet") { _%>
- <% } %> + <% } _%>
- <% }; %> + <% } %>
- <% }; %> + <% } _%> + <% } %>
-<% }; %> +<% } %> diff --git a/src/pages/options/widgets/services.js b/src/pages/options/widgets/services.js index c7955b40..4a53a749 100644 --- a/src/pages/options/widgets/services.js +++ b/src/pages/options/widgets/services.js @@ -1,13 +1,10 @@ import utils from "../../../assets/javascripts/utils.js" -// const frontends = new Array("librarian") -// const protocols = new Array("clearnet", "tor", "i2p", "loki") - let config, network, divs = {} -async function getConfig() { +function getConfig() { return new Promise(resolve => { fetch("/config/config.json") .then(response => response.text()) @@ -19,7 +16,7 @@ async function getConfig() { }) } -getConfig() +await getConfig() browser.storage.local.get("network", r => { network = r.network @@ -27,45 +24,50 @@ browser.storage.local.get("network", r => { function changeFrontendsSettings(service) { for (const frontend in config.services[service].frontends) { - const frontendDiv = document.getElementById(frontend) - if (frontend == divs[service].frontend.value) { - frontendDiv.style.display = "block" - } else { - frontendDiv.style.display = "none" + if (config.services[service].frontends[frontend].instanceList && config.services[service].frontends.length > 1) { + const frontendDiv = document.getElementById(frontend) + if (divs[service].frontend == null) { + console.log(frontend) + } + if (frontend == divs[service].frontend.value) { + frontendDiv.style.display = "block" + } else { + frontendDiv.style.display = "none" + } } } } function changeNetworkSettings(selectedNetwork) { for (const frontend in config.frontends) { - const frontendDiv = document.getElementById(frontend) - for (const network in config.networks) { - const networkDiv = frontendDiv.getElementsByClassName(network)[0] - if (network == selectedNetwork) { - networkDiv.style.display = "block" - } else { - networkDiv.style.display = "none" + if (config.services[service].frontends[frontend].instanceList) { + const frontendDiv = document.getElementById(frontend) + for (const network in config.networks) { + const networkDiv = frontendDiv.getElementsByClassName(network)[0] + if (network == selectedNetwork) { + networkDiv.style.display = "block" + } else { + networkDiv.style.display = "none" + } } } } } -for (service in config.services) { +for (const service in config.services) { + divs[service] = {} divs[service][service] = document.getElementById(`${service}_page`) for (const option in config.services[service].options) { divs[service][option] = document.getElementById(`${service}-${option}`) browser.storage.local.get([`${service + utils.camelCase(option)}`], r => { - if (typeof config.services[service].options[option] == "boollean") divs[service][option].checked = !r[service + utils.camelCase(option)] + if (typeof config.services[service].options[option] == "boollean") divs[service][option].checked = r[service + utils.camelCase(option)] else divs[service][option].value = !r[service + utils.camelCase(option)] }) divs[service][option].addEventListener("change", () => { - if (typeof config.services[service].options[option] == "boollean") { - browser.storage.local.set({ [service + utils.camelCase(option)]: !divs[service][option].checked }) - } else { - browser.storage.local.set({ [service + utils.camelCase(option)]: divs[service][option].value }) - } + if (typeof config.services[service].options[option] == "boollean") browser.storage.local.set({ [service + utils.camelCase(option)]: divs[service][option].checked }) + else browser.storage.local.set({ [service + utils.camelCase(option)]: divs[service][option].value }) changeFrontendsSettings() }) } @@ -74,9 +76,11 @@ for (service in config.services) { changeNetworkSettings(network) for (const frontend in config.services[service].frontends) { - for (const network in config.networks) { - utils.processDefaultCustomInstances(service, frontend, network, document) + if (config.services[service].frontends[frontend].instanceList) { + for (const network in config.networks) { + utils.processDefaultCustomInstances(service, frontend, network, document) + } + utils.latency(service, frontend, document, location) } - utils.latency(service, frontend, document, location) } } diff --git a/src/pages/widgets/links.ejs b/src/pages/widgets/links.ejs index fe0cd37c..c28d3668 100644 --- a/src/pages/widgets/links.ejs +++ b/src/pages/widgets/links.ejs @@ -1,7 +1,7 @@ -- cgit 1.4.1 From 098e7368a743b61f36e920e2e01df764441786b6 Mon Sep 17 00:00:00 2001 From: Hygna Date: Mon, 19 Sep 2022 19:52:26 +0100 Subject: Fixed bugs introduced in the previous commit --- src/instances/get_instances.py | 53 +++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 26 deletions(-) (limited to 'src/instances') diff --git a/src/instances/get_instances.py b/src/instances/get_instances.py index 770f2581..3dcb42b4 100644 --- a/src/instances/get_instances.py +++ b/src/instances/get_instances.py @@ -9,6 +9,7 @@ from urllib.parse import urlparse import socket mightyList = {} +config = {} startRegex = "https?:\/{2}(?:[^\s\/]+\.)+" endRegex = "(?:\/[^\s\/]+)*\/?" @@ -16,10 +17,10 @@ torRegex = startRegex + "onion" + endRegex i2pRegex = startRegex + "i2p" + endRegex lokiRegex = startRegex + "loki" + endRegex authRegex = "https?:\/{2}\S+:\S+@(?:[^\s\/]+\.)+[a-zA-Z0-9]+" + endRegex -config = {} -with open('./config/config.json') as file: - config = file +with open('./src/config/config.json', 'rt') as tmp: + config['networks'] = json.load(tmp)['config']['networks'] + def filterLastSlash(urlList): @@ -108,8 +109,8 @@ def is_offline(url): def fetchCache(frontend, name) : # json_object = json.dumps(mightyList, ensure_ascii=False, indent=2) with open('./src/instances/data.json') as file: - mightyList[frontend] = json.load(file).frontend - print(Fore.ORANGE + 'Failed' + Style.RESET_ALL + ' to fetch ' + name) + mightyList[frontend] = json.load(file)[frontend] + print(Fore.YELLOW + 'Failed' + Style.RESET_ALL + ' to fetch ' + name) def fetchFromFile(frontend, name): #json_object = json.dumps(mightyList, ensure_ascii=False, indent=2) @@ -122,32 +123,31 @@ def fetchJsonList(frontend, name, url, urlItem): r = requests.get(url) rJson = json.loads(r.text) _list = {} - for network in config.networks: + for network in config['networks']: _list[network] = [] - if type(urlItem) is 'str': + if type(urlItem) == 'str': for item in rJson: + tmpItem = item if urlItem is not None: - tmpUrl = item[urlItem] - else: - tmpUrl = item - if tmpUrl.strip() == "": + tmpItem = item[urlItem] + if tmpItem.strip() == '': continue - elif re.search(torRegex, tmpUrl): - _list['tor'].append(tmpUrl) - elif re.search(i2pRegex, tmpUrl): - _list['i2p'].append(tmpUrl) - elif re.search(lokiRegex, tmpUrl): - _list['loki'].append(tmpUrl) + elif re.search(torRegex, tmpItem): + _list['tor'].append(tmpItem) + elif re.search(i2pRegex, tmpItem): + _list['i2p'].append(tmpItem) + elif re.search(lokiRegex, tmpItem): + _list['loki'].append(tmpItem) else: - _list['clearnet'].append(tmpUrl) + _list['clearnet'].append(tmpItem) else: - for i in range(config.networks.length): + for i in range(len(config['networks']) - 1): # The expected order is the same as in config.json. If the frontend doesn't have any instances for a specified network, use None if urlItem != None: for item in rJson: if network in item: - if item[network].strip() != "": - _list[config.networks[i]].append(item[urlItem[i]]) + if item[network].strip() != '': + _list[config['networks'][i]].append(item[urlItem[i]]) mightyList[frontend] = _list print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + name) @@ -158,7 +158,7 @@ def fetchRegexList(frontend, name, url, regex): try: r = requests.get(url) _list = {} - for network in config.networks: + for network in config['networks']: _list[network] = [] tmp = re.findall(regex, r.text) @@ -185,7 +185,7 @@ def fetchTextList(frontend, name, url, prepend): tmp = r.text.strip().split('\n') _list = {} - for network in config.networks: + for network in config['networks']: _list[network] = [] for item in tmp: @@ -207,13 +207,14 @@ def fetchTextList(frontend, name, url, prepend): def invidious(): name = 'Invidious' frontend = 'invidious' + url = 'https://api.invidious.io/instances.json' try: _list = {} _list['clearnet'] = [] _list['tor'] = [] _list['i2p'] = [] _list['loki'] = [] - r = requests.get('https://api.invidious.io/instances.json') + r = requests.get(url) rJson = json.loads(r.text) for instance in rJson: if instance[1]['type'] == 'https': @@ -256,11 +257,11 @@ def piped(): def pipedMaterial(): - fetchRegexList('pipedMaterial', 'Piped-Material', 'https://raw.githubusercontent.com/mmjee/Piped-Material/master/README.md', r"\| (https?:\/{2}(?:\S+\.)+[a-zA-Z0-9]*) +\|") + fetchRegexList('pipedMaterial', 'Piped-Material', 'https://raw.githubusercontent.com/mmjee/Piped-Material/master/README.md', r"\| (https?:\/{2}(?:\S+\.)+[a-zA-Z0-9]*) +\| Production") def cloudtube(): - fetchCache('cloudtube', 'Cloudtube') + fetchFromFile('cloudtube', 'Cloudtube') def proxitok(): -- cgit 1.4.1 From 8f05957ffad01824448397574851719f4f562e58 Mon Sep 17 00:00:00 2001 From: Hygna Date: Tue, 20 Sep 2022 22:24:19 +0100 Subject: Fixed more bugs --- src/assets/javascripts/services.js | 61 ++++++++++++++++------------------- src/instances/get_instances.py | 28 ++++++++-------- src/pages/options/widgets/services.js | 6 ++-- 3 files changed, 45 insertions(+), 50 deletions(-) (limited to 'src/instances') diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js index affe0d1a..fff32275 100644 --- a/src/assets/javascripts/services.js +++ b/src/assets/javascripts/services.js @@ -25,14 +25,12 @@ function init() { options.networkFallback = r.networkFallback options.redirects = r.redirects }) - //cur = current for (const service in config.services) { options[service] = {} browser.storage.local.get([`${utils.camelCase(service)}Enable`, `${service}RedirectType`, `${service}Frontend`], r => { options[service].enabled = r[utils.camelCase(service) + "Enable"] options[service].frontend = r[service + "Frontend"] options[service].redirectType = r[service + "RedirectType"] - // console.log(r) }) for (const frontend in config.services[service].frontends) { options[frontend] = {} @@ -40,8 +38,6 @@ function init() { options[frontend].custom = [] for (const network in config.networks) { browser.storage.local.get([`${frontend}${utils.camelCase(network)}RedirectsChecks`, `${frontend}${utils.camelCase(network)}CustomRedirects`], r => { - // console.log(r) - // console.log(`${frontend}${utils.camelCase(network)}RedirectsChecks`) options[frontend].checks = r[frontend + utils.camelCase(network) + "RedirectsChecks"] options[frontend].custom = r[frontend + utils.camelCase(network) + "CustomRedirects"] }) @@ -390,46 +386,45 @@ function initDefaults() { .then(async data => { let dataJson = JSON.parse(data) redirects = dataJson - // console.log(redirects) - // console.log(config) - browser.storage.local.set({ - redirects: redirects.invidious, - }) browser.storage.local.get(["cloudflareBlackList", "authenticateBlackList", "offlineBlackList"], async r => { - // console.log(r) for (const service in config.services) { if (config.services[service].targets == "datajson") { - browser.storage.local.set({ [service + "Targets"]: redirects[service] }) + browser.storage.local.set({ [service + "Targets"]: [...dataJson[service]] }) + delete redirects[service] } - for (const defaultOption in config.services[service].defaults) { - browser.storage.local.set({ [service + camelCase(defaultOption)]: config.services[service].defaults[defaultOption] }) + for (const defaultOption in config.services[service].options) { + browser.storage.local.set({ [service + utils.camelCase(defaultOption)]: config.services[service].options[defaultOption] }) } for (const frontend in config.services[service].frontends) { - let clearnetChecks = redirects[frontend].clearnet - for (const instance of [...r.cloudflareBlackList, ...r.authenticateBlackList, ...r.offlineBlackList]) { - let i = clearnetChecks.indexOf(instance) - if (i > -1) clearnetChecks.splice(i, 1) - } - for (const network in config.networks) { - // console.log(redirects[frontend][network]) - switch (network) { - case "clearnet": - browser.storage.local.set({ - [frontend + "ClearnetRedirectsChecks"]: [clearnetChecks], - [frontend + "ClearnetCustomRedirects"]: [], - }) - break - default: - browser.storage.local.set({ - [frontend + utils.camelCase(network) + "RedirectsChecks"]: [...redirects[frontend][network]], - [frontend + utils.camelCase(network) + "CustomRedirects"]: [], - }) + if (config.services[service].frontends[frontend].instanceList) { + let clearnetChecks = redirects[frontend].clearnet + for (const instance of [...r.cloudflareBlackList, ...r.authenticateBlackList, ...r.offlineBlackList]) { + let i = clearnetChecks.indexOf(instance) + if (i > -1) clearnetChecks.splice(i, 1) + } + for (const network in config.networks) { + switch (network) { + case "clearnet": + browser.storage.local.set({ + [frontend + "ClearnetRedirectsChecks"]: [...clearnetChecks], + [frontend + "ClearnetCustomRedirects"]: [], + }) + break + default: + browser.storage.local.set({ + [frontend + utils.camelCase(network) + "RedirectsChecks"]: [...redirects[frontend][network]], + [frontend + utils.camelCase(network) + "CustomRedirects"]: [], + }) + } } } } } - ;() => resolve() }) + browser.storage.local.set({ + redirects, + }) + ;() => resolve() }) }) } diff --git a/src/instances/get_instances.py b/src/instances/get_instances.py index 3dcb42b4..2547917a 100644 --- a/src/instances/get_instances.py +++ b/src/instances/get_instances.py @@ -22,7 +22,6 @@ with open('./src/config/config.json', 'rt') as tmp: config['networks'] = json.load(tmp)['config']['networks'] - def filterLastSlash(urlList): tmp = {} for x in urlList: @@ -106,7 +105,7 @@ def is_offline(url): except: return False -def fetchCache(frontend, name) : +def fetchCache(frontend, name): # json_object = json.dumps(mightyList, ensure_ascii=False, indent=2) with open('./src/instances/data.json') as file: mightyList[frontend] = json.load(file)[frontend] @@ -125,7 +124,16 @@ def fetchJsonList(frontend, name, url, urlItem): _list = {} for network in config['networks']: _list[network] = [] - if type(urlItem) == 'str': + if type(urlItem) == dict: + for item in rJson: + for network in config['networks']: + if urlItem[network] != None: + if urlItem[network] in item: + if item[urlItem[network]].strip() != '': + _list[network].append(item[urlItem[network]]) + else: + if frontend == 'librarian': + rJson = rJson['instances'] # I got lazy :p Might fix this at some point... for item in rJson: tmpItem = item if urlItem is not None: @@ -140,14 +148,6 @@ def fetchJsonList(frontend, name, url, urlItem): _list['loki'].append(tmpItem) else: _list['clearnet'].append(tmpItem) - else: - for i in range(len(config['networks']) - 1): - # The expected order is the same as in config.json. If the frontend doesn't have any instances for a specified network, use None - if urlItem != None: - for item in rJson: - if network in item: - if item[network].strip() != '': - _list[config['networks'][i]].append(item[urlItem[i]]) mightyList[frontend] = _list print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + name) @@ -322,11 +322,11 @@ def libreddit(): def teddit(): - fetchJsonList('teddit', 'Teddit', 'https://codeberg.org/teddit/teddit/raw/branch/main/instances.json', ['url', 'onion', 'i2p', None]) + fetchJsonList('teddit', 'Teddit', 'https://codeberg.org/teddit/teddit/raw/branch/main/instances.json', { 'clearnet': 'url', 'tor': 'onion', 'i2p': 'i2p', 'loki': None }) def wikiless(): - fetchJsonList('wikiless', 'Wikiless', 'https://wikiless.org/instances.json', ['url', 'onion', 'i2p', None]) + fetchJsonList('wikiless', 'Wikiless', 'https://wikiless.org/instances.json', { 'clearnet': 'url', 'tor': 'onion', 'i2p': 'i2p', 'loki': None}) def scribe(): @@ -419,7 +419,7 @@ def librex(): def rimgo(): - fetchJsonList('rimgo', 'rimgo', 'https://codeberg.org/video-prize-ranch/rimgo/raw/branch/main/instances.json', ['url', 'onion', 'i2p', None]) + fetchJsonList('rimgo', 'rimgo', 'https://codeberg.org/video-prize-ranch/rimgo/raw/branch/main/instances.json', {'clearnet': 'url', 'tor': 'onion', 'i2p': 'i2p', 'loki': None}) def librarian(): diff --git a/src/pages/options/widgets/services.js b/src/pages/options/widgets/services.js index 4a53a749..33c174f9 100644 --- a/src/pages/options/widgets/services.js +++ b/src/pages/options/widgets/services.js @@ -1,7 +1,7 @@ import utils from "../../../assets/javascripts/utils.js" let config, - network, + selectedNetwork, divs = {} function getConfig() { @@ -19,7 +19,7 @@ function getConfig() { await getConfig() browser.storage.local.get("network", r => { - network = r.network + selectedNetwork = r.network }) function changeFrontendsSettings(service) { @@ -54,6 +54,7 @@ function changeNetworkSettings(selectedNetwork) { } } +changeNetworkSettings(selectedNetwork) for (const service in config.services) { divs[service] = {} divs[service][service] = document.getElementById(`${service}_page`) @@ -73,7 +74,6 @@ for (const service in config.services) { } changeFrontendsSettings(service) - changeNetworkSettings(network) for (const frontend in config.services[service].frontends) { if (config.services[service].frontends[frontend].instanceList) { -- cgit 1.4.1 From b2b9adfa97adc2d3784f5d76f670b919bb6a64fe Mon Sep 17 00:00:00 2001 From: Hygna Date: Tue, 20 Sep 2022 22:27:56 +0100 Subject: Update instances to match new structure --- src/instances/blacklist.json | 58 ++++-- src/instances/data.json | 430 +++++++++++++++++++++---------------------- 2 files changed, 252 insertions(+), 236 deletions(-) (limited to 'src/instances') diff --git a/src/instances/blacklist.json b/src/instances/blacklist.json index e7756f8e..fe941df0 100644 --- a/src/instances/blacklist.json +++ b/src/instances/blacklist.json @@ -1,29 +1,36 @@ { "cloudflare": [ "https://invidious.kavin.rocks", + "https://invidious.rhyshl.live", "https://piped.kavin.rocks", "https://piped.tokhmi.xyz", "https://piped.moomoo.me", "https://piped.mha.fi", "https://de-piped.shimul.me", "https://pipedus.palash.dev", - "https://piped.waffle.wiki", "https://watch.whatever.social", + "https://piped.garudalinux.org", + "https://y.rivo.lol", + "https://cringe.whatever.social", "https://nitter.domain.glass", "https://birdsite.xanny.family", + "https://nitter.it", "https://notabird.site", "https://fuckthesacklers.network", "https://nitter.winscloud.net", "https://twtr.bch.bar", "https://twitter.dr460nf1r3.org", "https://nitter.garudalinux.org", - "https://nitter.wef.lol", "https://nitter.catalyst.sx", "https://nitter.fprivacy.com", - "https://bib.actionsack.com", + "https://read.whatever.social", + "https://nitter.rawbit.ninja", + "https://nitter.privacytools.io", + "https://nitter.sneed.network", + "https://n.sneed.network", + "https://nitter.twei.space", "https://libreddit.domain.glass", "https://r.nf", - "https://lr.oversold.host", "https://libreddit.hu", "https://lr.stilic.ml", "https://reddi.tk", @@ -32,6 +39,7 @@ "https://libreddit.winscloud.net", "https://r.ahwx.org", "https://reddit.dr460nf1r3.org", + "https://libreddit.mha.fi", "https://libreddit.encrypted-data.xyz", "https://libreddit.eu.org", "https://teddit.domain.glass", @@ -39,44 +47,54 @@ "https://teddit.encrypted-data.xyz", "https://teddit.garudalinux.org", "https://tedd.it", + "https://wiki.privacytools.io", + "https://teddit.rawbit.ninja", "https://wiki.604kph.xyz", + "https://wiki.privacytools.io", + "https://wikiless.rawbit.ninja", + "https://scribe.rawbit.ninja", "https://lingva.garudalinux.org", "https://translate.dr460nf1r3.org", - "https://searx.org", "https://searx.run", - "https://search.albony.xyz", + "https://searx.org", "https://search.garudalinux.org", "https://search.dr460nf1r3.org", "https://search.wef.lol", "https://i.actionsack.com", "https://rimgo.encrypted-data.xyz", - "https://beatbump.ml" + "https://beatbump.ml", + "https://listen.whatever.social" ], "authenticate": [ "https://nitter:nitter@nitter.nixnet.services" ], "offline": [ - "https://invidious.snopyta.org", - "https://tok.habedieeh.re", - "https://n.hyperborea.cloud", - "https://nitter.spaceint.fr", - "https://bibliogram.snopyta.org", - "https://libreddit.autarkic.org", + "https://invidious.rhyshl.live", + "https://proxitok.odyssey346.dev", + "https://nhanh.cloud", + "https://nitter.nl", + "https://ntr.odyssey346.dev", + "https://libreddit.nl", "https://libreddit.notyourcomputer.net", - "https://anon.sx", + "https://teddit.ggc-project.de", + "https://teddit.nautolan.racing", + "https://tedd.it", + "https://teddit.artemislena.eu", + "https://wiki.froth.zone", + "https://quetre.odyssey346.dev", + "https://st.odyssey346.dev", "https://jsearch.pw", "https://searx.gnu.style", "https://searx.semipvt.com", "https://etsi.me", - "https://s.zhaocloud.net", - "https://search.vidhukant.xyz", + "https://search.zzls.xyz", "https://searx.ericaftereric.top", "https://searx.fmac.xyz", - "https://searxng.au/searx", "https://www.webrats.xyz", - "https://search.albony.xyz", "https://whoogle.esmailelbob.xyz", - "https://beatbump.ml", - "https://stube.tokhmi.xyz" + "https://search.wef.lol", + "https://i.bcow.xyz", + "https://lbry.bcow.xyz", + "https://beatbump.ml" ] } \ No newline at end of file diff --git a/src/instances/data.json b/src/instances/data.json index 3e82842c..e2e5d9f5 100644 --- a/src/instances/data.json +++ b/src/instances/data.json @@ -1,75 +1,82 @@ { "invidious": { - "normal": [ + "clearnet": [ "https://yewtu.be", "https://vid.puffyan.us", + "https://invidious.snopyta.org", "https://invidious.kavin.rocks", "https://inv.riverside.rocks", - "https://invidious.osi.kr", + "https://invidio.xamh.de", "https://y.com.sb", "https://yt.artemislena.eu", - "https://invidious.flokinet.to", "https://invidious.sethforprivacy.com", + "https://invidious.flokinet.to", "https://invidious.tiekoetter.com", "https://inv.bp.projectsegfau.lt", - "https://invidious.projectsegfau.lt", "https://inv.vern.cc", + "https://invidious.projectsegfau.lt", "https://invidious.nerdvpn.de", + "https://invidious.rhyshl.live", "https://inv.privacy.com.de", "https://invidious.slipfox.xyz", - "https://youtube.076.ne.jp", "https://invidious.weblibre.org", - "https://invidious.snopyta.org", "https://invidious.esmailelbob.xyz", + "https://youtube.076.ne.jp", "https://invidious.namazso.eu" ], "tor": [ - "http://c7hqkpkpemu6e7emz5b4vyz7idjgdvgaaa3dyimmeojqbgpea3xqjoid.onion", - "http://w6ijuptxiku4xpnnaetxvnkc5vqcdu7mgns2u77qefoixi63vbvnpnqd.onion", - "http://kbjggqkzv65ivcqj6bumvp337z6264huv5kpkwuv6gu5yjiskvan7fad.onion", - "http://grwp24hodrefzvjjuccrkw3mjq4tzhaaq32amf33dzpmuxe7ilepcmad.onion", - "http://osbivz6guyeahrwp2lnwyjk2xos342h4ocsxyqrlaopqjuhwn2djiiyd.onion", - "http://u2cvlit75owumwpy4dj2hsmvkq7nvrclkpht7xgyye2pyoxhpmclkrad.onion", - "http://euxxcnhsynwmfidvhjf6uzptsmh4dipkmgdmcmxxuo7tunp3ad2jrwyd.onion", + "http://inv.vernccvbvyi5qhfzyqengccj7lkove6bjot2xhh5kajhwvidqafczrad.onion", "http://invidious.lqs5fjmajyp7rvp4qvyubwofzi6d4imua7vs237rkc4m5qogitqwrgyd.onion", - "http://inv.vernccvbvyi5qhfzyqengccj7lkove6bjot2xhh5kajhwvidqafczrad.onion" + "http://euxxcnhsynwmfidvhjf6uzptsmh4dipkmgdmcmxxuo7tunp3ad2jrwyd.onion", + "http://u2cvlit75owumwpy4dj2hsmvkq7nvrclkpht7xgyye2pyoxhpmclkrad.onion", + "http://osbivz6guyeahrwp2lnwyjk2xos342h4ocsxyqrlaopqjuhwn2djiiyd.onion", + "http://grwp24hodrefzvjjuccrkw3mjq4tzhaaq32amf33dzpmuxe7ilepcmad.onion", + "http://kbjggqkzv65ivcqj6bumvp337z6264huv5kpkwuv6gu5yjiskvan7fad.onion", + "http://w6ijuptxiku4xpnnaetxvnkc5vqcdu7mgns2u77qefoixi63vbvnpnqd.onion", + "http://c7hqkpkpemu6e7emz5b4vyz7idjgdvgaaa3dyimmeojqbgpea3xqjoid.onion", + "http://am74vkcrjp2d5v36lcdqgsj2m6x36tbrkhsruoegwfcizzabnfgf5zyd.onion" ], "i2p": [], "loki": [] }, "piped": { - "normal": [ + "clearnet": [ "https://piped.kavin.rocks", "https://piped.tokhmi.xyz", "https://piped.moomoo.me", - "https://il.ax", "https://piped.mha.fi", "https://de-piped.shimul.me", "https://pipedus.palash.dev", - "https://piped.waffle.wiki", "https://watch.whatever.social", + "https://piped.garudalinux.org", + "https://y.rivo.lol", "https://yt.jae.fi", "https://piped.mint.lgbt", + "https://il.ax", + "https://piped.privacy.com.de", "https://piped.esmailelbob.xyz", - "https://piped.projectsegfau.lt" + "https://piped.projectsegfau.lt", + "https://piped.privacydev.net", + "https://piped.palveluntarjoaja.eu", + "https://piped.smnz.de", + "https://piped.adminforge.de", + "https://watch.whatevertinfoil.de" ], "tor": [], "i2p": [], "loki": [] }, "pipedMaterial": { - "normal": [ + "clearnet": [ "https://piped-material.১.net", - "https://piped-material.ftp.sh", - "https://piped-staging.ftp.sh", - "https://ui.piped.১.net" + "https://piped-material.ftp.sh" ], "tor": [], "i2p": [], "loki": [] }, "cloudtube": { - "normal": [ + "clearnet": [ "https://tube.cadence.moe", "https://yt.beparanoid.de" ], @@ -80,18 +87,25 @@ "loki": [] }, "proxiTok": { - "normal": [ - "https://proxitok.herokuapp.com", + "clearnet": [ + "https://proxitok.pabloferreiro.es", "https://proxitok.pussthecat.org", + "https://tok.habedieeh.re", + "https://proxitok.esmailelbob.xyz", + "https://cringe.whatever.social", + "https://proxitok.dhusch.de", "https://proxitok.privacydev.net", - "https://tok.habedieeh.re" + "https://proxitok.odyssey346.dev", + "https://tok.artemislena.eu", + "https://tok.adminforge.de", + "https://proxitok.manasiwibi.com" ], "tor": [], "i2p": [], "loki": [] }, "send": { - "normal": [ + "clearnet": [ "https://send.vis.ee", "https://send.zcyph.cc", "https://send.turingpoint.de", @@ -115,7 +129,7 @@ "loki": [] }, "nitter": { - "normal": [ + "clearnet": [ "https://nitter.net", "https://nitter.42l.fr", "https://nitter.pussthecat.org", @@ -133,7 +147,6 @@ "https://nitter.it", "https://twitter.censors.us", "https://nitter.grimneko.de", - "https://n.hyperborea.cloud", "https://nitter.ca", "https://twitter.076.ne.jp", "https://nitter.fly.dev", @@ -148,14 +161,11 @@ "https://fuckthesacklers.network", "https://nitter.esmailelbob.xyz", "https://tw.artemislena.eu", - "https://de.nttr.stream", "https://nitter.winscloud.net", "https://nitter.tiekoetter.com", "https://nitter.spaceint.fr", "https://twtr.bch.bar", "https://nitter.privacy.com.de", - "https://nitter.mastodon.pro", - "https://nitter.notraxx.ch", "https://nitter.poast.org", "https://nitter.bird.froth.zone", "https://nitter.dcs0.hu", @@ -165,13 +175,11 @@ "https://n.ramle.be", "https://nitter.cz", "https://nitter.privacydev.net", + "https://nitter.evil.site", "https://tweet.lambda.dance", - "https://nitter.ebnar.xyz", "https://nitter.kylrth.com", "https://nitter.foss.wtf", "https://nitter.priv.pw", - "https://nt.vern.cc", - "https://nitter.wef.lol", "https://nitter.tokhmi.xyz", "https://nitter.catalyst.sx", "https://unofficialbird.com", @@ -184,7 +192,21 @@ "https://nederland.unofficialbird.com", "https://uk.unofficialbird.com", "https://n.l5.ca", - "https://nitter.slipfox.xyz" + "https://nitter.slipfox.xyz", + "https://nitter.soopy.moe", + "https://nitter.qwik.space", + "https://read.whatever.social", + "https://nitter.rawbit.ninja", + "https://nt.vern.cc", + "https://ntr.odyssey346.dev", + "https://nitter.ir", + "https://nitter.privacytools.io", + "https://nitter.sneed.network", + "https://n.sneed.network", + "https://nitter.manasiwibi.com", + "https://nitter.smnz.de", + "https://nitter.twei.space", + "https://nitter.inpt.fr" ], "tor": [ "http://nitter7bryz3jv7e3uekphigvmoyoem4al3fynerxkj22dmoxoq553qd.onion", @@ -197,7 +219,7 @@ "http://jebqj47jgxleaiosfcxfibx2xdahjettuydlxbg64azd4khsxv6kawid.onion", "http://nttr2iupbb6fazdpr2rgbooon2tzbbsvvkagkgkwohhodjzj43stxhad.onion", "http://nitraeju2mipeziu2wtcrqsxg7h62v5y4eqgwi75uprynkj74gevvuqd.onion", - "http://nitter.lqs5fjmajyp7rvp4qvyubwofzi6d4imua7vs237rkc4m5qogitqwrgyd.onion", + "http://nitter.esmail5pdn24shtvieloeedh7ehz3nrwcdivnfhfcedl7gf4kwddhkqd.onion", "http://ibsboeui2im5o7dxnik3s5yghufumgy5abevtij5nbizequfpu4qi4ad.onion", "http://ec5nvbycpfa5k6ro77blxgkyrzbkv7uy6r5cngcbkadtjj2733nm3uyd.onion", "http://twitter.ap3jtgssd7qn4vfoa62gi2ijddoblslbeuw5dan3xt7myvqpura5i4qd.onion", @@ -207,39 +229,36 @@ "http://nitterqdyumlovt7tjqpdjrluitgmtpa53qq3idlpgoe4kxo7gs3xvad.onion", "http://nitter.privpw3tndpkw6pnp3g727zfgfdzbu3k6a7chv226s3xymv2p4eiuqyd.onion", "http://aaaaaxx74hbzeibageieowryhsqvimbdiitfkfe47tvgawkwkjh3coqd.onion", - "http://wiio4sgs4247brk7hj6qck2jxnvldwfdbguigc5ivpxrsegnliyfvuqd.onion" + "http://wiio4sgs4247brk7hj6qck2jxnvldwfdbguigc5ivpxrsegnliyfvuqd.onion", + "http://qwikxx2erhx6qrymued6ox2qkf2yeogjwypqvzoif4fqkljixasr6oid.onion", + "http://4g47cxugkohbweao2x66nnxxfoe3k7gdfzxej537nhdbwr522sbjxeqd.onion", + "http://tw.lpoaj7z2zkajuhgnlltpeqh3zyq7wk2iyeggqaduhgxhyajtdt2j7wad.onion" ], "i2p": [ "http://axd6uavsstsrvstva4mzlzh4ct76rc6zdug3nxdgeitrzczhzf4q.b32.i2p", "http://u6ikd6zndl3c4dsdq4mmujpntgeevdk5qzkfb57r4tnfeccrn2qa.b32.i2p", - "http://gseczlzmiv23p5vhsktyd7whquq2uy3c5fgkmdohh453qp3daoua.b32.i2p" + "http://gseczlzmiv23p5vhsktyd7whquq2uy3c5fgkmdohh453qp3daoua.b32.i2p", + "http://tm4rwkeysv3zz3q5yacyr4rlmca2c4etkdobfvuqzt6vsfsu4weq.b32.i2p", + "http://vernzdedoxuflrrxc4vbatbkpjh4k22ecgiqgimdiif62onhagva.b32.i2p" ], "loki": [ "http://nitter.priv.loki" ] }, "bibliogram": { - "normal": [ - "https://bibliogram.art", - "https://bibliogram.snopyta.org", - "https://bibliogram.pussthecat.org", + "clearnet": [ "https://bibliogram.1d4.us", "https://bibliogram.froth.zone", - "https://insta.trom.tf", - "https://insta.tromdienste.de", "https://ig.tokhmi.xyz", "https://ig.beparanoid.de", - "https://bibliogram.privacydev.net", - "https://bibliogram.priv.pw", - "https://ig.funami.tech", - "https://bib.actionsack.com" + "https://bibliogram.priv.pw" ], "tor": [], "i2p": [], "loki": [] }, "libreddit": { - "normal": [ + "clearnet": [ "https://libredd.it", "https://libreddit.spike.codes", "https://libreddit.dothq.co", @@ -324,7 +343,7 @@ "loki": [] }, "teddit": { - "normal": [ + "clearnet": [ "https://teddit.net", "https://teddit.ggc-project.de", "https://teddit.zaggy.nl", @@ -347,20 +366,35 @@ "https://i.opnxng.com", "https://teddit.tokhmi.xyz", "https://teddit.garudalinux.org", - "https://tedd.it" + "https://tedd.it", + "https://wiki.privacytools.io", + "https://td.vern.cc", + "https://teddit.rawbit.ninja", + "https://teddit.artemislena.eu", + "https://teddit.manasiwibi.com" ], "tor": [ "http://snoo.ioensistjs7wd746zluwixvojbbkxhr37lepdvwtdfeav673o64iflqd.onion", "http://ibarajztopxnuhabfu7fg6gbudynxofbnmvis3ltj6lfx47b6fhrd5qd.onion", "http://tedditfyn6idalzso5wam5qd3kdtxoljjhbrbbx34q2xkcisvshuytad.onion", "http://dawtyi5e2cfyfmoht4izmczi42aa2zwh6wi34zwvc6rzf2acpxhrcrad.onion", - "http://qtpvyiaqhmwccxwzsqubd23xhmmrt75tdyw35kp43w4hvamsgl3x27ad.onion" + "http://qtpvyiaqhmwccxwzsqubd23xhmmrt75tdyw35kp43w4hvamsgl3x27ad.onion", + "http://jnuonmf2n36sfdmyksqqqyab3w63cq4kx24olyjleh5z6zzfvyt7uqqd.onion", + "http://td.vernccvbvyi5qhfzyqengccj7lkove6bjot2xhh5kajhwvidqafczrad.onion", + "http://yqu4yj5lju7bmlwpzpmltb5gsu6cw7nnbcxxx4iqemwa56nxjiggf4qd.onion", + "http://teddit.lpoaj7z2zkajuhgnlltpeqh3zyq7wk2iyeggqaduhgxhyajtdt2j7wad.onion", + "http://24fympskbrdgbf4afuvhqwwl2tv3y2vwxg5t2ktozd4j5b3fob5ntzyd.onion" + ], + "i2p": [ + "http://xugoqcf2pftm76vbznx4xuhrzyb5b6zwpizpnw2hysexjdn5l2tq.b32.i2p", + "http://teddit.i2p", + "https://codeberg.org/teddit/teddit/src/branch/main/vzeiwzi7ogwl3ijrfek4fbtwhvamxcpyqoc3s4vcgnhlp54s5clq.b32.i2p", + "http://verncco2oaxjikammz4pi7umzp673cme6zuemx7yeeewspwrw3va.b32.i2p" ], - "i2p": [], "loki": [] }, "wikiless": { - "normal": [ + "clearnet": [ "https://wikiless.org", "https://wikiless.sethforprivacy.com", "https://wiki.604kph.xyz", @@ -370,69 +404,85 @@ "https://wikiless.tiekoetter.com", "https://wikiless.esmailelbob.xyz", "https://wiki.slipfox.xyz", - "https://wikiless.funami.tech" + "https://wikiless.funami.tech", + "https://wl.vern.cc", + "https://wiki.privacytools.io", + "https://wikiless.rawbit.ninja", + "https://wiki.adminforge.de" ], "tor": [ "http://dj2tbh2nqfxyfmvq33cjmhuw7nb6am7thzd3zsjvizeqf374fixbrxyd.onion", "http://ybgg2evrcdz37y2qes23ff3wjqjdn33tthgoagi76vhxytu4mpxiz5qd.onion", - "http://wikiless.lqs5fjmajyp7rvp4qvyubwofzi6d4imua7vs237rkc4m5qogitqwrgyd.onion", - "http://c2pesewpalbi6lbfc5hf53q4g3ovnxe4s7tfa6k2aqkf7jd7a7dlz5ad.onion" + "http://wikiless.esmail5pdn24shtvieloeedh7ehz3nrwcdivnfhfcedl7gf4kwddhkqd.onion", + "http://c2pesewpalbi6lbfc5hf53q4g3ovnxe4s7tfa6k2aqkf7jd7a7dlz5ad.onion", + "http://wl.vernccvbvyi5qhfzyqengccj7lkove6bjot2xhh5kajhwvidqafczrad.onion", + "http://tdx37ew3oke5rxn3yi5r5665ka7ozvehnd4xmnjxxdvqorias2nyl4qd.onion" ], "i2p": [ "http://wikiless.i2p", "http://hflqp2ejxygpj6cdwo3ogfieqmxw3b56w7dblt7bor2ltwk6kcfa.b32.i2p", - "http://x33lx4h6d7h6xs4eiqwhvaxn3ea5gn2ifmu3jobnvuvn4k4aej7a.b32.i2p" + "http://x33lx4h6d7h6xs4eiqwhvaxn3ea5gn2ifmu3jobnvuvn4k4aej7a.b32.i2p", + "http://vernesciy2defjsputrjrv6pa5ll6qzrckfffi5lgkumstdojyga.b32.i2p" ], "loki": [] }, "scribe": { - "normal": [ + "clearnet": [ "https://scribe.rip", "https://scribe.nixnet.services", "https://scribe.citizen4.eu", "https://scribe.bus-hit.me", "https://scribe.froth.zone", - "https://scribe.esmailelbob.xyz" + "https://scribe.esmailelbob.xyz", + "https://scribe.privacydev.net", + "https://scribe.rawbit.ninja", + "https://sc.vern.cc" ], "tor": [], "i2p": [], "loki": [] }, "quetre": { - "normal": [ - "https://quetre.herokuapp.com", - "https://quora.vern.cc", + "clearnet": [ + "https://quetre.iket.me", + "https://qr.vern.cc", "https://quetre.pussthecat.org", "https://wuetre.herokuapp.com", "https://quetreus.herokuapp.com", "https://quetre.tokhmi.xyz", "https://quetre.projectsegfau.lt", - "https://quetre.esmailelbob.xyz" + "https://quetre.esmailelbob.xyz", + "https://quetre.odyssey346.dev" + ], + "tor": [ + "http://quetre.esmail5pdn24shtvieloeedh7ehz3nrwcdivnfhfcedl7gf4kwddhkqd.onion", + "http://qr.vernccvbvyi5qhfzyqengccj7lkove6bjot2xhh5kajhwvidqafczrad.onion" ], - "tor": [], "i2p": [], "loki": [] }, "libremdb": { - "normal": [ + "clearnet": [ "https://libremdb.herokuapp.com", "https://libremdb.pussthecat.org", "https://libremdbeu.herokuapp.com", "https://lmdb.tokhmi.xyz", "https://libremdb.esmailelbob.xyz" ], - "tor": [], + "tor": [ + "http://libremdb.lqs5fjmajyp7rvp4qvyubwofzi6d4imua7vs237rkc4m5qogitqwrgyd.onion" + ], "i2p": [], "loki": [] }, "simplyTranslate": { - "normal": [ + "clearnet": [ "https://simplytranslate.org", "https://st.tokhmi.xyz", "https://translate.josias.dev", "https://translate.namazso.eu", "https://translate.riverside.rocks", - "https://st.manerakai.com", + "https://simplytranslate.manerakai.com", "https://translate.bus-hit.me", "https://simplytranslate.pussthecat.org", "https://translate.northboot.xyz", @@ -442,22 +492,26 @@ "https://translate.slipfox.xyz", "https://st.privacydev.net", "https://translate.beparanoid.de", - "https://translate.priv.pw" + "https://translate.priv.pw", + "https://st.odyssey346.dev" ], "tor": [ "http://fyng2tsmzmvxmojzbbwmfnsn2lrcyftf4cw6rk5j2v2huliazud3fjid.onion", "http://xxtbwyb5z5bdvy2f6l2yquu5qilgkjeewno4qfknvb3lkg3nmoklitid.onion", - "http://translate.prnoid54e44a4bduq5due64jkk7wcnkxcp5kv3juncm7veptjcqudgyd.onion" + "http://translate.prnoid54e44a4bduq5due64jkk7wcnkxcp5kv3juncm7veptjcqudgyd.onion", + "http://simplytranslate.esmail5pdn24shtvieloeedh7ehz3nrwcdivnfhfcedl7gf4kwddhkqd.onion", + "http://tl.vernccvbvyi5qhfzyqengccj7lkove6bjot2xhh5kajhwvidqafczrad.onion" ], "i2p": [ - "http://kmnkkp4v4ublygtnyq46oacy3qw75nrxxniriuaersumw7bfsm2a.b32.i2p" + "http://kmnkkp4v4ublygtnyq46oacy3qw75nrxxniriuaersumw7bfsm2a.b32.i2p", + "http://verna7avzgd4qqal7k2onjzwxcceqby2gwvya2a2frdswb7z2k4q.b32.i2p" ], "loki": [ "http://translate.priv.loki" ] }, "lingva": { - "normal": [ + "clearnet": [ "https://lingva.ml", "https://translate.igna.ooo", "https://lingva.pussthecat.org", @@ -473,8 +527,7 @@ "loki": [] }, "searx": { - "normal": [ - "https://anon.sx", + "clearnet": [ "https://dynabyte.ca", "https://jsearch.pw", "https://search.ethibox.fr", @@ -491,8 +544,6 @@ "https://searx.nakhan.net", "https://searx.netzspielplatz.de", "https://searx.nixnet.services", - "https://searx.org", - "https://searx.rasp.fr", "https://searx.ru", "https://searx.run", "https://searx.semipvt.com", @@ -515,10 +566,12 @@ ], "tor": [ "http://3afisqjw2rxm6z7mmstyt5rx75qfqrgxnkzftknbp2vhipr2nrmrjdyd.onion", + "http://4n53nafyi77iplnbrpmxnp3x4exbswwxigujaxy3b37fvr7bvlopxeyd.onion", "http://yra4tke2pwcnatxjkufpw6kvebu3h3ti2jca2lcdpgx3mpwol326lzid.onion", "http://z5vawdol25vrmorm4yydmohsd4u6rdoj2sylvoi3e3nqvxkvpqul7bqd.onion", "http://zbuc3bbzbfdqqo2x46repx2ddajbha6fpsjeeptjhhhhzji3zopxdqyd.onion", - "http://f4qfqajszpx5b7itzxt6mb7kj4ktpgbdq7lq6xaiqyqx6a7de3epptad.onion" + "http://f4qfqajszpx5b7itzxt6mb7kj4ktpgbdq7lq6xaiqyqx6a7de3epptad.onion", + "http://searxfilowxokbogygrigir4wqxfxqzuxofxgdon7dg6rsii4yxzytyd.onion" ], "i2p": [ "http://ransack.i2p", @@ -527,12 +580,15 @@ "loki": [] }, "searxng": { - "normal": [ + "clearnet": [ "https://darmarit.org/searx", "https://de.xcxc.ml", "https://etsi.me", + "https://icanfindit.online", "https://jackgoss.xyz", + "https://metasearch.nl", "https://northboot.xyz", + "https://notsearch.uk", "https://opnxng.com", "https://paulgo.io", "https://priv.au", @@ -542,24 +598,30 @@ "https://saber.tk", "https://search.0relay.com", "https://search.affusio.com", - "https://search.ashs.club", - "https://search.bingowaves.xyz", "https://search.bus-hit.me", "https://search.chemicals-in-the-water.eu", + "https://search.cronobox.one", "https://search.disroot.org", "https://search.gcomm.ch", "https://search.kiwitalk.de", "https://search.mdosch.de", + "https://search.mpx.wtf", "https://search.neet.works", "https://search.ononoki.org", "https://search.privacyguides.net", "https://search.projectsegfau.lt", "https://search.rabbit-company.com", + "https://search.rhscze.cf", + "https://search.rowie.at", "https://search.sapti.me", + "https://search.serginho.dev", + "https://search.smnz.de", "https://search.teamriverbubbles.com", "https://search.unlocked.link", + "https://search.uspersec.com", "https://search.vidhukant.xyz", "https://search.zzls.xyz", + "https://searx.baczek.me", "https://searx.be", "https://searx.becomesovran.com", "https://searx.chocoflan.net", @@ -569,9 +631,11 @@ "https://searx.fi", "https://searx.fmac.xyz", "https://searx.gnous.eu", + "https://searx.kujonello.cf", "https://searx.mha.fi", "https://searx.mistli.net", "https://searx.namejeff.xyz", + "https://searx.org", "https://searx.orion-hub.fr", "https://searx.priv.pw", "https://searx.prvcy.eu", @@ -580,40 +644,41 @@ "https://searx.sev.monster", "https://searx.slipfox.xyz/searx", "https://searx.tiekoetter.com", - "https://searx.vimproved.me", "https://searx.zcyph.cc", - "https://searxng.au/searx", - "https://searxng.tordenskjold.de", + "https://searxng.nicfab.it", "https://searxng.zackptg5.com", "https://serx.ml", "https://sh0.it", + "https://soek.allesbeste.com", "https://srx.cosmohub.io", "https://swag.pw", + "https://trydex.tk/searxng", "https://www.gruble.de", "https://www.webrats.xyz", - "https://xcxc.ml", "https://xo.wtf" ], "tor": [ "http://w5rl6wsd7mzj4bdkbuqvzidet5osdsm5jhg2f7nvfidakfq5exda5wid.onion", - "http://4n53nafyi77iplnbrpmxnp3x4exbswwxigujaxy3b37fvr7bvlopxeyd.onion", + "http://privateoz3u5utrimal2edr56j3r5caakektxxgixigdkycuxigvquid.onion", "http://b6sxmon57qza6dt36li7huabie5ntrvjr4q5rc2vvbn4hqvzd4phrvyd.onion", - "http://search3q76rqpektbrchlf2rjq4fnbxzeov6rljdywg3nwbunpgd7bid.onion", - "http://searchoorwalty5a2ailrboa2asqyts2u7bdoqwnjefpgjobpvtzn4qd.onion", + "http://searxngg6zleq6ceboe5ltkyo4hyrb3aaycrgzmrljv3jjlb5vcytead.onion", "http://gbat2pbpg7ys3fi3pbp64667tt5x66mg45xok35bxdw7v55brm7a27yd.onion", + "http://b2c7fvbhnfvwnl6oh2tydhzfx4i37kmmrycq42heqbbe7wovq3uzenid.onion", "http://searxdr3pqz4nydgnqocsia2xbywptxbkympa2emn7zlgggrir4bkfad.onion", + "http://searx.esmail5pdn24shtvieloeedh7ehz3nrwcdivnfhfcedl7gf4kwddhkqd.onion", "http://searx.micohauwkjbyw5meacrb4ipicwvwg4xtzl7y7viv53kig2mdcsvwkyyd.onion", "http://searx.privpw3tndpkw6pnp3g727zfgfdzbu3k6a7chv226s3xymv2p4eiuqyd.onion", "http://rq2w52kyrif3xpfihkgjnhqm3a5aqhoikpv72z3drpjglfzc2wr5z4yd.onion", "http://fub6vgedgeadlu3ctskrpkcqjruh76tckwtj5swfhyblgml2tzgzckqd.onion/searx", "http://searx3aolosaf3urwnhpynlhuokqsgz47si4pzz5hvb7uuzyjncl2tid.onion", - "http://4tz2vlnwk2apf2rpinkqv6uxvfgo5xjx6vl5vp7lxgaiooumetjpstqd.onion" + "http://4tz2vlnwk2apf2rpinkqv6uxvfgo5xjx6vl5vp7lxgaiooumetjpstqd.onion", + "https://lgmekfnpealdqhnctyg3p5fuelpdwnbqbwnl2ickpdoodzatzgz27ryd.onion" ], "i2p": [], "loki": [] }, "whoogle": { - "normal": [ + "clearnet": [ "https://gowogle.voring.me", "https://s.tokhmi.xyz", "https://search.albony.xyz", @@ -633,29 +698,32 @@ "loki": [] }, "librex": { - "normal": [ + "clearnet": [ "https://librex.beparanoid.de", + "https://librex.extravi.dev", "https://search.davidovski.xyz", "https://search.funami.tech", - "https://librex.catalyst.sx" + "https://librex.catalyst.sx", + "https://search.madreyk.xyz", + "https://search.pabloferreiro.es" ], "tor": [ - "http://librex.prnoid54e44a4bduq5due64jkk7wcnkxcp5kv3juncm7veptjcqudgyd.onion", + "http://librex.2356uhnbpv5nk3bni5bv6jg2cd6lgj664kwx3lhyelstpttpyv4kk2qd.onion", + "http://ncblhz7q4sfbf755bdbhebfzxcpypz7ewafgi4agatecojz7pln4i3id.onion", "http://librex.so2mpiyfo4cje7bof5v52y3cvjyo2haxpqfvut4sr6gj2ul4mddx2jid.onion" ], "i2p": [ - "http://fboseyskrqpi6yjiifvz4ryuoiswjezkqsfxfkm2vmbuhehbpr7q.b32.i2p" + "http://rra33hiaf6nmby7jfpqe2gqmng3jnzkvbu2n7jgce7vbhoyuhzya.b32.i2p" ], "loki": [] }, "rimgo": { - "normal": [ + "clearnet": [ "https://i.bcow.xyz", "https://rimgo.pussthecat.org", "https://rimgo.totaldarkness.net", "https://rimgo.bus-hit.me", "https://rimgo.esmailelbob.xyz", - "https://rimgo.lunar.icu", "https://i.actionsack.com", "https://rimgo.privacydev.net", "https://imgur.artemislena.eu", @@ -664,7 +732,7 @@ "https://rimgo.mha.fi" ], "tor": [ - "http://rimgo.lqs5fjmajyp7rvp4qvyubwofzi6d4imua7vs237rkc4m5qogitqwrgyd.onion", + "http://rimgo.esmail5pdn24shtvieloeedh7ehz3nrwcdivnfhfcedl7gf4kwddhkqd.onion", "http://rimgo.vernccvbvyi5qhfzyqengccj7lkove6bjot2xhh5kajhwvidqafczrad.onion", "http://rimgo.micohauwkjbyw5meacrb4ipicwvwg4xtzl7y7viv53kig2mdcsvwkyyd.onion" ], @@ -672,25 +740,30 @@ "loki": [] }, "librarian": { - "normal": [ + "clearnet": [ "https://lbry.bcow.xyz", "https://odysee.076.ne.jp", "https://librarian.pussthecat.org", - "https://lbry.mutahar.rocks", + "https://lbry.projectsegfau.lt", "https://librarian.esmailelbob.xyz", "https://lbry.vern.cc", - "https://lbry.slipfox.xyz" + "https://lbry.slipfox.xyz", + "https://lbry.sytes.net", + "https://lbry.webhop.me", + "https://lbry.mywire.org" ], "tor": [ - "http://librarian.lqs5fjmajyp7rvp4qvyubwofzi6d4imua7vs237rkc4m5qogitqwrgyd.onion", + "http://librarian.esmail5pdn24shtvieloeedh7ehz3nrwcdivnfhfcedl7gf4kwddhkqd.onion", "http://lbry.vernccvbvyi5qhfzyqengccj7lkove6bjot2xhh5kajhwvidqafczrad.onion", - "http://5znbzx2xcymhddzekfjib3isgqq4ilcyxa2bsq6vqmnvbtgu4f776lqd.onion" + "http://5znbzx2xcymhddzekfjib3isgqq4ilcyxa2bsq6vqmnvbtgu4f776lqd.onion", + "http://zjmls4urccc5wxc64ilbv4oqarjab6pbanvmhd2qqt6p7fgqrjjnryqd.onion", + "http://bxewpsswttslepw27w2hhxhlizwm7l7y54x3jw5cfrb64hb6lgc557ad.onion" ], "i2p": [], "loki": [] }, "neuters": { - "normal": [ + "clearnet": [ "https://neuters.de" ], "tor": [], @@ -698,24 +771,31 @@ "loki": [] }, "beatbump": { - "normal": [ - "https://beatbump.ml" + "clearnet": [ + "https://beatbump.ml", + "https://beatbump.esmailelbob.xyz" + ], + "tor": [ + "http://beatbump.lqs5fjmajyp7rvp4qvyubwofzi6d4imua7vs237rkc4m5qogitqwrgyd.onion" ], - "tor": [], "i2p": [], "loki": [] }, "hyperpipe": { - "normal": [ + "clearnet": [ "https://hyperpipe.surge.sh", - "https://hyperpipe.esmailelbob.xyz" + "https://hyperpipe.esmailelbob.xyz", + "https://listen.whatever.social", + "https://music.adminforge.de" + ], + "tor": [ + "http://hyperpipe.esmail5pdn24shtvieloeedh7ehz3nrwcdivnfhfcedl7gf4kwddhkqd.onion" ], - "tor": [], "i2p": [], "loki": [] }, "facil": { - "normal": [ + "clearnet": [ "https://facilmap.org" ], "tor": [], @@ -723,42 +803,51 @@ "loki": [] }, "simpleertube": { - "normal": [ + "clearnet": [ "https://tube.simple-web.org", "https://simpleertube.esmailelbob.xyz", - "https://stube.tokhmi.xyz" + "https://stube.tokhmi.xyz", + "https://st.vern.cc" ], "tor": [], "i2p": [], "loki": [] }, "peertube": [ + "https://pt.freedomwolf.cc", + "https://vr360tube.online", + "https://bodavr.com", + "https://peertube.tni-hosted.nl", + "https://videos.parleur.net", + "https://tube.azadehafzar.ir", + "https://pewflix.com", + "https://video.electronicping.net", + "https://videos.im.allmendenetz.de", + "https://tube.cyberia.club", + "https://casstream.nohost.me", + "https://peertube.as62430.net", + "https://peertube.askan.info", + "https://apertatube.net", + "https://beetoons.tv", + "https://rankett.net", + "https://tube.xsoftware.it", + "https://video.ut0pia.org", + "https://kinotu.be", "https://tube.nogafa.org", "https://www.neptube.io", "https://tube.ghk-academy.info", "https://pcbu.nl", - "https://soberania.tv", "https://pire.artisanlogiciel.net", - "https://trutube.xyz", "https://tube-test.apps.education.fr", "https://tube-sciences-technologies.apps.education.fr", - "https://stream.conesphere.cloud", "https://tube-institutionnel.apps.education.fr", "https://trutube.online", "https://tube-cycle-3.apps.education.fr", "https://video.manicphase.me", - "https://tube.emy.plus", - "https://v.bearvideo.win", "https://tubulus.openlatin.org", - "https://peertube.securetown.top", - "https://tv.datamol.org", "https://video.graine-pdl.org", - "https://tube.zee.li", "https://tube-cycle-2.apps.education.fr", - "https://mikeclips.net", - "https://tube.s1gm4.eu", "https://videos.keyedlimepie.org", - "https://video.cpn.so", "https://video.davduf.net", "https://tube.oldkid.digital", "https://tube.fofoca.eu", @@ -769,9 +858,6 @@ "https://media.theplattform.net", "https://peertube.offerman.com", "https://v.lastorder.xyz", - "https://video.eradicatinglove.xyz", - "https://peertube.thele.me", - "https://video.schnitzler.one", "https://tube.cybershock.life", "https://tube.reseau-canope.fr", "https://frentube.myyouniverse.observer", @@ -781,17 +867,12 @@ "https://video.trankil.info", "https://video.uriopss-pdl.fr", "https://pt.bolapara.mywire.org", - "https://ptube.ranranhome.info", - "https://vidid.pl", "https://video.3cmr.fr", - "https://tube.die-rote-front.de", "https://peertube.miguelcr.me", "https://video.thinkof.name", "https://nekofans.tv", "https://video.comun.al", - "https://peertube.nrsk.no", "https://video.occm.cc", - "https://peertube.viviers-fibre.net", "https://tube-action-educative.apps.education.fr", "https://jahve.pl", "https://videos.yesil.club", @@ -800,93 +881,68 @@ "https://tube.hunterjozwiak.com", "https://tube-numerique-educatif.apps.education.fr", "https://tube.itsg.host", - "https://tube.valinor.fr", "https://lucarne.balsamine.be", "https://peertube.suranyami.com", "https://video.ados.accoord.fr", "https://t.0x0.st", "https://tube-education-physique-et-sportive.apps.education.fr", "https://videos.lemouvementassociatif-pdl.org", - "https://videos.casually.cat", "https://playroom.kitsunes.world", "https://tube2.nous.media", - "https://peertube.freenet.ru", "https://peertube.0x5e.eu", "https://tube.darknight-coffee.org", "https://play.mittdata.se", - "https://peertube.lhc.net.br", - "https://see.vtopia.live", "https://peertube.letoine.fr", "https://tube-enseignement-professionnel.apps.education.fr", - "https://socpeertube.ru", "https://videos.laliguepaysdelaloire.org", "https://quantube.win", "https://twctube.twc-zone.eu", "https://vhs.absturztau.be", - "https://video.espr.moe", "https://peertube.social.my-wan.de", "https://phijkchu.com", "https://video.lycee-experimental.org", - "https://galileo.news", - "https://peertube.otakufarms.com", "https://tube.motuhake.xyz", "https://pt.m0r016.net", "https://hitchtube.fr", "https://video.fox-romka.ru", "https://peertube.ctrl-c.liu.se", - "https://peertube.live", "https://video.slipfox.xyz", - "https://pt.vern.cc", "https://vnop.org", "https://videos.cassidypunchmachine.com", - "https://tv1.gomntu.space", "https://dalek.zone", "https://seka.pona.la", "https://syop.tv", "https://watch.thelema.social", "https://tube.miegl.cz", "https://mov.clov.fr", - "https://videomensoif.ynh.fr", - "https://videos.neongarden.life", "https://video.vaku.org.ua", "https://videos.trom.lt", "https://vid.mkp.ca", "https://jupiter.tube", - "https://tuvideo.encanarias.info", "https://videos.squat.net", "https://peertube.chaunchy.com", "https://tube.vrpnet.org", "https://video.tii.space", - "https://peertube.inubo.ch", "https://nightshift.minnix.dev", "https://tube.friloux.me", "https://peertube.virtual-assembly.org", - "https://video.olos311.org", "https://peertube.atilla.org", - "https://video.lapineige.fr", - "https://zapping.no-ip.info", "https://tube.azkware.net", "https://video.lunasqu.ee", "https://v.mkp.ca", "https://peertube.eus", "https://infothema.net", "https://tube.nilsu.org", - "https://podlibre.video", - "https://videos.tankernn.eu", "https://watch.autonomous-zone.earth", "https://pirtube.calut.fr", "https://y.melonia.se", - "https://peertube.cirkau.art", - "https://peertube.2i2l.net", "https://videos.martyn.berlin", "https://turkum.me", "https://video.colibris-outilslibres.org", - "https://invoice.peertube.biz", "https://peertube.chantierlibre.org", "https://video.9wd.eu", "https://video.niboe.info", "https://peertuibe.fedsinfo.nohost.me", - "https://s9.gegenstimme.tv", "https://videos.alamaisondulibre.org", "https://videos.tormentasolar.win", "https://tube.nestor.coop", @@ -903,13 +959,9 @@ "https://peertube.bgzashtita.es", "https://tube.genb.de", "https://cliptube.org", - "https://tube.tr4sk.me", "https://videos.campdarling.com", - "https://video.mikka.md", - "https://www.aktion-nordost.tv", "https://tube.rooty.fr", "https://tube.dnet.one", - "https://peertube.io", "https://www.kotikoff.net", "https://peertube.nz", "https://videos.grafo.zone", @@ -921,7 +973,6 @@ "https://peertube.narrativerry.xyz", "https://tube.9minuti.it", "https://krdtube.org", - "https://peertube.elforcer.ru", "https://tubocatodico.bida.im", "https://torstenwitte.peertube-host.de", "https://peertube.hackerfraternity.org", @@ -940,14 +991,9 @@ "https://free-streams.com", "https://tube.pawelko.net", "https://video.livecchi.cloud", - "https://anarchy.video", "https://peertube.gsugambit.com", - "https://media.zat.im", - "https://videos.sadx.moe", "https://pt.nospy.net", "https://yhwh.tube", - "https://peerlook.ru", - "https://monero.wf", "https://tube.kicou.info", "https://video.aqr.af", "https://videos-passages.huma-num.fr", @@ -956,8 +1002,6 @@ "https://peertube.dsmouse.net", "https://ptube.horsentiers.fr", "https://video.cnt.social", - "https://peertube.okko.io", - "https://video.mentality.rip", "https://tube.03281.fspfc.org", "https://tube.linc.systems", "https://peertube.ketchup.noho.st", @@ -970,31 +1014,23 @@ "https://truvitv.com", "https://pt.ilyamikcoder.com", "https://peertube.sensin.eu", - "https://watch.riverside.rocks", - "https://sharetube.us", "https://video.sadmin.io", "https://stream.jurnalfm.md", - "https://video.asgardius.company", "https://video.publicspaces.net", "https://video.eientei.org", "https://tv.suwerenni.org", "https://tube.revertron.com", "https://tube.erzbistum-hamburg.de", - "https://video.germanische-heilkunde.at", "https://views.southfox.me", - "https://vide.oxel.me", "https://video.mttv.it", "https://peertube.cloud.nerdraum.de", "https://vid.pretok.tv", "https://videos.slownewsdayshow.com", "https://videos.sarcasmstardust.com", "https://videos.factsonthegroundshow.com", - "https://video.pe6.eu", "https://tv.santic-zombie.ru", "https://tube.sleeping.town", - "https://tube.globalfrens.com", "https://peertube.hacknews.pmdcollab.org", - "https://freetubes.nohost.me", "https://video.snug.moe", "https://video.avant-le-strike.buzz", "https://videos.ritimo.org", @@ -1017,17 +1053,14 @@ "https://peertube.beardedtek.com", "https://creemoseducacioninclusiva.uma.es", "https://videos.yeswiki.net", - "https://tube.lrk.sh", "https://peertube.autogestioncitoyenne.org", "https://video.r3s.nrw", "https://peertube.semweb.pro", "https://poast.tv", "https://testube.distrilab.fr", "https://peertube.rse43.com", - "https://libremedia.video", "https://vid.lelux.fi", "https://v.wolfskaempf.de", - "https://peertube.chevro.fr", "https://media.econoalchemist.com", "https://video.qoto.org", "https://peertube.maxweiss.io", @@ -1036,34 +1069,27 @@ "https://peertube.swarm.solvingmaz.es", "https://film.node9.org", "https://peertube.mi-site.net", - "https://tube.nowtech.io", "https://raptube.antipub.org", "https://video.cm-en-transition.fr", "https://tube.koweb.fr", "https://peertube.genma.fr", "https://tv.generallyrubbish.net.au", - "https://video.travisshears.xyz", "https://videos.codingotaku.com", "https://foss.tube", "https://peertube.satoshishop.de", "https://ua.peertube.red", "https://peertube.zwindler.fr", "https://videos.fsci.in", - "https://swebbtube.se", "https://video.dnfi.no", "https://peertube.revelin.fr", - "https://armstube.com", "https://peertube.ti-fr.com", "https://video.turbo.chat", - "https://tube.toldi.eu", - "https://review.peertube.biz", "https://peertube.am-networks.fr", "https://video.chbmeyer.de", "https://video.rs-einrich.de", "https://p2ptv.ru", "https://peertube.librenet.co.za", "https://h3h3.club", - "https://watch.snoot.tube", "https://tube.freepeople.fr", "https://watch.rt4mn.org", "https://video.lrose.de", @@ -1080,7 +1106,6 @@ "https://video.anartist.org", "https://peertube.home.x0r.fr", "https://peertube.marud.fr", - "https://freetubehub.live", "https://mtube.mooo.com", "https://skeptube.fr", "https://tube.villejuif.fr", @@ -1125,9 +1150,7 @@ "https://live.solari.com", "https://live.codinglab.ch", "https://dud-video.inf.tu-dresden.de", - "https://media-test.interior.edu.uy", "https://media.interior.edu.uy", - "https://phoenixproject.group", "https://peertube.sebu77.com", "https://www.orion-hub.fr", "https://tv.orion-serv.fr", @@ -1168,7 +1191,6 @@ "https://tube.nuxnik.com", "https://tube.froth.zone", "https://peertube.ethibox.fr", - "https://www.freetubehub.live", "https://tube.communia.org", "https://peertube.dragonborn.app", "https://ai-tube.ch", @@ -1180,14 +1202,12 @@ "https://pocketnetpeertube10.nohost.me", "https://tube.io18.top", "https://peertube.remerge.net", - "https://video.wuatek.is", "https://tube.geekyboo.net", "https://notretube.asselma.eu", "https://canal.facil.services", "https://pt.gordons.gen.nz", "https://tube.misterbanal.net", "https://peertube.fomin.site", - "https://peertube.kenjiyon.xyz", "https://tube.g1zm0.de", "https://video.ellijaymakerspace.org", "https://videos.benpro.fr", @@ -1223,14 +1243,12 @@ "https://bideoak.argia.eus", "https://video.hainry.fr", "https://video.gresille.org", - "https://peertube.tangentfox.com", "https://puffy.tube", "https://tube.kher.nl", "https://watch.ocaml.org", "https://peertube.kleph.eu", "https://tube.missbanal.net", "https://pityu.flaki.hu", - "https://tv.catalpafestival.fr", "https://pony.tube", "https://peertube.umeahackerspace.se", "https://tube.okcinfo.news", @@ -1250,7 +1268,6 @@ "https://peertube.scyldings.com", "https://gade.o-k-i.net", "https://peertube.mobilsicher.de", - "https://video.jigmedatse.com", "https://video.amiga-ng.org", "https://peertube.espace.si", "https://videos.supertuxkart.net", @@ -1264,7 +1281,6 @@ "https://peertube.w.utnw.de", "https://tube.sp-codes.de", "https://tube.apolut.net", - "https://tube.mfraters.net", "https://tube.pyngu.com", "https://peertube.troback.com", "https://peertube.ucy.de", @@ -1300,7 +1316,6 @@ "https://video.gyt.is", "https://peertube.jensdiemer.de", "https://tube.futuretic.fr", - "https://libra.syntazia.org", "https://peertube.beeldengeluid.nl", "https://tv.lumbung.space", "https://peertube.cuatrolibertades.org", @@ -1318,7 +1333,6 @@ "https://peertube.radres.xyz", "https://darkvapor.nohost.me", "https://tube.chaoszone.tv", - "https://media.over-world.org", "https://tube.avensio.de", "https://peertube.klaewyss.fr", "https://sender-fm.veezee.tube", @@ -1332,7 +1346,6 @@ "https://peertube.iriseden.eu", "https://video.shitposter.club", "https://tv.mattchristiansenmedia.com", - "https://tube.hackerscop.org", "https://peertube.kx.studio", "https://videos.3d-wolf.com", "https://tube.octaplex.net", @@ -1355,7 +1368,6 @@ "https://tube.frischesicht.de", "https://peertube1.zeteo.me", "https://conspiracydistillery.com", - "https://peertube.chemnitz.freifunk.net", "https://hpstube.fr", "https://video.blast-info.fr", "https://peertube.bubuit.net", @@ -1380,7 +1392,6 @@ "https://peertube.inapurna.org", "https://watch.libertaria.space", "https://video.triplea.fr", - "https://video.catgirl.biz", "https://vulgarisation-informatique.fr", "https://tube.kotur.org", "https://peertube.euskarabildua.eus", @@ -1430,7 +1441,6 @@ "https://evangelisch.video", "https://tube.anufrij.de", "https://videos.mastodont.cat", - "https://video.taboulisme.com", "https://media.undeadnetwork.de", "https://tube.dragonpsi.xyz", "https://peertube.nicolastissot.fr", @@ -1504,11 +1514,9 @@ "https://video.csc49.fr", "https://tube.wolfe.casa", "https://video.dresden.network", - "https://peertube.zapashcanon.fr", "https://40two.tube", "https://tube.amic37.fr", "https://video.comptoir.net", - "https://kino.schuerz.at", "https://peertube.tiennot.net", "https://tututu.tube", "https://tube.picasoft.net", @@ -1521,14 +1529,12 @@ "https://videos.testimonia.org", "https://video.mass-trespass.uk", "https://peertube.cipherbliss.com", - "https://peertube.stemy.me", "https://daschauher.aksel.rocks", "https://tube.cyano.at", "https://tube.nox-rhea.org", "https://peertube.securitymadein.lu", "https://tube.rita.moe", "https://tuktube.com", - "https://v.basspistol.org", "https://mytube.kn-cloud.de", "https://tube.nuagelibre.fr", "https://video.nogafam.es", @@ -1547,9 +1553,7 @@ "https://cinema.yunohost.support", "https://peertube.s2s.video", "https://peertube.travelpandas.eu", - "https://video.sdm-tools.net", "https://peertube.anzui.dev", - "https://video.up.edu.ph", "https://video.igem.org", "https://worldofvids.com", "https://peertube.underworld.fr", @@ -1576,8 +1580,6 @@ "https://video.violoncello.ch", "https://peertube.gidikroon.eu", "https://tubedu.org", - "https://watch.breadtube.tv", - "https://video.exodus-privacy.eu.org", "https://tilvids.com", "https://peertube.devloprog.org", "https://peertube.designersethiques.org", @@ -1614,11 +1616,9 @@ "https://peertube.netzbegruenung.de", "https://plextube.nl", "https://tube.opportunis.me", - "https://nanawel-peertube.dyndns.org", "https://tube-strasbourg.beta.education.fr", "https://tube.graz.social", "https://tube-besancon.beta.education.fr", - "https://vid.garwood.io", "https://kolektiva.media", "https://peertube.ichigo.everydayimshuflin.com", "https://video.lundi.am", @@ -1643,7 +1643,6 @@ "https://mplayer.demouliere.eu", "https://video.liberta.vip", "https://peertube.gcfamily.fr", - "https://video.ploud.fr", "https://tube.plaf.fr", "https://tube.nah.re", "https://dreiecksnebel.alex-detsch.de", @@ -1731,7 +1730,6 @@ "https://peertube.makotoworkshop.org", "https://peertube.serveur.slv-valbonne.fr", "https://video.netsyms.com", - "https://video.writeas.org", "https://videos.adhocmusic.com", "https://vid.y-y.li", "https://diode.zone", @@ -1775,4 +1773,4 @@ "https://peertube2.cpy.re", "https://peertube.cpy.re" ] -} \ No newline at end of file +} -- cgit 1.4.1 From 320d0175a8e1223618eb3b8d740b420ef674fc8d Mon Sep 17 00:00:00 2001 From: Hygna Date: Thu, 22 Sep 2022 19:58:07 +0100 Subject: Completed Migration to ejs --- package.json | 2 +- src/assets/images/sendTargets-icon.svg | 52 +---- src/assets/javascripts/services.js | 8 +- src/config/config.json | 67 ++++-- src/instances/get_instances.py | 2 +- src/pages/options/index.html | 109 ++++++--- src/pages/options/widgets/services.js | 2 +- src/pages/popup/popup.ejs | 49 ++++ src/pages/popup/popup.html | 396 ++++++++++++++++++--------------- src/pages/popup/popup.pug | 155 ------------- src/pages/widgets/head.pug | 5 - src/pages/widgets/icons.pug | 46 ---- src/pages/widgets/instances.pug | 15 -- src/pages/widgets/latency.pug | 14 -- src/pages/widgets/links.ejs | 12 +- src/pages/widgets/links.pug | 83 ------- src/pages/widgets/switches.ejs | 11 + 17 files changed, 422 insertions(+), 606 deletions(-) create mode 100644 src/pages/popup/popup.ejs delete mode 100644 src/pages/popup/popup.pug delete mode 100644 src/pages/widgets/head.pug delete mode 100644 src/pages/widgets/icons.pug delete mode 100644 src/pages/widgets/instances.pug delete mode 100644 src/pages/widgets/latency.pug delete mode 100644 src/pages/widgets/links.pug create mode 100644 src/pages/widgets/switches.ejs (limited to 'src/instances') diff --git a/package.json b/package.json index ee0d9089..76f57474 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "pug": "pug ./src/pages/options/*.pug ./src/pages/popup/ -P -w", "prettier": "npx prettier --write .", "instances": "python3 src/instances/get_instances.py; git update-index --assume-unchanged src/instances/blacklist.json src/instances/data.json", - "ejs": "npx ejs src/pages/options/index.ejs -f src/config/config.json -o src/pages/options/index.html" + "ejs": "npx ejs src/pages/options/index.ejs -f src/config/config.json -o src/pages/options/index.html; npx ejs src/pages/popup/popup.ejs -f src/config/config.json -o src/pages/popup/popup.html" }, "repository": { "type": "git", diff --git a/src/assets/images/sendTargets-icon.svg b/src/assets/images/sendTargets-icon.svg index 2ed80a06..5557664e 100644 --- a/src/assets/images/sendTargets-icon.svg +++ b/src/assets/images/sendTargets-icon.svg @@ -1,51 +1,3 @@ - - - - - - - - + + diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js index 79444442..f4c30873 100644 --- a/src/assets/javascripts/services.js +++ b/src/assets/javascripts/services.js @@ -68,7 +68,7 @@ function redirect(url, type, initiator) { let redirectType if (url.pathname == "/") return for (const service in config.services) { - if (!options[service].enabled && !disableOverride) continue + if (!options[service].enabled) continue let targets = service.targets if (targets == "datajson") { browser.storage.local.get(`${service}Targets`, (targets = r[service + "Targets"])) @@ -385,12 +385,12 @@ function initDefaults() { .then(response => response.text()) .then(async data => { let dataJson = JSON.parse(data) - redirects = dataJson.slice() + redirects = JSON.parse(data) browser.storage.local.get(["cloudflareBlackList", "authenticateBlackList", "offlineBlackList"], async r => { for (const service in config.services) { if (config.services[service].targets == "datajson") { browser.storage.local.set({ [service + "Targets"]: [...dataJson[service]] }) - delete redirects[service] + delete dataJson[service] } for (const defaultOption in config.services[service].options) { browser.storage.local.set({ [service + utils.camelCase(defaultOption)]: config.services[service].options[defaultOption] }) @@ -422,7 +422,7 @@ function initDefaults() { } }) browser.storage.local.set({ - redirects, + redirects: dataJson, }) ;() => resolve() }) diff --git a/src/config/config.json b/src/config/config.json index ac393f18..1c8f5f9f 100644 --- a/src/config/config.json +++ b/src/config/config.json @@ -102,7 +102,8 @@ "embedFrontend": "invidious" }, "imageType": "png", - "embeddable": true + "embeddable": true, + "url": "https://youtube.com" }, "youtubeMusic": { "frontends": { @@ -130,7 +131,8 @@ "frontend": "beatbump" }, "imageType": "png", - "embeddable": false + "embeddable": false, + "url": "https://music.youtube.com" }, "twitter": { "frontends": { @@ -169,7 +171,8 @@ "redirectType": "both" }, "imageType": "png", - "embeddable": true + "embeddable": true, + "url": "https://twitter.com" }, "instagram": { "frontends": { @@ -187,7 +190,8 @@ "name": "Instagram", "options": { "enabled": true }, "imageType": "png", - "embeddable": false + "embeddable": false, + "url": "https://instagram.com" }, "tiktok": { "frontends": { @@ -203,7 +207,8 @@ "name": "TikTok", "options": { "enabled": true }, "imageType": "png", - "embeddable": false + "embeddable": false, + "url": "https://tiktok.com" }, "reddit": { "frontends": { @@ -242,7 +247,8 @@ "frontend": "libreddit" }, "imageType": "png", - "embeddable": false + "embeddable": false, + "url": "https://reddit.com" }, "imgur": { "frontends": { @@ -256,7 +262,8 @@ "name": "Imgur", "options": { "enabled": true }, "imageType": "png", - "embeddable": false + "embeddable": false, + "url": "https://imgur.com" }, "wikipedia": { "frontends": { @@ -272,7 +279,8 @@ "name": "Wikipedia", "options": { "enabled": false }, "imageType": "svg", - "embeddable": false + "embeddable": false, + "url": "https://wikipedia.com" }, "medium": { "frontends": { @@ -304,8 +312,9 @@ ], "name": "Medium", "options": { "enabled": true }, - "imageType": "svg", - "embeddable": false + "imageType": "svgMono", + "embeddable": false, + "url": "https://medium.com" }, "quora": { "frontends": { @@ -321,7 +330,8 @@ "name": "Quora", "options": { "enabled": true }, "imageType": "png", - "embeddable": false + "embeddable": false, + "url": "https://quora.com" }, "imdb": { "frontends": { @@ -337,7 +347,8 @@ "name": "IMDb", "options": { "enabled": false }, "imageType": "svg", - "embeddable": false + "embeddable": false, + "url": "https://imdb.com" }, "reuters": { "frontends": { @@ -351,7 +362,8 @@ "name": "Reuters", "options": { "enabled": false }, "imageType": "svg", - "embeddable": false + "embeddable": false, + "url": "https://reuters.com" }, "peertube": { "frontends": { @@ -365,7 +377,8 @@ "name": "PeerTube", "options": { "enabled": false }, "imageType": "svg", - "embeddable": false + "embeddable": false, + "url": "https://search.joinpeertube.org" }, "lbry": { "frontends": { @@ -389,10 +402,12 @@ "options": { "enabled": false, "frontend": "librarian", - "redirectType": "both" + "redirectType": "both", + "embedFrontend": "librarian" }, "imageType": "png", - "embeddable": true + "embeddable": true, + "url": "https://odysee.com" }, "search": { "frontends": { @@ -467,8 +482,9 @@ "enabled": true, "frontend": "searxng" }, - "imageType": "svg", - "embeddable": false + "imageType": "svgMono", + "embeddable": false, + "url": "https://search.libredirect.invalid" }, "translate": { "frontends": { @@ -493,8 +509,9 @@ "enabled": true, "frontend": "simplyTranslate" }, - "imageType": "svg", - "embeddable": false + "imageType": "svgMono", + "embeddable": false, + "url": "https://translate.google.com" }, "maps": { "frontends": { @@ -514,8 +531,9 @@ "enabled": true, "frontend": "osm" }, - "imageType": "svg", - "embeddable": false + "imageType": "svgMono", + "embeddable": false, + "url": "https://maps.google.com" }, "sendTargets": { "frontends": { @@ -528,8 +546,9 @@ "targets": ["^https?:\\/{2}send\\.libredirect\\.invalid\\/$", "^https?:\\/{2}send\\.firefox\\.com\\/$", "^https?:\\/{2}sendfiles\\.online\\/$"], "name": "Send Files", "options": { "enabled": true }, - "imageType": "svg", - "embeddable": false + "imageType": "svgMono", + "embeddable": false, + "url": "https://send.libredirect.invalid" } } } diff --git a/src/instances/get_instances.py b/src/instances/get_instances.py index 2547917a..85bdf1cf 100644 --- a/src/instances/get_instances.py +++ b/src/instances/get_instances.py @@ -446,7 +446,7 @@ def peertube(): 'https://instances.joinpeertube.org/api/v1/instances?start=0&count=1045&sort=-createdAt') rJson = json.loads(r.text) - myList = [] + myList = ['https://search.joinpeertube.org'] for k in rJson['data']: myList.append('https://'+k['host']) diff --git a/src/pages/options/index.html b/src/pages/options/index.html index e1163e99..a23ff247 100644 --- a/src/pages/options/index.html +++ b/src/pages/options/index.html @@ -10,26 +10,85 @@
@@ -169,7 +228,7 @@
-
+
medium
@@ -205,25 +264,25 @@
-
+
search
-
+
translate
-
+
maps
-
+
sendTargets
diff --git a/src/pages/options/widgets/services.js b/src/pages/options/widgets/services.js index 69840de4..b595943e 100644 --- a/src/pages/options/widgets/services.js +++ b/src/pages/options/widgets/services.js @@ -53,7 +53,7 @@ function changeFrontendsSettings(service) { } } } - } else if (Object.keys(config.services[service].frontends) > 1) divs[service].embedFrontend.disabled = true + } else if (Object.keys(config.services[service].frontends).length > 1) divs[service].embedFrontend.disabled = true } } diff --git a/src/pages/popup/popup.ejs b/src/pages/popup/popup.ejs new file mode 100644 index 00000000..efb73e5c --- /dev/null +++ b/src/pages/popup/popup.ejs @@ -0,0 +1,49 @@ + + + + + + + + + +
+ <%- include('src/pages/widgets/switches', {config: config}) -%> +
+
+
+
+
+ <%- include('src/pages/widgets/switches', {config: config}) -%> +
+
+ + + + + +
+ + + + diff --git a/src/pages/popup/popup.html b/src/pages/popup/popup.html index 25f70f48..e21a63a0 100644 --- a/src/pages/popup/popup.html +++ b/src/pages/popup/popup.html @@ -8,189 +8,227 @@
@@ -222,4 +260,4 @@ - \ No newline at end of file + diff --git a/src/pages/popup/popup.pug b/src/pages/popup/popup.pug deleted file mode 100644 index 7da687cc..00000000 --- a/src/pages/popup/popup.pug +++ /dev/null @@ -1,155 +0,0 @@ -include ../widgets/icons.pug - -mixin services - .youtube.some-block - a.title(href="https://youtube.com") - img(src="../../assets/images/youtube-icon.png") - h4(data-localise="__MSG_youtube__") YouTube - input.disable-youtube(type="checkbox") - - .youtubeMusic.some-block - a.title(href="https://music.youtube.com") - img(src="../../assets/images/youtube-music-icon.png") - h4(data-localise="__MSG_ytmusic__") YT Music - input.disable-youtubeMusic(type="checkbox") - - .twitter.some-block - a.title(href="https://twitter.com") - img(src="../../assets/images/twitter-icon.png") - h4(data-localise="__MSG_twitter__") Twitter - input.disable-nitter(type="checkbox") - - .instagram.some-block - a.title(href="https://instagram.com") - img(src="../../assets/images/instagram-icon.png") - h4(data-localise="__MSG_instagram__") Instagram - input.disable-bibliogram(type="checkbox") - - .tiktok.some-block - a.title(href="https://tiktok.com") - img(src="../../assets/images/tiktok-icon.png") - h4(data-localise="__MSG_tiktok__") TikTok - input.disable-tiktok(type="checkbox") - - .imgur.some-block - a.title(href="https://imgur.com") - img(src="../../assets/images/imgur.png") - h4(data-localise="__MSG_imgur__") Imgur - input.disable-imgur(type="checkbox") - - .reddit.some-block - a.title(href="https://reddit.com") - img(src="../../assets/images/reddit-icon.png") - h4(data-localise="__MSG_reddit__") Reddit - input.disable-reddit(type="checkbox") - - .wikipedia.some-block - a.title(href="https://wikipedia.com") - img(src="../../assets/images/wikipedia-icon.svg") - h4(data-localise="__MSG_wikipedia__") Wikipedia - input.disable-wikipedia(type="checkbox") - - .medium.some-block - a.title(href="https://medium.com") - +medium - h4(data-localise="__MSG_medium__") Medium - input.disable-medium(type="checkbox") - - .quora.some-block - a.title(href="https://quora.com") - img(src="../../assets/images/quora.png") - h4(data-localise="__MSG_quora__") Quora - input.disable-quora(type="checkbox") - - .imdb.some-block - a.title(href="https://imdb.com") - img(src="../../assets/images/imdb.svg") - h4(data-localise="__MSG_imdb__") IMDb - input.disable-imdb(type="checkbox") - - .reuters.some-block - a.title(href="https://reuters.com") - img(src="../../assets/images/reuters.svg") - h4(data-localise="__MSG_reuters__") Reuters - input.disable-reuters(type="checkbox") - - .peertube.some-block - a.title(href="https://search.joinpeertube.org") - img(src="../../assets/images/peertube-icon.svg") - h4(data-localise="__MSG_peertube__") PeerTube - input.disable-peertube(type="checkbox") - - .lbry.some-block - a.title(href="https://odysee.com/") - img(src="../../assets/images/lbry-icon.png") - h4(data-localise="__MSG_lbry__") LBRY - input.disable-lbry(type="checkbox") - - .search.some-block - a.title(href="https://search.libredirect.invalid") - +search - h4(data-localise="__MSG_search__") Search - input.disable-search(type="checkbox") - - .translate.some-block - a.title(href="https://translate.google.com") - +translate - h4(data-localise="__MSG_translate__") Translate - input.disable-translate(type="checkbox") - - .maps.some-block - a.title(href="https://www.openstreetmap.org") - +maps - h4(data-localise="__MSG_maps__") Maps - input.disable-osm(type="checkbox") - - .sendTargets.some-block - a.title(href="https://send.libredirect.invalid") - +send - h4(data-localise="__MSG_sendFiles__") Send Files - input.disable-sendTargets(type="checkbox") - -doctype html -html(lang="en") - head - meta(charset="utf-8") - meta(name="viewport" content="width=device-width, initial-scale=1") - link(href="../stylesheets/styles.css" rel="stylesheet") - link(href="./style.css" rel="stylesheet") - body(dir="auto") - .current_site - +services - #current_site_divider - hr - .all_sites - +services - hr - #change_instance_div.some-block - a#change_instance.title.button.prevent - h4(data-localise="__MSG_switchInstance__") Change Instance - +change_instance - - #copy_raw_div.some-block(title="Copy the original redirected link") - a#copy_raw.title.button.prevent - h4(data-localise="__MSG_copyRaw__") Copy Raw - +copy_raw - - #unify_div.some-block(title="Unify cookies across all selected instances") - a#unify.title.button.prevent - h4(data-localise="__MSG_unifySettings__") Unify Settings - +unify - - .some-block - a#more-options.title.button.prevent - h4(data-localise="__MSG_settings__") Settings - +settings - - .some-block - a#about.title.button(href="/pages/options/index.html#about") - h4(data-localise="__MSG_about__") About - +about - - .space - - script(type="module" src="../options/init.js") - script(type="module" src="./popup.js") diff --git a/src/pages/widgets/head.pug b/src/pages/widgets/head.pug deleted file mode 100644 index 53de42d3..00000000 --- a/src/pages/widgets/head.pug +++ /dev/null @@ -1,5 +0,0 @@ -head - meta(charset='utf-8') - meta(name="viewport" content="width=device-width, initial-scale=1") - link(rel="icon" type="image/x-icon" href="../../../assets/images/libredirect.svg") - link(href="../../stylesheets/styles.css" rel="stylesheet") \ No newline at end of file diff --git a/src/pages/widgets/icons.pug b/src/pages/widgets/icons.pug deleted file mode 100644 index cc77ad16..00000000 --- a/src/pages/widgets/icons.pug +++ /dev/null @@ -1,46 +0,0 @@ -mixin medium - svg(xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1770 1000" fill="currentColor") - circle(cx="500" cy="500" r="500") - ellipse(ry="475" rx="250" cy="501" cx="1296") - ellipse(cx="1682" cy="502" rx="88" ry="424") - -mixin search - 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") - -mixin translate - svg(xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor") - path(d="M12.87 15.07l-2.54-2.51.03-.03c1.74-1.94 2.98-4.17 3.71-6.53H17V4h-7V2H8v2H1v1.99h11.17C11.5 7.92 10.44 9.75 9 11.35 8.07 10.32 7.3 9.19 6.69 8h-2c.73 1.63 1.73 3.17 2.98 4.56l-5.09 5.02L4 19l5-5 3.11 3.11.76-2.04zM18.5 10h-2L12 22h2l1.12-3h4.75L21 22h2l-4.5-12zm-2.62 7l1.62-4.33L19.12 17h-3.24z") - -mixin maps - svg(xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor") - path( d="M20.5 3l-.16.03L15 5.1 9 3 3.36 4.9c-.21.07-.36.25-.36.48V20.5c0 .28.22.5.5.5l.16-.03L9 18.9l6 2.1 5.64-1.9c.21-.07.36-.25.36-.48V3.5c0-.28-.22-.5-.5-.5zM10 5.47l4 1.4v11.66l-4-1.4V5.47zm-5 .99l3-1.01v11.7l-3 1.16V6.46zm14 11.08l-3 1.01V6.86l3-1.16v11.84z") - -mixin send - svg(xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor") - path(d="M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM14 13v4h-4v-4H7l5-5 5 5h-3z") - -mixin change_instance - svg(xmlns="http://www.w3.org/2000/svg" height="26px" viewBox="0 0 24 24" width="26px" fill="currentColor") - path(d="M12 4V1L8 5l4 4V6c3.31 0 6 2.69 6 6 0 1.01-.25 1.97-.7 2.8l1.46 1.46C19.54 15.03 20 13.57 20 12c0-4.42-3.58-8-8-8zm0 14c-3.31 0-6-2.69-6-6 0-1.01.25-1.97.7-2.8L5.24 7.74C4.46 8.97 4 10.43 4 12c0 4.42 3.58 8 8 8v3l4-4-4-4v3z") - -mixin settings - svg(xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="26px" viewBox="0 0 24 24" - width="26px" fill="currentColor") - path(d="M19.14,12.94c0.04-0.3,0.06-0.61,0.06-0.94c0-0.32-0.02-0.64-0.07-0.94l2.03-1.58c0.18-0.14,0.23-0.41,0.12-0.61 l-1.92-3.32c-0.12-0.22-0.37-0.29-0.59-0.22l-2.39,0.96c-0.5-0.38-1.03-0.7-1.62-0.94L14.4,2.81c-0.04-0.24-0.24-0.41-0.48-0.41 h-3.84c-0.24,0-0.43,0.17-0.47,0.41L9.25,5.35C8.66,5.59,8.12,5.92,7.63,6.29L5.24,5.33c-0.22-0.08-0.47,0-0.59,0.22L2.74,8.87 C2.62,9.08,2.66,9.34,2.86,9.48l2.03,1.58C4.84,11.36,4.8,11.69,4.8,12s0.02,0.64,0.07,0.94l-2.03,1.58 c-0.18,0.14-0.23,0.41-0.12,0.61l1.92,3.32c0.12,0.22,0.37,0.29,0.59,0.22l2.39-0.96c0.5,0.38,1.03,0.7,1.62,0.94l0.36,2.54 c0.05,0.24,0.24,0.41,0.48,0.41h3.84c0.24,0,0.44-0.17,0.47-0.41l0.36-2.54c0.59-0.24,1.13-0.56,1.62-0.94l2.39,0.96 c0.22,0.08,0.47,0,0.59-0.22l1.92-3.32c0.12-0.22,0.07-0.47-0.12-0.61L19.14,12.94z M12,15.6c-1.98,0-3.6-1.62-3.6-3.6 s1.62-3.6,3.6-3.6s3.6,1.62,3.6,3.6S13.98,15.6,12,15.6z") - -mixin copy_raw - svg(xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor") - path(d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z") - -mixin general - svg(xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="26px" viewBox="0 0 24 24" width="26px" fill="currentColor") - path(d="M19.14,12.94c0.04-0.3,0.06-0.61,0.06-0.94c0-0.32-0.02-0.64-0.07-0.94l2.03-1.58c0.18-0.14,0.23-0.41,0.12-0.61 l-1.92-3.32c-0.12-0.22-0.37-0.29-0.59-0.22l-2.39,0.96c-0.5-0.38-1.03-0.7-1.62-0.94L14.4,2.81c-0.04-0.24-0.24-0.41-0.48-0.41 h-3.84c-0.24,0-0.43,0.17-0.47,0.41L9.25,5.35C8.66,5.59,8.12,5.92,7.63,6.29L5.24,5.33c-0.22-0.08-0.47,0-0.59,0.22L2.74,8.87 C2.62,9.08,2.66,9.34,2.86,9.48l2.03,1.58C4.84,11.36,4.8,11.69,4.8,12s0.02,0.64,0.07,0.94l-2.03,1.58 c-0.18,0.14-0.23,0.41-0.12,0.61l1.92,3.32c0.12,0.22,0.37,0.29,0.59,0.22l2.39-0.96c0.5,0.38,1.03,0.7,1.62,0.94l0.36,2.54 c0.05,0.24,0.24,0.41,0.48,0.41h3.84c0.24,0,0.44-0.17,0.47-0.41l0.36-2.54c0.59-0.24,1.13-0.56,1.62-0.94l2.39,0.96 c0.22,0.08,0.47,0,0.59-0.22l1.92-3.32c0.12-0.22,0.07-0.47-0.12-0.61L19.14,12.94z M12,15.6c-1.98,0-3.6-1.62-3.6-3.6 s1.62-3.6,3.6-3.6s3.6,1.62,3.6,3.6S13.98,15.6,12,15.6z") - -mixin unify - svg(xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor") - path(d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z") - -mixin about - svg( xmlns="http://www.w3.org/2000/svg" height="24" width="24" fill="currentColor") - path( d="M11 17h2v-6h-2Zm1-8q.425 0 .713-.288Q13 8.425 13 8t-.287-.713Q12.425 7 12 7t-.712.287Q11 7.575 11 8t.288.712Q11.575 9 12 9Zm0 13q-2.075 0-3.9-.788-1.825-.787-3.175-2.137-1.35-1.35-2.137-3.175Q2 14.075 2 12t.788-3.9q.787-1.825 2.137-3.175 1.35-1.35 3.175-2.138Q9.925 2 12 2t3.9.787q1.825.788 3.175 2.138 1.35 1.35 2.137 3.175Q22 9.925 22 12t-.788 3.9q-.787 1.825-2.137 3.175-1.35 1.35-3.175 2.137Q14.075 22 12 22Zm0-2q3.35 0 5.675-2.325Q20 15.35 20 12q0-3.35-2.325-5.675Q15.35 4 12 4 8.65 4 6.325 6.325 4 8.65 4 12q0 3a.35 2.325 5.675Q8.65 20 12 20Zm0-8Z") \ No newline at end of file diff --git a/src/pages/widgets/instances.pug b/src/pages/widgets/instances.pug deleted file mode 100644 index 950bd46b..00000000 --- a/src/pages/widgets/instances.pug +++ /dev/null @@ -1,15 +0,0 @@ -mixin instances(myPlaceholder) - .some-block.option-block - h4(data-localise="__MSG_defaultInstances__") Default Instances - - .checklist - hr - .some-block.option-block - h4(data-localise="__MSG_customInstances__") Custom Instances - form.custom-instance-form - .some-block.option-block - input.custom-instance(placeholder=myPlaceholder type="url") - button.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") - .checklist.custom-checklist \ No newline at end of file diff --git a/src/pages/widgets/latency.pug b/src/pages/widgets/latency.pug deleted file mode 100644 index e5bf53b2..00000000 --- a/src/pages/widgets/latency.pug +++ /dev/null @@ -1,14 +0,0 @@ -mixin latency(service) - - var latencyVal - if (service) - - latencyVal = `latency-${service}` - else - - latencyVal = `latency` - - .buttons.buttons-inline - label.button.button-inline(id=`${latencyVal}-label` for=latencyVal) - svg(xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor") - path(d="M19 19H5V5h7V3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-7h-2v7zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3h-7z") - |  - x(data-localise="__MSG_testInstancesLatency__") Test Instances Latency - input.button.button-inline(id=latencyVal style="display:none;") \ No newline at end of file diff --git a/src/pages/widgets/links.ejs b/src/pages/widgets/links.ejs index c28d3668..86b9f260 100644 --- a/src/pages/widgets/links.ejs +++ b/src/pages/widgets/links.ejs @@ -1,7 +1,13 @@ diff --git a/src/pages/widgets/links.pug b/src/pages/widgets/links.pug deleted file mode 100644 index c7f8e0a6..00000000 --- a/src/pages/widgets/links.pug +++ /dev/null @@ -1,83 +0,0 @@ -include ./icons.pug - -mixin links(service) - section#links.links - .title - +general - a(href="#general" data-localise="__MSG_general__") General - - .title - img(src="../../../assets/images/youtube-icon.png") - a(href="#youtube" data-localise="__MSG_youtube__") YouTube - - .title - img(src="../../../assets/images/youtube-music-icon.png") - a(href="#youtubeMusic" data-localise="__MSG_ytmusic__") YT Music - - .title - img(src="../../../assets/images/twitter-icon.png") - a(href="#twitter" data-localise="__MSG_twitter__") Twitter - - .title - img(src="../../../assets/images/instagram-icon.png") - a(href="#instagram" data-localise="__MSG_instagram__") Instagram - - .title - img(src="../../../assets/images/tiktok-icon.png") - a(href="#tiktok" data-localise="__MSG_tiktok__") TikTok - - .title - img(src="../../../assets/images/reddit-icon.png") - a(href="#reddit" data-localise="__MSG_reddit__") Reddit - - .title - img(src="../../../assets/images/imgur.png") - a(href="#imgur" data-localise="__MSG_imgur__") Imgur - - .title - img(src="../../../assets/images/wikipedia-icon.svg") - a(href="#wikipedia" data-localise="__MSG_wikipedia__") Wikipedia - - .title - +medium - a(href="#medium" data-localise="__MSG_medium__") Medium - - .title - img(src="../../../assets/images/quora.png") - a(href="#quora" data-localise="__MSG_quora__") Quora - - .title - img(src="../../../assets/images/imdb.svg") - a(href="#imdb" data-localise="__MSG_imdb__") IMDb - - .title - img(src="../../../assets/images/reuters.svg") - a(href="#reuters" data-localise="__MSG_reuters__") Reuters - - .title - img(src="../../../assets/images/peertube-icon.svg") - a(href="#peertube" data-localise="__MSG_peertube__") PeerTube - - .title - img(src="../../../assets/images/lbry-icon.png") - a(href="#lbry" data-localise="__MSG_lbry__") LBRY - - .title - +search - a(href="#search" data-localise="__MSG_search__") Search - - .title - +translate - a(href="#translate" data-localise="__MSG_translate__") Translate - - .title - +maps - a(href="#maps" data-localise="__MSG_maps__") Maps - - .title - +send - a(href="#sendTargets" data-localise="__MSG_sendFiles__") Send Files - - .title - +about - a(href="#about" data-localise="__MSG_about") About diff --git a/src/pages/widgets/switches.ejs b/src/pages/widgets/switches.ejs new file mode 100644 index 00000000..45bcd790 --- /dev/null +++ b/src/pages/widgets/switches.ejs @@ -0,0 +1,11 @@ +<% for (const service in config.services) { -%> + +<% } %> -- cgit 1.4.1 From 378fab21c081735311f4b3dab9d3423d955b400b Mon Sep 17 00:00:00 2001 From: Hygna Date: Mon, 26 Sep 2022 18:32:32 +0100 Subject: Changes Changed some regex Made ejs no longer need extra config member variable Added url reversal --- src/assets/javascripts/services.js | 42 +- src/assets/javascripts/utils.js | 8 +- src/config/config.json | 1012 ++++++++++++++++----------------- src/instances/get_instances.py | 30 +- src/pages/options/index.ejs | 6 +- src/pages/options/widgets/general.js | 3 +- src/pages/options/widgets/services.js | 3 +- src/pages/popup/popup.ejs | 4 +- src/pages/popup/popup.js | 3 +- src/pages/widgets/links.ejs | 8 +- 10 files changed, 556 insertions(+), 563 deletions(-) (limited to 'src/instances') diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js index 309d5528..25e998d2 100644 --- a/src/assets/javascripts/services.js +++ b/src/assets/javascripts/services.js @@ -11,8 +11,7 @@ async function getConfig() { fetch("/config/config.json") .then(response => response.text()) .then(data => { - const tmp = JSON.parse(data) - config = tmp.config + config = JSON.parse(data) resolve() }) }) @@ -55,7 +54,7 @@ function all(service) { for (const frontend in config.services[service].frontends) { if (config.services[service].frontends[frontend].instanceList) { for (const network in config.networks) { - tmp.push(...redirects[frontend][network]) + tmp.push(...redirects[frontend][network], ...options[frontend][network].custom) } } else if (config.services[service].frontends[frontend].singleInstance != undefined) tmp.push(config.services[service].frontends[frontend].singleInstance) } @@ -168,10 +167,10 @@ function redirect(url, type, initiator) { } else if (url.pathname.split("/").includes("tweets")) return `${randomInstance}${url.pathname.replace("/tweets", "")}${url.search}` else if (url.host == "t.co") return `${randomInstance}/t.co${url.pathname}` else return `${randomInstance}${url.pathname}${url.search}` - case "yatte": + case "yattee": return url.href.replace(/^https?:\/{2}/, "yattee://") case "freetube": - return `freetube://https://youtube.com${url.pathname}${url.search}` + return `freetube://https://youtu.be${url.pathname}${url.search}`.replace(/watch\?v=/, "") case "simplyTranslate": return `${randomInstance}/${url.search}` case "osm": { @@ -462,9 +461,9 @@ function switchInstance(url) { return new Promise(async resolve => { await init() await getConfig() + const protocolHost = utils.protocolHost(url) for (const service in config.services) { if (!options[service].enabled) continue - const protocolHost = utils.protocolHost(url) if (!all(service).includes(protocolHost)) continue let instancesList = [...options[options[service].frontend][options.network].checks, ...options[options[service].frontend][options.network].custom] @@ -485,15 +484,44 @@ function switchInstance(url) { // This is to make instance switching work when the instance depends on the pathname, eg https://darmarit.org/searx // Doesn't work because of .includes array method, not a top priotiry atm resolve(oldUrl.replace(oldInstance, randomInstance)) + return } resolve() }) } +function reverse(url) { + return new Promise(async resolve => { + await init() + await getConfig() + let protocolHost = utils.protocolHost(url) + let currentService + for (const service in config.services) { + if (!all(service).includes(protocolHost)) continue + currentService = service + } + switch (currentService) { + case "instagram": + if (url.pathname.startsWith("/p")) resolve(`https://instagram.com${url.pathname.replace("/p", "")}${url.search}`) + if (url.pathname.startsWith("/u")) resolve(`https://instagram.com${url.pathname.replace("/u", "")}${url.search}`) + case "youtube": + case "imdb": + case "imgur": + case "tiktok": + case "twitter": + resolve(config.services[currentService].url + url.pathname + url.search) + return + default: + resolve() + return + } + }) +} + export default { redirect, initDefaults, computeService, switchInstance, - init, + reverse, } diff --git a/src/assets/javascripts/utils.js b/src/assets/javascripts/utils.js index 371838ff..c28af018 100644 --- a/src/assets/javascripts/utils.js +++ b/src/assets/javascripts/utils.js @@ -408,13 +408,7 @@ function copyRaw(test, copyRawElement) { return } - let newUrl = await youtubeHelper.reverse(url) - if (!newUrl) newUrl = await twitterHelper.reverse(url) - if (!newUrl) newUrl = await instagramHelper.reverse(url) - if (!newUrl) newUrl = await tiktokHelper.reverse(url) - if (!newUrl) newUrl = await quoraHelper.reverse(url) - if (!newUrl) newUrl = await libremdbHelper.reverse(url) - if (!newUrl) newUrl = await imgurHelper.reverse(url) + let newUrl = await servicesHelper.reverse(url) if (newUrl) { resolve(newUrl) diff --git a/src/config/config.json b/src/config/config.json index 84f430fa..ca835d51 100644 --- a/src/config/config.json +++ b/src/config/config.json @@ -1,548 +1,546 @@ { - "config": { - "networks": { - "clearnet": { - "tld": "org", - "name": "Clearnet" - }, - "tor": { - "tld": "onion", - "name": "Tor" - }, - "i2p": { - "tld": "i2p", - "name": "I2P" - }, - "loki": { - "tld": "loki", - "name": "Lokinet" - } + "networks": { + "clearnet": { + "tld": "org", + "name": "Clearnet" }, - "services": { - "youtube": { - "frontends": { - "invidious": { - "preferences": { - "cookies": ["PREFS"] - }, - "name": "Invidious", - "embeddable": true, - "instanceList": true - }, - "piped": { - "preferences": { - "localstorage": [ - "bufferGoal", - "comments", - "disableLBRY", - "enabledCodecs", - "hl", - "homepage", - "instance", - "listen", - "minimizeDescription", - "playerAutoPlay", - "proxyLBRY", - "quality", - "region", - "selectedSkip", - "sponsorblock", - "theme", - "volume", - "watchHistory" - ] - }, - "name": "Piped", - "embeddable": true, - "instanceList": true - }, - "pipedMaterial": { - "preferences": { - "localstorage": ["PREFERENCES"] - }, - "name": "Piped-Material", - "embeddable": false, - "instanceList": true - }, - "cloudtube": { - "preferences": { - "token": "token", - "fetchEndpoint": "/api/settings", - "setEndpoint": "/settings" - }, - "name": "CloudTube", - "embeddable": false, - "instanceList": true + "tor": { + "tld": "onion", + "name": "Tor" + }, + "i2p": { + "tld": "i2p", + "name": "I2P" + }, + "loki": { + "tld": "loki", + "name": "Lokinet" + } + }, + "services": { + "youtube": { + "frontends": { + "invidious": { + "preferences": { + "cookies": ["PREFS"] }, - "freetube": { - "name": "FreeTube", - "embeddable": false, - "instanceList": false + "name": "Invidious", + "embeddable": true, + "instanceList": true + }, + "piped": { + "preferences": { + "localstorage": [ + "bufferGoal", + "comments", + "disableLBRY", + "enabledCodecs", + "hl", + "homepage", + "instance", + "listen", + "minimizeDescription", + "playerAutoPlay", + "proxyLBRY", + "quality", + "region", + "selectedSkip", + "sponsorblock", + "theme", + "volume", + "watchHistory" + ] }, - "yattee": { - "name": "Yattee", - "embeddable": false, - "instanceList": false - } + "name": "Piped", + "embeddable": true, + "instanceList": true }, - "targets": [ - "^https?:\\/{2}(?:www\\.|m\\.|)youtube.com(?!iframe_api\\/.*)", - "^https?:\\/{2}img\\.youtube.com\\/vi\\/.*\\/..*", - "^https?:\\/{2}(?:i|s)\\.ytimg.com\\/vi\\/.*\\/..*", - "^https?:\\/{2}(?:www\\.|music\\.|)youtube.com\\/watch?v=..*", - "^https?:\\/{2}youtu\\.be\\/..*", - "^https?:\\/{2}(?:www\\.|)(youtube|youtube-nocookie)\\.com\\/embed\\/..*" - ], - "name": "Youtube", - "options": { - "enabled": true, - "redirectType": "both", - "frontend": "invidious", - "embedFrontend": "invidious" + "pipedMaterial": { + "preferences": { + "localstorage": ["PREFERENCES"] + }, + "name": "Piped-Material", + "embeddable": false, + "instanceList": true }, - "imageType": "png", - "embeddable": true, - "url": "https://youtube.com" - }, - "youtubeMusic": { - "frontends": { - "beatbump": { - "preferences": { - "localstorage": ["settings"], - "indexeddb": "beatbump" - }, - "name": "Beatbump", - "instanceList": true + "cloudtube": { + "preferences": { + "token": "token", + "fetchEndpoint": "/api/settings", + "setEndpoint": "/settings" }, - "hyperpipe": { - "preferences": { - "localstorage": ["api", "authapi", "codec", "locale", "next", "pipedapi", "quality", "theme", "vol"], - "indexeddb": ["hyperpipedb"] - }, - "name": "HyperPipe", - "instanceList": true - } + "name": "CloudTube", + "embeddable": false, + "instanceList": true }, - "targets": ["^https?:\\/{2}music\\.youtube\\.com(\\/.*|$)"], - "name": "YT Music", - "options": { - "enabled": true, - "frontend": "beatbump" + "freetube": { + "name": "FreeTube", + "embeddable": false, + "instanceList": false }, - "imageType": "png", - "embeddable": false, - "url": "https://music.youtube.com" + "yattee": { + "name": "Yattee", + "embeddable": false, + "instanceList": false + } }, - "twitter": { - "frontends": { - "nitter": { - "preferences": { - "cookies": [ - "theme", - "infiniteScroll", - "stickyProfile", - "bidiSupport", - "hideTweetStats", - "hideBanner", - "hidePins", - "hideReplies", - "squareAvatars", - "mp4Playback", - "hlsPlayback", - "proxyVideos", - "muteVideos", - "autoplayGifs", - "replaceInstagram", - "replaceReddit", - "replaceTwitter", - "replaceYouTube" - ] - }, - "name": "Nitter", - "embeddable": true, - "instanceList": true - } - }, - "targets": ["^https?:\\/{2}(www\\.|mobile\\.|)twitter\\.com", "^https?:\\/{2}(pbs\\.|video\\.|)twimg\\.com", "^https?:\\/{2}platform\\.twitter\\.com/embed", "^https?:\\/{2}t\\.co"], - "name": "Twitter", - "options": { - "enabled": true, - "redirectType": "both" - }, - "imageType": "png", - "embeddable": true, - "url": "https://twitter.com" + "targets": [ + "^https?:\\/{2}(?:www\\.|m\\.|)youtube.com(?!iframe_api\\/.*)", + "^https?:\\/{2}img\\.youtube.com\\/vi\\/.*\\/..*", + "^https?:\\/{2}(?:i|s)\\.ytimg.com\\/vi\\/.*\\/..*", + "^https?:\\/{2}(?:www\\.|music\\.|)youtube.com\\/watch?v=..*", + "^https?:\\/{2}youtu\\.be\\/..*", + "^https?:\\/{2}(?:www\\.|)(youtube|youtube-nocookie)\\.com\\/embed\\/..*" + ], + "name": "Youtube", + "options": { + "enabled": true, + "redirectType": "both", + "frontend": "invidious", + "embedFrontend": "invidious" }, - "instagram": { - "frontends": { - "bibliogram": { - "preferences": { - "token": "token", - "fetchEndpoint": "/settings.json", - "setEndpoint": "/applysettings" - }, - "name": "Bibliogram", - "instanceList": true - } + "imageType": "png", + "embeddable": true, + "url": "https://youtube.com" + }, + "youtubeMusic": { + "frontends": { + "beatbump": { + "preferences": { + "localstorage": ["settings"], + "indexeddb": "beatbump" + }, + "name": "Beatbump", + "instanceList": true }, - "targets": ["^https?:\\/{2}(www\\.)?instagram\\.com"], - "name": "Instagram", - "options": { "enabled": true }, - "imageType": "png", - "embeddable": false, - "url": "https://instagram.com" + "hyperpipe": { + "preferences": { + "localstorage": ["api", "authapi", "codec", "locale", "next", "pipedapi", "quality", "theme", "vol"], + "indexeddb": ["hyperpipedb"] + }, + "name": "HyperPipe", + "instanceList": true + } }, - "tiktok": { - "frontends": { - "proxiTok": { - "preferences": { - "cookies": ["api-test_endpoints", "theme"] - }, - "name": "ProxiTok", - "instanceList": true - } - }, - "targets": ["^https?:\\/{2}(www\\.|)tiktok\\.com.*"], - "name": "TikTok", - "options": { "enabled": true }, - "imageType": "png", - "embeddable": false, - "url": "https://tiktok.com" + "targets": ["^https?:\\/{2}music\\.youtube\\.com(\\/.*|$)"], + "name": "YT Music", + "options": { + "enabled": true, + "frontend": "beatbump" }, - "reddit": { - "frontends": { - "libreddit": { - "preferences": { - "cookies": ["theme", "front_page", "layout", "wide", "post_sort", "comment_sort", "show_nsfw", "autoplay_videos", "use_hls", "hide_hls_notification", "subscriptions", "filters"] - }, - "name": "Libreddit", - "instanceList": true + "imageType": "png", + "embeddable": false, + "url": "https://music.youtube.com" + }, + "twitter": { + "frontends": { + "nitter": { + "preferences": { + "cookies": [ + "theme", + "infiniteScroll", + "stickyProfile", + "bidiSupport", + "hideTweetStats", + "hideBanner", + "hidePins", + "hideReplies", + "squareAvatars", + "mp4Playback", + "hlsPlayback", + "proxyVideos", + "muteVideos", + "autoplayGifs", + "replaceInstagram", + "replaceReddit", + "replaceTwitter", + "replaceYouTube" + ] }, - "teddit": { - "preferences": { - "cookies": [ - "collapse_child_comments", - "domain_instagram", - "domain_twitter", - "domain_youtube", - "flairs", - "highlight_controversial", - "nsfw_enabled", - "post_media_max_height", - "show_upvoted_percentage", - "show_upvotes", - "theme", - "videos_muted" - ] - }, - "name": "Teddit", - "instanceList": true - } - }, - "targets": ["^https?:\\/{2}(www\\.|old\\.|np\\.|new\\.|amp\\.|)reddit\\.com", "^https?:\\/{2}(i\\.|preview\\.)redd\\.it"], - "name": "Reddit", - "options": { - "enabled": true, - "frontend": "libreddit" - }, - "imageType": "png", - "embeddable": false, - "url": "https://reddit.com" + "name": "Nitter", + "embeddable": true, + "instanceList": true + } }, - "imgur": { - "frontends": { - "rimgo": { - "name": "rimgo", - "instanceList": true - } - }, - "targets": ["^https?:\\/{2}([im]\\.)?imgur\\.(com|io)(\\/|$)"], - "name": "Imgur", - "options": { "enabled": true }, - "imageType": "png", - "embeddable": false, - "url": "https://imgur.com" - }, - "wikipedia": { - "frontends": { - "wikiless": { - "preferences": { - "cookies": ["theme", "default_lang"] - }, - "name": "Wikiless", - "instanceList": true - } - }, - "targets": ["^https?:\\/{2}(?:[a-z]+\\.)*wikipedia\\.org"], - "name": "Wikipedia", - "options": { "enabled": false }, - "imageType": "svg", - "embeddable": false, - "url": "https://wikipedia.com" + "targets": ["^https?:\\/{2}(www\\.|mobile\\.|)twitter\\.com", "^https?:\\/{2}(pbs\\.|video\\.|)twimg\\.com", "^https?:\\/{2}platform\\.twitter\\.com/embed", "^https?:\\/{2}t\\.co"], + "name": "Twitter", + "options": { + "enabled": true, + "redirectType": "both" }, - "medium": { - "frontends": { - "scribe": { - "name": "Scribe", - "instanceList": true - } - }, - "targets": [ - "(?:.*\\.)*(? <%- include('src/pages/widgets/head') -%> - <%- include('src/pages/widgets/links', {config: config}) -%> + <%- include('src/pages/widgets/links', {services: services}) -%>
- <%- include('src/pages/options/widgets/general', {config: config}) -%> - <%- include('src/pages/options/widgets/services', {config: config}) -%> + <%- include('src/pages/options/widgets/general', {config: {networks, services}}) -%> + <%- include('src/pages/options/widgets/services', {config: {networks, services}}) -%> <%- include('src/pages/options/widgets/about') -%>
diff --git a/src/pages/options/widgets/general.js b/src/pages/options/widgets/general.js index 2249f830..cfc95df2 100644 --- a/src/pages/options/widgets/general.js +++ b/src/pages/options/widgets/general.js @@ -22,8 +22,7 @@ async function getConfig() { fetch("/config/config.json") .then(response => response.text()) .then(data => { - const tmp = JSON.parse(data) - config = tmp.config + config = JSON.parse(data) resolve() }) }) diff --git a/src/pages/options/widgets/services.js b/src/pages/options/widgets/services.js index b595943e..dbb66dec 100644 --- a/src/pages/options/widgets/services.js +++ b/src/pages/options/widgets/services.js @@ -9,8 +9,7 @@ function getConfig() { fetch("/config/config.json") .then(response => response.text()) .then(data => { - const tmp = JSON.parse(data) - config = tmp.config + config = JSON.parse(data) resolve() }) }) diff --git a/src/pages/popup/popup.ejs b/src/pages/popup/popup.ejs index efb73e5c..5b3bb026 100644 --- a/src/pages/popup/popup.ejs +++ b/src/pages/popup/popup.ejs @@ -8,13 +8,13 @@
- <%- include('src/pages/widgets/switches', {config: config}) -%> + <%- include('src/pages/widgets/switches', {config: {networks, services}}) -%>

- <%- include('src/pages/widgets/switches', {config: config}) -%> + <%- include('src/pages/widgets/switches', {config: {networks, services}}) -%>

<% }; -%>
<%- include ('src/assets/images/about-icon.svg') %>About
-- cgit 1.4.1 From f1b8b64c48fede90ee9c828c1b82e641c0fe653d Mon Sep 17 00:00:00 2001 From: Hygna Date: Thu, 29 Sep 2022 18:32:03 +0100 Subject: Changes: Improved instance fetcher Added instance updating Fix a few bugs --- package.json | 8 +- src/assets/javascripts/general.js | 2 +- src/assets/javascripts/imdb.js | 216 ------ src/assets/javascripts/imgur.js | 216 ------ src/assets/javascripts/instagram.js | 244 ------- src/assets/javascripts/lbry.js | 218 ------ src/assets/javascripts/maps.js | 304 -------- src/assets/javascripts/medium.js | 222 ------ src/assets/javascripts/peertube.js | 204 ------ src/assets/javascripts/quora.js | 202 ------ src/assets/javascripts/reddit.js | 394 ---------- src/assets/javascripts/reuters.js | 150 ---- src/assets/javascripts/search.js | 576 --------------- src/assets/javascripts/sendTargets.js | 195 ----- src/assets/javascripts/services.js | 39 +- src/assets/javascripts/tiktok.js | 246 ------- .../translate/get_lingva_preferences.js | 10 - .../translate/set_lingva_preferences.js | 9 - src/assets/javascripts/translate/translate.js | 372 ---------- src/assets/javascripts/twitter.js | 268 ------- src/assets/javascripts/utils.js | 60 +- src/assets/javascripts/wikipedia.js | 242 ------- .../youtube/get_pipedMaterial_preferences.js | 5 - .../javascripts/youtube/get_piped_preferences.js | 22 - .../youtube/set_pipedMaterial_preferences.js | 7 - .../javascripts/youtube/set_piped_preferences.js | 45 -- src/assets/javascripts/youtube/youtube.js | 792 --------------------- src/assets/javascripts/youtubeMusic.js | 327 --------- src/config/config.json | 2 +- src/instances/get_instances.py | 77 +- src/pages/options/widgets/general.js | 3 +- src/pages/options/widgets/services.js | 2 +- 32 files changed, 71 insertions(+), 5608 deletions(-) delete mode 100644 src/assets/javascripts/imdb.js delete mode 100644 src/assets/javascripts/imgur.js delete mode 100644 src/assets/javascripts/instagram.js delete mode 100644 src/assets/javascripts/lbry.js delete mode 100644 src/assets/javascripts/maps.js delete mode 100644 src/assets/javascripts/medium.js delete mode 100644 src/assets/javascripts/peertube.js delete mode 100644 src/assets/javascripts/quora.js delete mode 100644 src/assets/javascripts/reddit.js delete mode 100644 src/assets/javascripts/reuters.js delete mode 100644 src/assets/javascripts/search.js delete mode 100644 src/assets/javascripts/sendTargets.js delete mode 100644 src/assets/javascripts/tiktok.js delete mode 100644 src/assets/javascripts/translate/get_lingva_preferences.js delete mode 100644 src/assets/javascripts/translate/set_lingva_preferences.js delete mode 100644 src/assets/javascripts/translate/translate.js delete mode 100644 src/assets/javascripts/twitter.js delete mode 100644 src/assets/javascripts/wikipedia.js delete mode 100644 src/assets/javascripts/youtube/get_pipedMaterial_preferences.js delete mode 100644 src/assets/javascripts/youtube/get_piped_preferences.js delete mode 100644 src/assets/javascripts/youtube/set_pipedMaterial_preferences.js delete mode 100644 src/assets/javascripts/youtube/set_piped_preferences.js delete mode 100644 src/assets/javascripts/youtube/youtube.js delete mode 100644 src/assets/javascripts/youtubeMusic.js (limited to 'src/instances') diff --git a/package.json b/package.json index ec39aee4..74bb60b3 100644 --- a/package.json +++ b/package.json @@ -14,17 +14,17 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/LibRedirect/LibRedirect.git" + "url": "git+https://codeberg.org/LibRedirect/LibRedirect.git" }, "author": "LibRedirect", "license": "GPL-3.0-only", "bugs": { - "url": "https://github.com/LibRedirect/LibRedirect/issues" + "url": "https://codeberg.org/LibRedirect/LibRedirect/issues" }, - "homepage": "https://libredirect.github.io", + "homepage": "https://libredirect.codeberg.page", "devDependencies": { "prettier": "2.7.1", - "web-ext": "^6.7.0" + "web-ext": "^7.2.0" }, "dependencies": { "buffer": "^6.0.3", diff --git a/src/assets/javascripts/general.js b/src/assets/javascripts/general.js index 9dcba752..6eb0a454 100644 --- a/src/assets/javascripts/general.js +++ b/src/assets/javascripts/general.js @@ -12,7 +12,7 @@ function isException(url) { function init() { return new Promise(resolve => { browser.storage.local.get("options", r => { - exceptions = r.options.exceptions + if (r.options) exceptions = r.options.exceptions resolve() }) }) diff --git a/src/assets/javascripts/imdb.js b/src/assets/javascripts/imdb.js deleted file mode 100644 index 57368557..00000000 --- a/src/assets/javascripts/imdb.js +++ /dev/null @@ -1,216 +0,0 @@ -window.browser = window.browser || window.chrome - -import utils from "./utils.js" - -const targets = [/^https?:\/{2}(?:www\.|)imdb\.com.*/] - -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", "offlineBlackList"], r => { - redirects.libremdb = val - 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({ - imdbRedirects: redirects, - libremdbNormalRedirectsChecks, - libremdbTorRedirectsChecks: [...redirects.libremdb.tor], - libremdbI2pRedirectsChecks: [...redirects.libremdb.i2p], - libremdbLokiRedirectsChecks: [...redirects.libremdb.loki], - }) - }) -} - -let disableImdb, - protocol, - protocolFallback, - imdbRedirects, - libremdbNormalRedirectsChecks, - libremdbNormalCustomRedirects, - libremdbTorRedirectsChecks, - libremdbTorCustomRedirects, - libremdbI2pCustomRedirects, - libremdbLokiCustomRedirects - -function init() { - return new Promise(async resolve => { - browser.storage.local.get( - [ - "disableImdb", - "protocol", - "protocolFallback", - "imdbRedirects", - "libremdbNormalRedirectsChecks", - "libremdbNormalCustomRedirects", - "libremdbTorRedirectsChecks", - "libremdbTorCustomRedirects", - "libremdbI2pCustomRedirects", - "libremdbLokiCustomRedirects", - ], - r => { - disableImdb = r.disableImdb - protocol = r.protocol - protocolFallback = r.protocolFallback - imdbRedirects = r.imdbRedirects - libremdbNormalRedirectsChecks = r.libremdbNormalRedirectsChecks - libremdbNormalCustomRedirects = r.libremdbNormalCustomRedirects - libremdbTorRedirectsChecks = r.libremdbTorRedirectsChecks - libremdbTorCustomRedirects = r.libremdbTorCustomRedirects - libremdbI2pCustomRedirects = r.libremdbI2pCustomRedirects - libremdbLokiCustomRedirects = r.libremdbLokiCustomRedirects - resolve() - } - ) - }) -} - -init() -browser.storage.onChanged.addListener(init) - -function redirect(url, type, initiator, disableOverride) { - if (disableImdb && !disableOverride) return - if (url.pathname == "/") return - if (type != "main_frame") return - const all = [...imdbRedirects.libremdb.normal, ...libremdbNormalCustomRedirects] - if (initiator && (all.includes(initiator.origin) || targets.includes(initiator.host))) return - if (!targets.some(rx => rx.test(url.href))) return - - let instancesList = [] - if (protocol == "loki") instancesList = [...libremdbLokiCustomRedirects] - else if (protocol == "i2p") instancesList = [...libremdbI2pCustomRedirects] - else 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}` -} - -function reverse(url) { - return new Promise(async resolve => { - await init() - let protocolHost = utils.protocolHost(url) - const all = [ - ...imdbRedirects.libremdb.normal, - ...imdbRedirects.libremdb.tor, - ...libremdbNormalCustomRedirects, - ...libremdbTorCustomRedirects, - ...libremdbI2pCustomRedirects, - ...libremdbLokiCustomRedirects, - ] - if (!all.includes(protocolHost)) { - resolve() - return - } - - resolve(`https://imdb.com${url.pathname}${url.search}`) - }) -} - -function switchInstance(url, disableOverride) { - return new Promise(async resolve => { - await init() - if (disableImdb && !disableOverride) { - resolve() - return - } - let protocolHost = utils.protocolHost(url) - const all = [ - ...imdbRedirects.libremdb.tor, - ...imdbRedirects.libremdb.normal, - - ...libremdbNormalCustomRedirects, - ...libremdbTorCustomRedirects, - ...libremdbI2pCustomRedirects, - ...libremdbLokiCustomRedirects, - ] - if (!all.includes(protocolHost)) { - resolve() - return - } - - let instancesList = [] - if (protocol == "loki") instancesList = [...libremdbLokiCustomRedirects] - else if (protocol == "i2p") instancesList = [...libremdbI2pCustomRedirects] - else 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) - if (instancesList.length === 0) { - resolve() - return - } - - const randomInstance = utils.getRandomInstance(instancesList) - resolve(`${randomInstance}${url.pathname}${url.search}`) - }) -} - -function initDefaults() { - 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.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, - libremdbNormalCustomRedirects: [], - - libremdbTorRedirectsChecks: [...redirects.libremdb.tor], - libremdbTorCustomRedirects: [], - - libremdbI2pRedirectsChecks: [], - libremdbI2pCustomRedirects: [], - - libremdbLokiRedirectsChecks: [], - libremdbLokiCustomRedirects: [], - }, - () => resolve() - ) - }) - }) - }) -} - -export default { - setRedirects, - - redirect, - reverse, - switchInstance, - - initDefaults, -} diff --git a/src/assets/javascripts/imgur.js b/src/assets/javascripts/imgur.js deleted file mode 100644 index 15b9ccac..00000000 --- a/src/assets/javascripts/imgur.js +++ /dev/null @@ -1,216 +0,0 @@ -window.browser = window.browser || window.chrome - -import utils from "./utils.js" - -const targets = /^https?:\/{2}([im]\.)?imgur\.(com|io)(\/|$)/ - -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(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, - rimgoTorRedirectsChecks: [...redirects.rimgo.tor], - rimgoI2pRedirectsChecks: [...redirects.rimgo.i2p], - rimgoLokiRedirectsChecks: [...redirects.rimgo.loki], - }) - }) -} - -let disableImgur, - imgurRedirects, - protocol, - protocolFallback, - rimgoNormalRedirectsChecks, - rimgoNormalCustomRedirects, - rimgoTorRedirectsChecks, - rimgoTorCustomRedirects, - rimgoI2pRedirectsChecks, - rimgoI2pCustomRedirects, - rimgoLokiCustomRedirects - -function init() { - return new Promise(async resolve => { - browser.storage.local.get( - [ - "disableImgur", - "imgurRedirects", - "protocol", - "protocolFallback", - "rimgoNormalRedirectsChecks", - "rimgoNormalCustomRedirects", - "rimgoTorRedirectsChecks", - "rimgoTorCustomRedirects", - "rimgoI2pRedirectsChecks", - "rimgoI2pCustomRedirects", - "rimgoLokiCustomRedirects", - ], - r => { - disableImgur = r.disableImgur - imgurRedirects = r.imgurRedirects - protocol = r.protocol - protocolFallback = r.protocolFallback - rimgoNormalRedirectsChecks = r.rimgoNormalRedirectsChecks - rimgoNormalCustomRedirects = r.rimgoNormalCustomRedirects - rimgoTorRedirectsChecks = r.rimgoTorRedirectsChecks - rimgoTorCustomRedirects = r.rimgoTorCustomRedirects - rimgoI2pRedirectsChecks = r.rimgoI2pRedirectsChecks - rimgoI2pCustomRedirects = r.rimgoI2pCustomRedirects - rimgoLokiCustomRedirects = r.rimgoLokiCustomRedirects - resolve() - } - ) - }) -} - -init() -browser.storage.onChanged.addListener(init) - -// https://imgur.com/gallery/s4WXQmn -// https://imgur.com/a/H8M4rcp -// https://imgur.com/gallery/gYiQLWy -// https://imgur.com/gallery/cTRwaJU -// https://i.imgur.com/CFSQArP.jpeg - -function all() { - return [ - ...imgurRedirects.rimgo.normal, - ...imgurRedirects.rimgo.tor, - ...imgurRedirects.rimgo.i2p, - ...rimgoNormalCustomRedirects, - ...rimgoTorCustomRedirects, - ...rimgoI2pCustomRedirects, - ...rimgoLokiCustomRedirects, - ] -} - -function redirect(url, type, initiator, disableOverride) { - if (disableImgur && !disableOverride) return - if (url.pathname == "/" && !disableOverride) return - if (!["main_frame", "sub_frame", "xmlhttprequest", "other", "image", "media"].includes(type)) return - if (initiator && (all().includes(initiator.origin) || targets.test(initiator.host))) return - if (!targets.test(url.href)) return - if (url.pathname.includes("delete/")) return - - let instancesList = [] - if (protocol == "loki") instancesList = [...rimgoLokiCustomRedirects] - else if (protocol == "i2p") instancesList = [...rimgoI2pCustomRedirects, ...rimgoI2pRedirectsChecks] - else 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}` -} - -function reverse(url) { - return new Promise(async resolve => { - await init() - const protocolHost = utils.protocolHost(url) - if (!all().includes(protocolHost)) { - resolve() - return - } - resolve(`https://imgur.com${url.pathname}${url.search}`) - }) -} - -function switchInstance(url, disableOverride) { - return new Promise(async resolve => { - await init() - if (disableImgur && !disableOverride) { - resolve() - return - } - let protocolHost = utils.protocolHost(url) - if (!all().includes(protocolHost)) { - resolve() - return - } - let instancesList = [] - if (protocol == "loki") instancesList = [...rimgoLokiCustomRedirects] - else if (protocol == "i2p") instancesList = [...rimgoI2pCustomRedirects, ...rimgoI2pRedirectsChecks] - else 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) - if (instancesList.length === 0) { - resolve() - return - } - - const randomInstance = utils.getRandomInstance(instancesList) - resolve(`${randomInstance}${url.pathname}${url.search}`) - }) -} - -function initDefaults() { - return new Promise(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.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, - imgurRedirects: redirects, - - rimgoNormalRedirectsChecks: rimgoNormalRedirectsChecks, - rimgoNormalCustomRedirects: [], - - rimgoTorRedirectsChecks: [...redirects.rimgo.tor], - rimgoTorCustomRedirects: [], - - rimgoI2pRedirectsChecks: [...redirects.rimgo.i2p], - rimgoI2pCustomRedirects: [], - - rimgoLokiRedirectsChecks: [...redirects.rimgo.loki], - rimgoLokiCustomRedirects: [], - }, - () => resolve() - ) - }) - }) - }) -} - -export default { - setRedirects, - redirect, - reverse, - initDefaults, - switchInstance, -} diff --git a/src/assets/javascripts/instagram.js b/src/assets/javascripts/instagram.js deleted file mode 100644 index d0aa07c0..00000000 --- a/src/assets/javascripts/instagram.js +++ /dev/null @@ -1,244 +0,0 @@ -window.browser = window.browser || window.chrome -import utils from "./utils.js" - -const targets = ["instagram.com", "www.instagram.com"] - -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", "offlineBlackList"], async r => { - redirects.bibliogram = val - 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({ - instagramRedirects: redirects, - bibliogramNormalRedirectsChecks, - bibliogramTorRedirectsChecks: [...redirects.bibliogram.tor], - bibliogramI2pRedirectsChecks: [...redirects.bibliogram.i2p], - bibliogramLokiRedirectsChecks: [...redirects.bibliogram.loki], - }) - }) -} - -let disableInstagram, - protocol, - protocolFallback, - instagramRedirects, - bibliogramNormalRedirectsChecks, - bibliogramTorRedirectsChecks, - bibliogramNormalCustomRedirects, - bibliogramTorCustomRedirects, - bibliogramI2pCustomRedirects, - bibliogramLokiCustomRedirects - -function init() { - return new Promise(async resolve => { - browser.storage.local.get( - [ - "disableInstagram", - "protocol", - "protocolFallback", - "instagramRedirects", - "bibliogramNormalRedirectsChecks", - "bibliogramTorRedirectsChecks", - "bibliogramNormalCustomRedirects", - "bibliogramTorCustomRedirects", - "bibliogramI2pCustomRedirects", - "bibliogramLokiCustomRedirects", - ], - r => { - disableInstagram = r.disableInstagram - protocol = r.protocol - protocolFallback = r.protocolFallback - instagramRedirects = r.instagramRedirects - bibliogramNormalRedirectsChecks = r.bibliogramNormalRedirectsChecks - bibliogramTorRedirectsChecks = r.bibliogramTorRedirectsChecks - bibliogramNormalCustomRedirects = r.bibliogramNormalCustomRedirects - bibliogramTorCustomRedirects = r.bibliogramTorCustomRedirects - bibliogramI2pCustomRedirects = r.bibliogramI2pCustomRedirects - bibliogramLokiCustomRedirects = r.bibliogramLokiCustomRedirects - resolve() - } - ) - }) -} - -init() -browser.storage.onChanged.addListener(init) - -function initBibliogramPreferences(test, from) { - return new Promise(async resolve => { - await init() - const protocolHost = utils.protocolHost(from) - if ( - ![ - ...bibliogramNormalRedirectsChecks, - ...bibliogramTorRedirectsChecks, - ...bibliogramNormalCustomRedirects, - ...bibliogramTorCustomRedirects, - ...bibliogramI2pCustomRedirects, - ...bibliogramLokiCustomRedirects, - ].includes(protocolHost) - ) { - resolve() - return - } - - if (!test) { - let checkedInstances = [] - if (protocol == "loki") checkedInstances = [...bibliogramLokiCustomRedirects] - else if (protocol == "i2p") checkedInstances = [...bibliogramI2pCustomRedirects] - else if (protocol == "tor") checkedInstances = [...bibliogramTorRedirectsChecks, ...bibliogramTorCustomRedirects] - if ((checkedInstances.length === 0 && protocolFallback) || protocol == "normal") { - checkedInstances = [...bibliogramNormalRedirectsChecks, ...bibliogramNormalCustomRedirects] - } - await utils.getPreferencesFromToken("bibliogram", from, checkedInstances, "settings", "settings.json") - } - resolve(true) - }) -} - -function all() { - return [ - ...bibliogramNormalRedirectsChecks, - ...bibliogramTorRedirectsChecks, - ...bibliogramNormalCustomRedirects, - ...bibliogramTorCustomRedirects, - ...bibliogramI2pCustomRedirects, - ...bibliogramLokiCustomRedirects, - ] -} - -function redirect(url, type, initiator, disableOverride) { - if (disableInstagram && !disableOverride) return - if (!targets.includes(url.host)) return - if (initiator && all().includes(initiator.origin)) return "BYPASSTAB" - if (!["main_frame", "sub_frame", "xmlhttprequest", "other", "image", "media"].includes(type)) return - - 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 (protocol == "loki") instancesList = [...bibliogramLokiCustomRedirects] - else if (protocol == "i2p") instancesList = [...bibliogramI2pCustomRedirects] - else 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"] - if (url.pathname === "/" || reservedPaths.includes(url.pathname.split("/")[1])) return `${randomInstance}${url.pathname}${url.search}` - if (url.pathname.startsWith("/reel") || url.pathname.startsWith("/tv")) return `${randomInstance}/p${url.pathname.replace(/\/reel|\/tv/i, "")}${url.search}` - else return `${randomInstance}/u${url.pathname}${url.search}` // Likely a user profile, redirect to '/u/...' -} - -function reverse(url) { - return new Promise(async resolve => { - await init() - const protocolHost = utils.protocolHost(url) - if (!all().includes(protocolHost)) { - resolve() - return - } - - if (url.pathname.startsWith("/p")) resolve(`https://instagram.com${url.pathname.replace("/p", "")}${url.search}`) - if (url.pathname.startsWith("/u")) resolve(`https://instagram.com${url.pathname.replace("/u", "")}${url.search}`) - resolve(`https://instagram.com${url.pathname}${url.search}`) - }) -} - -function switchInstance(url, disableOverride) { - return new Promise(async resolve => { - await init() - if (disableInstagram && !disableOverride) { - resolve() - return - } - let protocolHost = utils.protocolHost(url) - if (!all().includes(protocolHost)) { - resolve() - return - } - - let instancesList = [] - if (protocol == "loki") instancesList = [...bibliogramLokiCustomRedirects] - else if (protocol == "i2p") instancesList = [...bibliogramI2pCustomRedirects] - else 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) - if (instancesList.length === 0) { - resolve() - return - } - - const randomInstance = utils.getRandomInstance(instancesList) - resolve(`${randomInstance}${url.pathname}${url.search}`) - }) -} - -function initDefaults() { - return new Promise(resolve => { - fetch("/instances/data.json") - .then(response => response.text()) - .then(data => { - let dataJson = JSON.parse(data) - for (let i = 0; i < frontends.length; i++) { - redirects[frontends[i]] = dataJson[frontends[i]] - } - 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, - bibliogramNormalCustomRedirects: [], - - bibliogramTorRedirectsChecks: [...redirects.bibliogram.tor], - bibliogramTorCustomRedirects: [], - - bibliogramI2pRedirectsChecks: [...redirects.bibliogram.i2p], - bibliogramI2pCustomRedirects: [], - - bibliogramLokiRedirectsChecks: [...redirects.bibliogram.loki], - bibliogramLokiCustomRedirects: [], - }) - resolve() - }) - }) - }) -} - -export default { - setRedirects, - initBibliogramPreferences, - reverse, - redirect, - initDefaults, - switchInstance, -} diff --git a/src/assets/javascripts/lbry.js b/src/assets/javascripts/lbry.js deleted file mode 100644 index 5e285ada..00000000 --- a/src/assets/javascripts/lbry.js +++ /dev/null @@ -1,218 +0,0 @@ -window.browser = window.browser || window.chrome - -import utils from "./utils.js" - -const targets = [/^https?:\/{2}odysee\.com/] - -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) { - browser.storage.local.get(["cloudflareBlackList", "offlineBlackList"], r => { - redirects.librarian = val - 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({ - lbryTargetsRedirects: redirects, - librarianNormalRedirectsChecks, - librarianTorRedirectsChecks: [...redirects.librarian.tor], - librarianI2pRedirectsChecks: [...redirects.librarian.i2p], - librarianLokiRedirectsChecks: [...redirects.librarian.loki], - }) - }) -} - -let disableLbryTargets, - lbryFrontend, - protocol, - protocolFallback, - lbryTargetsRedirects, - lbryRedirectType, - librarianNormalRedirectsChecks, - librarianNormalCustomRedirects, - librarianTorRedirectsChecks, - librarianTorCustomRedirects, - librarianI2pRedirectsChecks, - librarianI2pCustomRedirects, - librarianLokiCustomRedirects - -function init() { - return new Promise(resolve => { - browser.storage.local.get( - [ - "disableLbryTargets", - "lbryFrontend", - "protocol", - "protocolFallback", - "lbryTargetsRedirects", - "lbryRedirectType", - "librarianNormalRedirectsChecks", - "librarianNormalCustomRedirects", - "librarianTorRedirectsChecks", - "librarianTorCustomRedirects", - "librarianI2pRedirectsChecks", - "librarianI2pCustomRedirects", - "librarianLokiCustomRedirects", - ], - r => { - disableLbryTargets = r.disableLbryTargets - lbryFrontend = r.lbryFrontend - protocol = r.protocol - protocolFallback = r.protocolFallback - lbryTargetsRedirects = r.lbryTargetsRedirects - lbryRedirectType = r.lbryRedirectType - librarianNormalRedirectsChecks = r.librarianNormalRedirectsChecks - librarianNormalCustomRedirects = r.librarianNormalCustomRedirects - librarianTorRedirectsChecks = r.librarianTorRedirectsChecks - librarianTorCustomRedirects = r.librarianTorCustomRedirects - librarianI2pRedirectsChecks = r.librarianI2pRedirectsChecks - librarianI2pCustomRedirects = r.librarianI2pCustomRedirects - librarianLokiCustomRedirects = r.librarianLokiCustomRedirects - resolve() - } - ) - }) -} -init() -browser.storage.onChanged.addListener(init) - -function all() { - return [...redirects.librarian.normal, ...redirects.librarian.tor, ...librarianNormalCustomRedirects, ...librarianTorCustomRedirects, ...librarianI2pCustomRedirects, ...librarianLokiCustomRedirects] -} - -function getInstancesList() { - let tmpList = [] - switch (protocol) { - case "loki": - tmpList = [...librarianLokiCustomRedirects] - break - case "i2p": - tmpList = [...librarianI2pRedirectsChecks, ...librarianI2pCustomRedirects] - break - case "tor": - tmpList = [...librarianTorRedirectsChecks, ...librarianTorCustomRedirects] - } - if ((tmpList.length === 0 && protocolFallback) || protocol == "normal") { - tmpList = [...librarianNormalRedirectsChecks, ...librarianNormalCustomRedirects] - } - return tmpList -} - -function switchInstance(url, disableOverride) { - return new Promise(async resolve => { - await init() - if (disableLbryTargets && !disableOverride) { - resolve() - return - } - const protocolHost = utils.protocolHost(url) - if (!all().includes(protocolHost)) { - resolve() - return - } - - let instancesList = [] - if (protocol == "loki") instancesList = [...librarianLokiCustomRedirects] - else if (protocol == "i2p") instancesList = [...librarianI2pCustomRedirects] - else 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) - if (instancesList.length === 0) { - resolve() - return - } - - const randomInstance = utils.getRandomInstance(instancesList) - resolve(`${randomInstance}${url.pathname}${url.search}`) - }) -} - -function redirect(url, type, initiator, disableOverride) { - if (disableLbryTargets && !disableOverride) return - if (initiator && (all().includes(initiator.origin) || targets.includes(initiator.host))) return - if (!targets.some(rx => rx.test(url.href))) return - if ((type == "main_frame" && lbryRedirectType == "sub_frame") || (type == "sub_frame" && lbryRedirectType == "main_frame")) return - - const instancesList = getInstancesList() - switch (type) { - case "main_frame": - switch (lbryFrontend) { - case "librarian": - if (instancesList.length === 0) return - const randomInstance = utils.getRandomInstance(instancesList) - return `${randomInstance}${url.pathname}${url.search}` - case "lbryDesktop": - if (type == "main_frame") { - return url.href.replace(/^https?:\/{2}odysee\.com\//, "lbry://").replace(/:(?=[a-zA-Z0-9])/g, "#") - } - } - case "sub_frame": - if (instancesList.length === 0) return - const randomInstance = utils.getRandomInstance(instancesList) - return `${randomInstance}${url.pathname}${url.search}`.replace(/\/(?=[a-f0-9]{40})/, ":") - } -} - -function initDefaults() { - 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.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, - lbryFrontend: "librarian", - lbryTargetsRedirects: redirects, - lbryRedirectType: "both", - - librarianNormalRedirectsChecks, - librarianNormalCustomRedirects: [], - - librarianTorRedirectsChecks: [...redirects.librarian.tor], - librarianTorCustomRedirects: [], - - librarianI2pRedirectsChecks: [...redirects.librarian.i2p], - librarianI2pCustomRedirects: [], - - librarianLokiRedirectsChecks: [...redirects.librarian.loki], - librarianLokiCustomRedirects: [], - }, - () => resolve() - ) - }) - }) - }) -} - -export default { - setRedirects, - switchInstance, - redirect, - initDefaults, -} diff --git a/src/assets/javascripts/maps.js b/src/assets/javascripts/maps.js deleted file mode 100644 index 6e3c9af0..00000000 --- a/src/assets/javascripts/maps.js +++ /dev/null @@ -1,304 +0,0 @@ -"use strict" - -window.browser = window.browser || window.chrome -import utils from "./utils.js" - -const targets = /^https?:\/{2}(((www|maps)\.)?(google\.).*(\/maps)|maps\.(google\.).*)/ - -const frontends = new Array("facil") -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]] = [] - } -} - -redirects.osm = {} -redirects.osm.normal = ["https://www.openstreetmap.org"] - -function setRedirects(val) { - browser.storage.local.get(["cloudflareBlackList", "offlineBlackList"], r => { - redirects.facil = val - 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({ - mapsRedirects: redirects, - facilNormalRedirectsChecks, - facilTorRedirectsChecks: [...redirects.facil.tor], - facilI2pRedirectsChecks: [...redirects.facil.i2p], - facilLokiRedirectsChecks: [...redirects.facil.loki], - }) - }) -} - -let disableMaps, - mapsFrontend, - protocol, - protocolFallback, - facilNormalRedirectsChecks, - facilNormalCustomRedirects, - facilTorRedirectsChecks, - facilTorCustomRedirects, - facilI2pRedirectsChecks, - facilI2pCustomRedirects, - facilLokiRedirectsChecks, - facilLokiCustomRedirects - -function init() { - browser.storage.local.get( - [ - "disableMaps", - "mapsFrontend", - "protocol", - "protocolFallback", - "facilNormalRedirectsChecks", - "facilNormalCustomRedirects", - "facilTorRedirectsChecks", - "facilTorCustomRedirects", - "facilI2pRedirectsChecks", - "facilI2pCustomRedirects", - "facilLokiRedirectsChecks", - "facilLokiCustomRedirects", - ], - r => { - disableMaps = r.disableMaps - mapsFrontend = r.mapsFrontend - protocol = r.protocol - protocolFallback = r.protocolFallback - facilNormalRedirectsChecks = r.facilNormalRedirectsChecks - facilNormalCustomRedirects = r.facilNormalCustomRedirects - facilTorRedirectsChecks = r.facilTorRedirectsChecks - facilTorCustomRedirects = r.facilTorCustomRedirects - facilI2pRedirectsChecks = r.facilI2pRedirectsChecks - facilI2pCustomRedirects = r.facilI2pCustomRedirects - facilLokiRedirectsChecks = r.facilLokiRedirectsChecks - facilLokiCustomRedirects = r.facilLokiCustomRedirects - } - ) -} - -init() -browser.storage.onChanged.addListener(init) - -function redirect(url, initiator) { - if (disableMaps) return - if (initiator && initiator.host === "earth.google.com") return - if (!url.href.match(targets)) return - const mapCentreRegex = /@(-?\d[0-9.]*),(-?\d[0-9.]*),(\d{1,2})[.z]/ - const dataLatLngRegex = /!3d(-?[0-9]{1,}.[0-9]{1,})!4d(-?[0-9]{1,}.[0-9]{1,})/ - const placeRegex = /\/place\/(.*)\// - const travelModes = { - driving: "fossgis_osrm_car", - walking: "fossgis_osrm_foot", - bicycling: "fossgis_osrm_bike", - transit: "fossgis_osrm_car", // not implemented on OSM, default to car. - } - const travelModesFacil = { - driving: "car", - walking: "pedestrian", - bicycling: "bicycle", - transit: "car", // not implemented on Facil, default to car. - } - const osmLayers = { - none: "S", - transit: "T", - traffic: "S", // not implemented on OSM, default to standard. - bicycling: "C", - } - function addressToLatLng(address) { - const xmlhttp = new XMLHttpRequest() - xmlhttp.open("GET", `https://nominatim.openstreetmap.org/search/${address}?format=json&limit=1`, false) - xmlhttp.send() - if (xmlhttp.status === 200) { - const json = JSON.parse(xmlhttp.responseText)[0] - if (json) { - console.log("json", json) - return [`${json.lat},${json.lon}`, `${json.boundingbox[2]},${json.boundingbox[1]},${json.boundingbox[3]},${json.boundingbox[0]}`] - } - } - console.info("Error: Status is " + xmlhttp.status) - } - - let instancesList - switch (mapsFrontend) { - case "osm": - instancesList = [...redirects.osm.normal] - break - case "facil": - switch (protocol) { - case "loki": - instancesList = [...facilLokiRedirectsChecks, ...facilLokiCustomRedirects] - break - case "i2p": - instancesList = [...facilI2pRedirectsChecks, ...facilI2pCustomRedirects] - break - case "tor": - instancesList = [...facilTorRedirectsChecks, ...facilTorCustomRedirects] - } - if ((instancesList == "" && protocolFallback) || protocol == "normal") { - instancesList = [...facilNormalRedirectsChecks, ...facilNormalCustomRedirects] - } - } - const randomInstance = utils.getRandomInstance(instancesList) - - let mapCentre = "#" - let prefs = {} - - if (url.pathname.match(mapCentreRegex)) { - // Set map centre if present - var [, lat, lon, zoom] = url.pathname.match(mapCentreRegex) - } else if (url.searchParams.has("center")) { - var [lat, lon] = url.searchParams.get("center").split(",") - var zoom = url.searchParams.get("zoom") ?? "17" - } - - if (lat && lon && zoom) { - if (mapsFrontend == "osm") mapCentre = `#map=${zoom}/${lat}/${lon}` - if (mapsFrontend == "facil") mapCentre = `#${zoom}/${lat}/${lon}` - } - - if (url.searchParams.get("layer")) prefs.layers = osmLayers[url.searchParams.get("layer")] - - if (url.pathname.includes("/embed")) { - // Handle Google Maps Embed API - // https://www.google.com/maps/embed/v1/place?key=AIzaSyD4iE2xVSpkLLOXoyqT-RuPwURN3ddScAI&q=Eiffel+Tower,Paris+France - console.log("embed life") - - let query = "" - if (url.searchParams.has("q")) query = url.searchParams.get("q") - else if (url.searchParams.has("query")) query = url.searchParams.has("query") - else if (url.searchParams.has("pb")) - try { - query = url.searchParams.get("pb").split(/!2s(.*?)!/)[1] - } catch (error) { - console.error(error) - } // Unable to find map marker in URL. - - let [coords, boundingbox] = addressToLatLng(query) - prefs.bbox = boundingbox - prefs.marker = coords - prefs.layer = "mapnik" - let prefsEncoded = new URLSearchParams(prefs).toString() - if (mapsFrontend == "osm") return `${randomInstance}/export/embed.html?${prefsEncoded}` - if (mapsFrontend == "facil") return `${randomInstance}/#q=${query}` - } else if (url.pathname.includes("/dir")) { - // Handle Google Maps Directions - // https://www.google.com/maps/dir/?api=1&origin=Space+Needle+Seattle+WA&destination=Pike+Place+Market+Seattle+WA&travelmode=bicycling - - let travMod = url.searchParams.get("travelmode") - if (url.searchParams.has("travelmode")) prefs.engine = travelModes[travMod] - - let orgVal = url.searchParams.get("origin") - let destVal = url.searchParams.get("destination") - - let org - addressToLatLng(orgVal, a => (org = a)) - let dest - addressToLatLng(destVal, a => (dest = a)) - prefs.route = `${org};${dest}` - - let prefsEncoded = new URLSearchParams(prefs).toString() - if (mapsFrontend == "osm") return `${randomInstance}/directions?${prefsEncoded}${mapCentre}` - if (mapsFrontend == "facil") return `${randomInstance}/#q=${orgVal}%20to%20${destVal}%20by%20${travelModesFacil[travMod]}` - } else if (url.pathname.includes("data=") && url.pathname.match(dataLatLngRegex)) { - // Get marker from data attribute - // https://www.google.com/maps/place/41%C2%B001'58.2%22N+40%C2%B029'18.2%22E/@41.032833,40.4862063,17z/data=!3m1!4b1!4m6!3m5!1s0x0:0xf64286eaf72fc49d!7e2!8m2!3d41.0328329!4d40.4883948 - console.log("data life") - - let [, mlat, mlon] = url.pathname.match(dataLatLngRegex) - - if (mapsFrontend == "osm") return `${randomInstance}/search?query=${mlat}%2C${mlon}` - if (mapsFrontend == "facil") return `${randomInstance}/#q=${mlat}%2C${mlon}` - } else if (url.searchParams.has("ll")) { - // Get marker from ll param - // https://maps.google.com/?ll=38.882147,-76.99017 - console.log("ll life") - - const [mlat, mlon] = url.searchParams.get("ll").split(",") - - if (mapsFrontend == "osm") return `${randomInstance}/search?query=${mlat}%2C${mlon}` - if (mapsFrontend == "facil") return `${randomInstance}/#q=${mlat}%2C${mlon}` - } else if (url.searchParams.has("viewpoint")) { - // Get marker from viewpoint param. - // https://www.google.com/maps/@?api=1&map_action=pano&viewpoint=48.857832,2.295226&heading=-45&pitch=38&fov=80 - console.log("viewpoint life") - - const [mlat, mlon] = url.searchParams.get("viewpoint").split(",") - - if (mapsFrontend == "osm") return `${randomInstance}/search?query=${mlat}%2C${mlon}` - if (mapsFrontend == "facil") return `${randomInstance}/#q=${mlat}%2C${mlon}` - } else { - // Use query as search if present. - console.log("normal life") - - let query - if (url.searchParams.has("q")) query = url.searchParams.get("q") - else if (url.searchParams.has("query")) query = url.searchParams.get("query") - else if (url.pathname.match(placeRegex)) query = url.pathname.match(placeRegex)[1] - - let prefsEncoded = new URLSearchParams(prefs).toString() - if (query) { - if (mapsFrontend == "osm") return `${randomInstance}/search?query="${query}${mapCentre}&${prefsEncoded}` - if (mapsFrontend == "facil") return `${randomInstance}/${mapCentre}/Mpnk/${query}` - } - } - - let prefsEncoded = new URLSearchParams(prefs).toString() - console.log("mapCentre", mapCentre) - console.log("prefs", prefs) - console.log("prefsEncoded", prefsEncoded) - if (mapsFrontend == "osm") return `${randomInstance}/${mapCentre}&${prefsEncoded}` - if (mapsFrontend == "facil") return `${randomInstance}/${mapCentre}/Mpnk` -} - -function initDefaults() { - 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.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, - facilNormalCustomRedirects: [], - - facilTorRedirectsChecks: [...redirects.facil.tor], - facilTorCustomRedirects: [], - - facilI2pRedirectsChecks: [...redirects.facil.i2p], - facilI2pCustomRedirects: [], - - facilLokiRedirectsChecks: [...redirects.facil.loki], - facilLokiCustomRedirects: [], - }, - () => resolve() - ) - }) - }) - }) -} - -export default { - setRedirects, - redirect, - initDefaults, -} diff --git a/src/assets/javascripts/medium.js b/src/assets/javascripts/medium.js deleted file mode 100644 index e5cb1dc4..00000000 --- a/src/assets/javascripts/medium.js +++ /dev/null @@ -1,222 +0,0 @@ -window.browser = window.browser || window.chrome -import utils from "./utils.js" - -const targets = [ - // /(?:.*\.)*(? { - redirects.scribe = val - 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({ - mediumRedirects: redirects, - scribeNormalRedirectsChecks, - scribeTorRedirectsChecks: [...redirects.scribe.tor], - scribeI2pRedirectsChecks: [...redirects.scribe.i2p], - scribeLokiRedirectsChecks: [...redirects.scribe.loki], - }) - }) -} - -let disableMedium, - mediumRedirects, - scribeNormalRedirectsChecks, - scribeNormalCustomRedirects, - scribeTorRedirectsChecks, - scribeTorCustomRedirects, - scribeI2pCustomRedirects, - scribeLokiCustomRedirects, - protocol, - protocolFallback - -function init() { - return new Promise(resolve => { - browser.storage.local.get( - [ - "disableMedium", - "mediumRedirects", - "scribeNormalRedirectsChecks", - "scribeNormalCustomRedirects", - "scribeTorRedirectsChecks", - "scribeTorCustomRedirects", - "scribeI2pCustomRedirects", - "scribeLokiCustomRedirects", - "protocol", - "protocolFallback", - ], - r => { - disableMedium = r.disableMedium - mediumRedirects = r.mediumRedirects - scribeNormalRedirectsChecks = r.scribeNormalRedirectsChecks - scribeNormalCustomRedirects = r.scribeNormalCustomRedirects - scribeTorRedirectsChecks = r.scribeTorRedirectsChecks - scribeTorCustomRedirects = r.scribeTorCustomRedirects - scribeI2pCustomRedirects = r.scribeI2pCustomRedirects - scribeLokiCustomRedirects = r.scribeLokiCustomRedirects - protocol = r.protocol - protocolFallback = r.protocolFallback - resolve() - } - ) - }) -} - -init() -browser.storage.onChanged.addListener(init) - -function redirect(url, type, initiator, disableOverride) { - if (disableMedium && !disableOverride) return - if (url.pathname == "/" && !disableOverride) return - if (type != "main_frame" && "sub_frame" && "xmlhttprequest" && "other") return - if ( - initiator && - [...mediumRedirects.scribe.normal, ...mediumRedirects.scribe.tor, ...scribeNormalCustomRedirects, ...scribeTorCustomRedirects, ...scribeI2pCustomRedirects, ...scribeLokiCustomRedirects].includes( - initiator.origin - ) - ) - return - - if (!targets.some(rx => rx.test(url.host))) return - if (/^\/(@[a-zA-Z.]{0,}(\/|)$)/.test(url.pathname)) return - - let instancesList = [] - if (protocol == "loki") instancesList = [...scribeLokiCustomRedirects] - else if (protocol == "i2p") instancesList = [...scribeI2pCustomRedirects] - else 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}` -} - -function switchInstance(url, disableOverride) { - return new Promise(async resolve => { - await init() - if (disableMedium && !disableOverride) { - resolve() - return - } - let protocolHost = utils.protocolHost(url) - const all = [ - ...mediumRedirects.scribe.tor, - ...mediumRedirects.scribe.normal, - - ...scribeNormalCustomRedirects, - ...scribeTorCustomRedirects, - ...scribeI2pCustomRedirects, - ...scribeLokiCustomRedirects, - ] - if (!all.includes(protocolHost)) { - resolve() - return - } - - let instancesList = [] - if (protocol == "loki") instancesList = [...scribeLokiCustomRedirects] - else if (protocol == "i2p") instancesList = [...scribeI2pCustomRedirects] - else 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) - if (instancesList.length === 0) { - resolve() - return - } - - const randomInstance = utils.getRandomInstance(instancesList) - resolve(`${randomInstance}${url.pathname}${url.search}`) - }) -} - -function initDefaults() { - return new Promise(resolve => { - fetch("/instances/data.json") - .then(response => response.text()) - .then(data => { - let dataJson = JSON.parse(data) - for (let i = 0; i < frontends.length; i++) { - redirects[frontends[i]] = dataJson[frontends[i]] - } - 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, - scribeNormalCustomRedirects: [], - - scribeTorRedirectsChecks: [...redirects.scribe.tor], - scribeTorCustomRedirects: [], - - scribeI2pRedirectsChecks: [...redirects.scribe.i2p], - scribeI2pCustomRedirects: [], - - scribeLokiRedirectsChecks: [...redirects.scribe.loki], - scribeLokiCustomRedirects: [], - }, - () => resolve() - ) - }) - }) - }) -} - -export default { - setRedirects, - redirect, - switchInstance, - initDefaults, -} diff --git a/src/assets/javascripts/peertube.js b/src/assets/javascripts/peertube.js deleted file mode 100644 index 478a18f0..00000000 --- a/src/assets/javascripts/peertube.js +++ /dev/null @@ -1,204 +0,0 @@ -window.browser = window.browser || window.chrome - -import utils from "./utils.js" - -const frontends = new Array("simpleertube") -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", "offlineBlackList"], r => { - redirects.simpleertube = val - 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({ - peertubeRedirects: redirects, - simpleertubeNormalRedirectsChecks, - simpleertubeTorRedirectsChecks: [...redirects.simpleertube.tor], - simpleertubeI2pRedirectsChecks: [...redirects.simpleertube.i2p], - simpleertubeLokiRedirectsChecks: [...redirects.simpleertube.loki], - }) - }) -} - -let disablePeertubeTargets, - peertubeRedirects, - simpleertubeNormalRedirectsChecks, - simpleertubeNormalCustomRedirects, - simpleertubeTorRedirectsChecks, - simpleertubeTorCustomRedirects, - simpleertubeI2pRedirectsChecks, - simpleertubeI2pCustomRedirects, - simpleertubeLokiRedirectsChecks, - simpleertubeLokiCustomRedirects, - peerTubeTargets, - protocol, - protocolFallback - -function init() { - return new Promise(resolve => { - browser.storage.local.get( - [ - "disablePeertubeTargets", - "peertubeRedirects", - "simpleertubeNormalRedirectsChecks", - "simpleertubeNormalCustomRedirects", - "simpleertubeTorRedirectsChecks", - "simpleertubeTorCustomRedirects", - "simpleertubeI2pRedirectsChecks", - "simpleertubeI2pCustomRedirects", - "simpleertubeLokiRedirectsChecks", - "simpleertubeLokiCustomRedirects", - "peerTubeTargets", - "protocol", - "protocolFallback", - ], - r => { - disablePeertubeTargets = r.disablePeertubeTargets - peertubeRedirects = r.peertubeRedirects - simpleertubeNormalRedirectsChecks = r.simpleertubeNormalRedirectsChecks - simpleertubeNormalCustomRedirects = r.simpleertubeNormalCustomRedirects - simpleertubeTorRedirectsChecks = r.simpleertubeTorRedirectsChecks - simpleertubeTorCustomRedirects = r.simpleertubeTorCustomRedirects - simpleertubeI2pRedirectsChecks = r.simpleertubeI2pRedirectsChecks - simpleertubeI2pCustomRedirects = r.simpleertubeI2pCustomRedirects - simpleertubeLokiRedirectsChecks = r.simpleertubeLokiRedirectsChecks - simpleertubeLokiCustomRedirects = r.simpleertubeLokiCustomRedirects - peerTubeTargets = r.peerTubeTargets - protocol = r.protocol - protocolFallback = r.protocolFallback - resolve() - } - ) - }) -} - -init() -browser.storage.onChanged.addListener(init) - -function all() { - return [ - ...simpleertubeNormalRedirectsChecks, - ...simpleertubeTorRedirectsChecks, - ...simpleertubeI2pRedirectsChecks, - ...simpleertubeLokiRedirectsChecks, - ...simpleertubeNormalCustomRedirects, - ...simpleertubeTorCustomRedirects, - ...simpleertubeI2pCustomRedirects, - ...simpleertubeLokiCustomRedirects, - ] -} - -function redirect(url, type, initiator, disableOverride) { - if (disablePeertubeTargets && !disableOverride) return - if (initiator && (all().includes(initiator.origin) || peerTubeTargets.includes(initiator.host))) return - let protocolHost = utils.protocolHost(url) - if (!peerTubeTargets.includes(protocolHost)) return - if (type != "main_frame") return - - let instancesList = [] - if (protocol == "loki") instancesList = [...simpleertubeLokiRedirectsChecks, ...simpleertubeLokiCustomRedirects] - else if (protocol == "i2p") instancesList = [...simpleertubeI2pRedirectsChecks, ...simpleertubeI2pCustomRedirects] - else 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 - return `${randomInstance}/${url.host}${url.pathname}${url.search}` -} - -function switchInstance(url, disableOverride) { - return new Promise(async resolve => { - await init() - if (disablePeertubeTargets && !disableOverride) { - resolve() - return - } - const protocolHost = utils.protocolHost(url) - if (!all().includes(protocolHost)) { - resolve() - return - } - - let instancesList = [] - if (protocol == "loki") instancesList = [...simpleertubeLokiRedirectsChecks, ...simpleertubeLokiCustomRedirects] - else if (protocol == "i2p") instancesList = [...simpleertubeI2pRedirectsChecks, ...simpleertubeI2pCustomRedirects] - else 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) - if (instancesList.length === 0) { - resolve() - return - } - - const randomInstance = utils.getRandomInstance(instancesList) - resolve(`${randomInstance}${url.pathname}${url.search}`) - }) -} - -function initDefaults() { - return new Promise(resolve => { - fetch("/instances/data.json") - .then(response => response.text()) - .then(data => { - let dataJson = JSON.parse(data) - for (let i = 0; i < frontends.length; i++) { - redirects[frontends[i]] = dataJson[frontends[i]] - } - 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, - simpleertubeNormalCustomRedirects: [], - - simpleertubeTorRedirectsChecks: [...redirects.simpleertube.tor], - simpleertubeTorCustomRedirects: [], - - simpleertubeI2pRedirectsChecks: [...redirects.simpleertube.i2p], - simpleertubeI2pCustomRedirects: [], - - simpleertubeLokiRedirectsChecks: [...redirects.simpleertube.loki], - simpleertubeLokiCustomRedirects: [], - }, - () => resolve() - ) - }) - }) - }) -} - -export default { - setRedirects, - switchInstance, - redirect, - initDefaults, -} diff --git a/src/assets/javascripts/quora.js b/src/assets/javascripts/quora.js deleted file mode 100644 index 578cfe76..00000000 --- a/src/assets/javascripts/quora.js +++ /dev/null @@ -1,202 +0,0 @@ -window.browser = window.browser || window.chrome - -import utils from "./utils.js" - -const targets = [/^https?:\/{2}(www\.|)quora\.com.*/] - -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", "offlineBlackList"], r => { - redirects.quetre = val - 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({ - quoraRedirects: redirects, - quetreNormalRedirectsChecks, - quetreTorRedirectsChecks: [...redirects.quetre.tor], - quetreI2pRedirectsChecks: [...redirects.quetre.i2p], - quetreLokiRedirectsChecks: [...redirects.quetre.loki], - }) - }) -} - -let disableQuora, - protocol, - protocolFallback, - quoraRedirects, - quetreNormalRedirectsChecks, - quetreNormalCustomRedirects, - quetreTorRedirectsChecks, - quetreTorCustomRedirects, - quetreI2pCustomRedirects, - quetreLokiCustomRedirects - -function init() { - return new Promise(async resolve => { - browser.storage.local.get( - [ - "disableQuora", - "protocol", - "protocolFallback", - "quoraRedirects", - "quetreNormalRedirectsChecks", - "quetreNormalCustomRedirects", - "quetreTorRedirectsChecks", - "quetreTorCustomRedirects", - "quetreI2pCustomRedirects", - "quetreLokiCustomRedirects", - ], - r => { - disableQuora = r.disableQuora - protocol = r.protocol - protocolFallback = r.protocolFallback - quoraRedirects = r.quoraRedirects - quetreNormalRedirectsChecks = r.quetreNormalRedirectsChecks - quetreNormalCustomRedirects = r.quetreNormalCustomRedirects - quetreTorRedirectsChecks = r.quetreTorRedirectsChecks - quetreTorCustomRedirects = r.quetreTorCustomRedirects - quetreI2pCustomRedirects = r.quetreI2pCustomRedirects - quetreLokiCustomRedirects = r.quetreLokiCustomRedirects - resolve() - } - ) - }) -} - -init() -browser.storage.onChanged.addListener(init) - -function redirect(url, type, initiator, disableOverride) { - if (disableQuora && !disableOverride) return - if (url.pathname == "/" && !disableOverride) return - if (type != "main_frame") return - const all = [...quoraRedirects.quetre.normal, ...quetreNormalCustomRedirects] - if (initiator && (all.includes(initiator.origin) || targets.includes(initiator.host))) return - if (!targets.some(rx => rx.test(url.href))) return - - let instancesList = [] - if (protocol == "loki") instancesList = [...quetreLokiCustomRedirects] - else if (protocol == "i2p") instancesList = [...quetreI2pCustomRedirects] - else 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}` -} - -function reverse(url) { - return new Promise(async resolve => { - await init() - let protocolHost = utils.protocolHost(url) - const all = [...quoraRedirects.quetre.normal, ...quoraRedirects.quetre.tor, ...quetreNormalCustomRedirects, ...quetreTorCustomRedirects, ...quetreI2pCustomRedirects, ...quetreLokiCustomRedirects] - if (!all.includes(protocolHost)) { - resolve() - return - } - - resolve(`https://quora.com${url.pathname}${url.search}`) - }) -} - -function switchInstance(url, disableOverride) { - return new Promise(async resolve => { - await init() - if (disableQuora && !disableOverride) { - resolve() - return - } - let protocolHost = utils.protocolHost(url) - const all = [...quoraRedirects.quetre.tor, ...quoraRedirects.quetre.normal, ...quetreNormalCustomRedirects, ...quetreTorCustomRedirects, ...quetreI2pCustomRedirects, ...quetreLokiCustomRedirects] - if (!all.includes(protocolHost)) { - resolve() - return - } - - let instancesList = [] - if (protocol == "loki") instancesList = [...quetreLokiCustomRedirects] - else if (protocol == "i2p") instancesList = [...quetreI2pCustomRedirects] - else 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) - if (instancesList.length === 0) { - resolve() - return - } - - const randomInstance = utils.getRandomInstance(instancesList) - resolve(`${randomInstance}${url.pathname}${url.search}`) - }) -} - -function initDefaults() { - 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.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, - quetreNormalCustomRedirects: [], - - quetreTorRedirectsChecks: [...redirects.quetre.tor], - quetreTorCustomRedirects: [], - - quetreI2pRedirectsChecks: [...redirects.quetre.i2p], - quetreI2pCustomRedirects: [], - - quetreLokiRedirectsChecks: [...redirects.quetre.loki], - quetreLokiCustomRedirects: [], - }, - () => resolve() - ) - }) - }) - }) -} - -export default { - setRedirects, - - redirect, - reverse, - switchInstance, - - initDefaults, -} diff --git a/src/assets/javascripts/reddit.js b/src/assets/javascripts/reddit.js deleted file mode 100644 index ca1993b5..00000000 --- a/src/assets/javascripts/reddit.js +++ /dev/null @@ -1,394 +0,0 @@ -window.browser = window.browser || window.chrome - -import utils from "./utils.js" - -const targets = [/^https?:\/{2}(www\.|old\.|np\.|new\.|amp\.|)reddit\.com/, /^https?:\/{2}(i\.|preview\.)redd\.it/] -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", "offlineBlackList"], r => { - redirects = val - 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({ - redditRedirects: redirects, - libredditNormalRedirectsChecks, - libredditTorRedirectsChecks: [...redirects.libreddit.tor], - libredditI2pRedirectsChecks: [...redirects.libreddit.i2p], - libredditLokiRedirectsChecks: [...redirects.libreddit.loki], - tedditNormalRedirectsChecks, - tedditTorRedirectsChecks: [...redirects.teddit.tor], - tedditI2pRedirectsChecks: [...redirects.teddit.i2p], - tedditLokiRedirectsChecks: [...redirects.teddit.loki], - }) - }) -} - -let disableReddit, - redditFrontend, - redditRedirects, - protocol, - protocolFallback, - libredditNormalRedirectsChecks, - libredditNormalCustomRedirects, - libredditTorRedirectsChecks, - libredditTorCustomRedirects, - libredditI2pCustomRedirects, - libredditLokiCustomRedirects, - tedditNormalRedirectsChecks, - tedditNormalCustomRedirects, - tedditTorRedirectsChecks, - tedditTorCustomRedirects, - tedditI2pCustomRedirects, - tedditLokiCustomRedirects - -function init() { - return new Promise(resolve => { - browser.storage.local.get( - [ - "disableReddit", - "redditFrontend", - "redditRedirects", - "protocol", - "protocolFallback", - "libredditNormalRedirectsChecks", - "libredditNormalCustomRedirects", - "libredditTorRedirectsChecks", - "libredditTorCustomRedirects", - "libredditI2pCustomRedirects", - "libredditLokiCustomRedirects", - "tedditNormalRedirectsChecks", - "tedditNormalCustomRedirects", - "tedditTorRedirectsChecks", - "tedditTorCustomRedirects", - "tedditI2pCustomRedirects", - "tedditLokiCustomRedirects", - ], - r => { - disableReddit = r.disableReddit - redditFrontend = r.redditFrontend - redditRedirects = r.redditRedirects - protocol = r.protocol - protocolFallback = r.protocolFallback - libredditNormalRedirectsChecks = r.libredditNormalRedirectsChecks - libredditNormalCustomRedirects = r.libredditNormalCustomRedirects - libredditTorRedirectsChecks = r.libredditTorRedirectsChecks - libredditTorCustomRedirects = r.libredditTorCustomRedirects - libredditI2pCustomRedirects = r.libredditI2pCustomRedirects - libredditLokiCustomRedirects = r.libredditLokiCustomRedirects - tedditNormalRedirectsChecks = r.tedditNormalRedirectsChecks - tedditNormalCustomRedirects = r.tedditNormalCustomRedirects - tedditTorRedirectsChecks = r.tedditTorRedirectsChecks - tedditTorCustomRedirects = r.tedditTorCustomRedirects - tedditI2pCustomRedirects = r.tedditI2pCustomRedirects - tedditLokiCustomRedirects = r.tedditLokiCustomRedirects - resolve() - } - ) - }) -} - -init() -browser.storage.onChanged.addListener(init) - -function initLibredditCookies(test, from) { - return new Promise(async resolve => { - await init() - const protocolHost = utils.protocolHost(from) - if ( - ![ - ...libredditNormalRedirectsChecks, - ...libredditTorRedirectsChecks, - ...libredditNormalCustomRedirects, - ...libredditTorCustomRedirects, - ...libredditI2pCustomRedirects, - ...libredditLokiCustomRedirects, - ].includes(protocolHost) - ) { - resolve() - return - } - - if (!test) { - let checkedInstances = [] - if (protocol == "loki") checkedInstances = [...libredditLokiCustomRedirects] - else if (protocol == "i2p") checkedInstances = [...libredditI2pCustomRedirects] - else if (protocol == "tor") checkedInstances = [...libredditTorRedirectsChecks, ...libredditTorCustomRedirects] - if ((checkedInstances.length === 0 && protocolFallback) || protocol == "normal") { - checkedInstances = [...libredditNormalRedirectsChecks, ...libredditNormalCustomRedirects] - } - await utils.copyCookie("libreddit", from, checkedInstances, "theme") - await utils.copyCookie("libreddit", from, checkedInstances, "front_page") - await utils.copyCookie("libreddit", from, checkedInstances, "layout") - await utils.copyCookie("libreddit", from, checkedInstances, "wide") - await utils.copyCookie("libreddit", from, checkedInstances, "post_sort") - await utils.copyCookie("libreddit", from, checkedInstances, "comment_sort") - await utils.copyCookie("libreddit", from, checkedInstances, "show_nsfw") - await utils.copyCookie("libreddit", from, checkedInstances, "autoplay_videos") - await utils.copyCookie("libreddit", from, checkedInstances, "use_hls") - await utils.copyCookie("libreddit", from, checkedInstances, "hide_hls_notification") - await utils.copyCookie("libreddit", from, checkedInstances, "subscriptions") - await utils.copyCookie("libreddit", from, checkedInstances, "filters") - } - resolve(true) - }) -} - -function initTedditCookies(test, from) { - return new Promise(async resolve => { - await init() - let protocolHost = utils.protocolHost(from) - if ( - ![...tedditNormalRedirectsChecks, ...tedditTorRedirectsChecks, ...tedditNormalCustomRedirects, ...tedditTorCustomRedirects, ...tedditI2pCustomRedirects, ...tedditI2pCustomRedirects].includes( - protocolHost - ) - ) - resolve() - - if (!test) { - let checkedInstances = [] - if (protocol == "loki") checkedInstances = [...tedditLokiCustomRedirects] - else if (protocol == "i2p") checkedInstances = [...tedditI2pCustomRedirects] - else if (protocol == "tor") checkedInstances = [...tedditTorRedirectsChecks, ...tedditTorCustomRedirects] - if ((checkedInstances.length === 0 && protocolFallback) || protocol == "normal") { - checkedInstances = [...tedditNormalRedirectsChecks, ...tedditNormalCustomRedirects] - } - 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") - await utils.copyCookie("teddit", from, checkedInstances, "domain_youtube") - await utils.copyCookie("teddit", from, checkedInstances, "flairs") - await utils.copyCookie("teddit", from, checkedInstances, "highlight_controversial") - await utils.copyCookie("teddit", from, checkedInstances, "nsfw_enabled") - await utils.copyCookie("teddit", from, checkedInstances, "post_media_max_height") - await utils.copyCookie("teddit", from, checkedInstances, "show_upvoted_percentage") - await utils.copyCookie("teddit", from, checkedInstances, "show_upvotes") - await utils.copyCookie("teddit", from, checkedInstances, "theme") - await utils.copyCookie("teddit", from, checkedInstances, "videos_muted") - } - resolve(true) - }) -} - -function all() { - return [ - ...redditRedirects.libreddit.normal, - ...redditRedirects.libreddit.tor, - ...redditRedirects.teddit.normal, - ...redditRedirects.teddit.tor, - ...libredditNormalCustomRedirects, - ...libredditTorCustomRedirects, - ...libredditI2pCustomRedirects, - ...libredditLokiCustomRedirects, - ...tedditNormalCustomRedirects, - ...tedditTorCustomRedirects, - ...tedditI2pCustomRedirects, - ...tedditLokiCustomRedirects, - ] -} - -// https://libreddit.exonip.de/vid/1mq8d0ma3yk81/720.mp4 -// https://libreddit.exonip.de/img/4v3t1vgvrzk81.png - -// https://teddit.net/vids/1mq8d0ma3yk81.mp4 -// https://teddit.net/pics/w:null_4v3t1vgvrzk81.png - -// redd.it/t5379n -// https://v.redd.it/z08avb339n801/DASH_1_2_M -// https://i.redd.it/bfkhs659tzk81.jpg -function redirect(url, type, initiator, disableOverride) { - if (disableReddit && !disableOverride) return - if (!targets.some(rx => rx.test(url.href))) return - if (initiator && all().includes(initiator.origin)) return "BYPASSTAB" - if (!["main_frame", "xmlhttprequest", "other", "image", "media"].includes(type)) return - const bypassPaths = /\/(gallery\/poll\/rpan\/settings\/topics)/ - if (url.pathname.match(bypassPaths)) return - - let libredditInstancesList = [] - let tedditInstancesList = [] - - if (protocol == "loki") { - libredditInstancesList = [...libredditLokiCustomRedirects] - tedditInstancesList = [...tedditLokiCustomRedirects] - } else if (protocol == "i2p") { - libredditInstancesList = [...libredditI2pCustomRedirects] - tedditInstancesList = [...tedditI2pCustomRedirects] - } else 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") { - if (tedditInstancesList.length === 0) return - let tedditRandomInstance = utils.getRandomInstance(tedditInstancesList) - return `${tedditRandomInstance}/pics/w:null_${url.pathname.substring(1)}${url.search}` - } - if (redditFrontend == "libreddit") { - if (libredditInstancesList.length === 0) return - let libredditRandomInstance = utils.getRandomInstance(libredditInstancesList) - return `${libredditRandomInstance}/img${url.pathname}${url.search}` - } - } else if (url.host === "redd.it") { - if (redditFrontend == "libreddit" && !url.pathname.match(/^\/+[^\/]+\/+[^\/]/)) { - if (libredditInstancesList.length === 0) return - let libredditRandomInstance = utils.getRandomInstance(libredditInstancesList) - // https://redd.it/foo => https://libredd.it/comments/foo - return `${libredditRandomInstance}/comments${url.pathname}${url.search}` - } - if (redditFrontend == "teddit" && !url.pathname.match(/^\/+[^\/]+\/+[^\/]/)) { - if (tedditInstancesList.length === 0) return - let tedditRandomInstance = utils.getRandomInstance(tedditInstancesList) - // https://redd.it/foo => https://teddit.net/comments/foo - return `${tedditRandomInstance}/comments${url.pathname}${url.search}` - } - } else if (url.host === "preview.redd.it") { - if (redditFrontend == "teddit") return - if (redditFrontend == "libreddit") { - if (libredditInstancesList.length === 0) return - const libredditRandomInstance = utils.getRandomInstance(libredditInstancesList) - return `${libredditRandomInstance}/preview/pre${url.pathname}${url.search}` - } - } - - let randomInstance - if (redditFrontend == "libreddit") { - if (libredditInstancesList.length === 0) return - randomInstance = utils.getRandomInstance(libredditInstancesList) - } - if (redditFrontend == "teddit") { - if (tedditInstancesList.length === 0) return - randomInstance = utils.getRandomInstance(tedditInstancesList) - } - return `${randomInstance}${url.pathname}${url.search}` -} - -function switchInstance(url, disableOverride) { - return new Promise(async resolve => { - await init() - if (disableReddit && !disableOverride) { - resolve() - return - } - const protocolHost = utils.protocolHost(url) - if (!all().includes(protocolHost)) { - resolve() - return - } - let instancesList = [] - if (redditFrontend == "libreddit") { - if (protocol == "loki") instancesList = [...libredditLokiCustomRedirects] - else if (protocol == "i2p") instancesList = [...libredditI2pCustomRedirects] - else 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 (protocol == "loki") instancesList = [...tedditLokiCustomRedirects] - else if (protocol == "i2p") instancesList = [...tedditI2pCustomRedirects] - else if (protocol == "tor") instancesList = [...tedditTorRedirectsChecks, ...tedditTorCustomRedirects] - if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") { - instancesList = [...tedditNormalRedirectsChecks, ...tedditNormalCustomRedirects] - } - if ([...redditRedirects.libreddit.normal, ...redditRedirects.libreddit.tor].includes(protocolHost)) url.pathname = url.pathname.replace("/img/", "/pics/w:null_") - } - - const i = instancesList.indexOf(protocolHost) - if (i > -1) instancesList.splice(i, 1) - if (instancesList.length === 0) { - resolve() - return - } - - const randomInstance = utils.getRandomInstance(instancesList) - resolve(`${randomInstance}${url.pathname}${url.search}`) - }) -} - -function initDefaults() { - return new Promise(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.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, - libredditNormalCustomRedirects: [], - - libredditTorRedirectsChecks: [...redirects.libreddit.tor], - libredditTorCustomRedirects: [], - - libredditI2pRedirectsChecks: [...redirects.libreddit.i2p], - libredditI2pCustomRedirects: [], - - libredditLokiRedirectsChecks: [...redirects.libreddit.loki], - libredditLokiCustomRedirects: [], - - tedditNormalRedirectsChecks, - tedditNormalCustomRedirects: [], - - tedditTorRedirectsChecks: [...redirects.teddit.tor], - tedditTorCustomRedirects: [], - - tedditI2pRedirectsChecks: [...redirects.teddit.i2p], - tedditI2pCustomRedirects: [], - - tedditLokiRedirectsChecks: [...redirects.teddit.loki], - tedditLokiCustomRedirects: [], - }, - () => resolve() - ) - }) - }) - }) -} - -export default { - setRedirects, - initLibredditCookies, - initTedditCookies, - - redirect, - initDefaults, - switchInstance, -} diff --git a/src/assets/javascripts/reuters.js b/src/assets/javascripts/reuters.js deleted file mode 100644 index 51d16329..00000000 --- a/src/assets/javascripts/reuters.js +++ /dev/null @@ -1,150 +0,0 @@ -window.browser = window.browser || window.chrome - -import utils from "./utils.js" - -const targets = [/^https?:\/{2}(www\.|)reuters\.com.*/] - -const frontends = new Array("neuters") -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", "offlineBlackList"], r => { - redirects.neuters = val - 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({ - neutersRedirects: redirects, - neutersNormalRedirectsChecks, - neutersTorRedirectsChecks: [...redirects.neuters.tor], - neutersI2pRedirectsChecks: [...redirects.neuters.i2p], - neutersLokiRedirectsChecks: [...redirects.neuters.loki], - }) - }) -} - -let disableReuters, - protocol, - protocolFallback, - reutersRedirects, - neutersNormalRedirectsChecks, - neutersNormalCustomRedirects, - neutersTorRedirectsChecks, - neutersTorCustomRedirects, - neutersI2pCustomRedirects, - neutersLokiCustomRedirects - -function init() { - return new Promise(async resolve => { - browser.storage.local.get( - [ - "disableReuters", - "protocol", - "protocolFallback", - "reutersRedirects", - "neutersNormalRedirectsChecks", - "neutersNormalCustomRedirects", - "neutersTorRedirectsChecks", - "neutersTorCustomRedirects", - "neutersI2pCustomRedirects", - "neutersLokiCustomRedirects", - ], - r => { - disableReuters = r.disableReuters - protocol = r.protocol - protocolFallback = r.protocolFallback - reutersRedirects = r.reutersRedirects - neutersNormalRedirectsChecks = r.neutersNormalRedirectsChecks - neutersNormalCustomRedirects = r.neutersNormalCustomRedirects - neutersTorRedirectsChecks = r.neutersTorRedirectsChecks - neutersTorCustomRedirects = r.neutersTorCustomRedirects - neutersI2pCustomRedirects = r.neutersI2pCustomRedirects - neutersLokiCustomRedirects = r.neutersLokiCustomRedirects - resolve() - } - ) - }) -} - -init() -browser.storage.onChanged.addListener(init) - -function redirect(url, type, initiator, disableOverride) { - if (disableReuters && !disableOverride) return - if (type != "main_frame") return - const all = [...reutersRedirects.neuters.normal, ...neutersNormalCustomRedirects] - if (initiator && (all.includes(initiator.origin) || targets.includes(initiator.host))) return - if (!targets.some(rx => rx.test(url.href))) return - - let instancesList = [] - 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] - } - if (instancesList.length === 0) return - - const randomInstance = utils.getRandomInstance(instancesList) - // stolen from https://addons.mozilla.org/en-US/firefox/addon/reuters-redirect/ - if (url.pathname.startsWith("/article/") || url.pathname.startsWith("/pf/") || url.pathname.startsWith("/arc/") || url.pathname.startsWith("/resizer/")) return null - else if (url.pathname.endsWith("/")) return `${randomInstance}${url.pathname}` - else return `${randomInstance}${url.pathname}/` -} - -function initDefaults() { - 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.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, - neutersNormalCustomRedirects: [], - - neutersTorRedirectsChecks: [...redirects.neuters.tor], - neutersTorCustomRedirects: [], - - neutersI2pRedirectsChecks: [...redirects.neuters.i2p], - neutersI2pCustomRedirects: [], - - neutersLokiRedirectsChecks: [...redirects.neuters.loki], - neutersLokiCustomRedirects: [], - }, - () => resolve() - ) - }) - }) - }) -} - -export default { - setRedirects, - redirect, - initDefaults, -} diff --git a/src/assets/javascripts/search.js b/src/assets/javascripts/search.js deleted file mode 100644 index 64b56caa..00000000 --- a/src/assets/javascripts/search.js +++ /dev/null @@ -1,576 +0,0 @@ -window.browser = window.browser || window.chrome - -import utils from "./utils.js" - -const targets = [/^https?:\/{2}search\.libredirect\.invalid/] -// 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", "loki") - -const 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", "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, ...r.offlineBlackList]) { - const a = searxNormalRedirectsChecks.indexOf(instance) - if (a > -1) searxNormalRedirectsChecks.splice(a, 1) - - const b = searxngNormalRedirectsChecks.indexOf(instance) - if (b > -1) searxngNormalRedirectsChecks.splice(b, 1) - - const c = whoogleNormalRedirectsChecks.indexOf(instance) - if (c > -1) whoogleNormalRedirectsChecks.splice(c, 1) - - const d = librexNormalRedirectsChecks.indexOf(instance) - if (d > -1) librexNormalRedirectsChecks.splice(d, 1) - } - browser.storage.local.set({ - searchRedirects: redirects, - searxNormalRedirectsChecks, - searxTorRedirectsChecks: [...redirects.searx.tor], - searxI2pRedirectsChecks: [...redirects.searx.i2p], - searxLokiRedirectsChecks: [...redirects.searx.loki], - searxngNormalRedirectsChecks, - searxngTorRedirectsChecks: [...redirects.searxng.tor], - searxngI2pRedirectsChecks: [...redirects.searxng.i2p], - searxngLokiRedirectsChecks: [...redirects.searxng.loki], - whoogleNormalRedirectsChecks, - whoogleTorRedirectsChecks: [...redirects.whoogle.tor], - whoogleI2pRedirectsChecks: [...redirects.whoogle.i2p], - whoogleLokiRedirectsChecks: [...redirects.whoogle.loki], - librexNormalRedirectsChecks, - librexTorRedirectsChecks: [...redirects.librex.tor], - librexI2pRedirectsChecks: [...redirects.librex.i2p], - librexLokiRedirectsChecks: [...redirects.librex.loki], - }) - }) -} - -let disableSearch, - searchFrontend, - searchRedirects, - protocol, - protocolFallback, - whoogleNormalRedirectsChecks, - whoogleNormalCustomRedirects, - whoogleTorRedirectsChecks, - whoogleTorCustomRedirects, - whoogleI2pRedirectsChecks, - whoogleI2pCustomRedirects, - whoogleLokiCustomRedirects, - searxNormalRedirectsChecks, - searxNormalCustomRedirects, - searxTorRedirectsChecks, - searxTorCustomRedirects, - searxI2pRedirectsChecks, - searxI2pCustomRedirects, - searxLokiCustomRedirects, - searxngNormalRedirectsChecks, - searxngNormalCustomRedirects, - searxngTorRedirectsChecks, - searxngTorCustomRedirects, - searxngI2pRedirectsChecks, - searxngI2pCustomRedirects, - searxngLokiCustomRedirects, - librexNormalRedirectsChecks, - librexNormalCustomRedirects, - librexTorRedirectsChecks, - librexTorCustomRedirects, - librexI2pRedirectsChecks, - librexI2pCustomRedirects, - librexLokiCustomRedirects - -function init() { - return new Promise(async resolve => { - browser.storage.local.get( - [ - "disableSearch", - "searchFrontend", - "searchRedirects", - "protocol", - "protocolFallback", - "whoogleNormalRedirectsChecks", - "whoogleNormalCustomRedirects", - "whoogleTorRedirectsChecks", - "whoogleTorCustomRedirects", - "whoogleI2pRedirectsChecks", - "whoogleI2pCustomRedirects", - "whoogleLokiCustomRedirects", - "searxNormalRedirectsChecks", - "searxNormalCustomRedirects", - "searxTorRedirectsChecks", - "searxTorCustomRedirects", - "searxI2pRedirectsChecks", - "searxI2pCustomRedirects", - "searxLokiCustomRedirects", - "searxngNormalRedirectsChecks", - "searxngNormalCustomRedirects", - "searxngTorRedirectsChecks", - "searxngTorCustomRedirects", - "searxngI2pRedirectsChecks", - "searxngI2pCustomRedirects", - "searxngLokiCustomRedirects", - "librexNormalRedirectsChecks", - "librexNormalCustomRedirects", - "librexTorRedirectsChecks", - "librexTorCustomRedirects", - "librexI2pRedirectsChecks", - "librexI2pCustomRedirects", - "librexLokiCustomRedirects", - ], - r => { - disableSearch = r.disableSearch - searchFrontend = r.searchFrontend - searchRedirects = r.searchRedirects - protocol = r.protocol - protocolFallback = r.protocolFallback - whoogleNormalRedirectsChecks = r.whoogleNormalRedirectsChecks - whoogleNormalCustomRedirects = r.whoogleNormalCustomRedirects - whoogleTorRedirectsChecks = r.whoogleTorRedirectsChecks - whoogleTorCustomRedirects = r.whoogleTorCustomRedirects - whoogleI2pRedirectsChecks = r.whoogleI2pRedirectsChecks - whoogleI2pCustomRedirects = r.whoogleI2pCustomRedirects - whoogleLokiCustomRedirects = r.whoogleLokiCustomRedirects - searxNormalRedirectsChecks = r.searxNormalRedirectsChecks - searxNormalCustomRedirects = r.searxNormalCustomRedirects - searxTorRedirectsChecks = r.searxTorRedirectsChecks - searxTorCustomRedirects = r.searxTorCustomRedirects - searxI2pRedirectsChecks = r.searxI2pRedirectsChecks - searxI2pCustomRedirects = r.searxI2pCustomRedirects - searxLokiCustomRedirects = r.searxLokiCustomRedirects - searxngNormalRedirectsChecks = r.searxngNormalRedirectsChecks - searxngNormalCustomRedirects = r.searxngNormalCustomRedirects - searxngTorRedirectsChecks = r.searxngTorRedirectsChecks - searxngTorCustomRedirects = r.searxngTorCustomRedirects - searxngI2pRedirectsChecks = r.searxngI2pRedirectsChecks - searxngI2pCustomRedirects = r.searxngI2pCustomRedirects - searxngLokiCustomRedirects = r.searxngLokiCustomRedirects - librexNormalRedirectsChecks = r.librexNormalRedirectsChecks - librexNormalCustomRedirects = r.librexNormalCustomRedirects - librexTorRedirectsChecks = r.librexTorRedirectsChecks - librexTorCustomRedirects = r.librexTorCustomRedirects - librexI2pRedirectsChecks = r.librexI2pRedirectsChecks - librexI2pCustomRedirects = r.librexI2pCustomRedirects - librexLokiCustomRedirects = r.librexLokiCustomRedirects - resolve() - } - ) - }) -} - -init() -browser.storage.onChanged.addListener(init) - -function initSearxCookies(test, from) { - return new Promise(async resolve => { - await init() - let protocolHost = utils.protocolHost(from) - if ( - ![ - ...searxNormalRedirectsChecks, - ...searxNormalCustomRedirects, - ...searxTorRedirectsChecks, - ...searxTorCustomRedirects, - ...searxI2pRedirectsChecks, - ...searxI2pCustomRedirects, - ...searxLokiCustomRedirects, - ].includes(protocolHost) - ) { - resolve() - return - } - - if (!test) { - let checkedInstances = [] - if (protocol == "loki") checkedInstances = [...searxLokiCustomRedirects] - else if (protocol == "i2p") checkedInstances = [...searxI2pCustomRedirects, ...searxI2pRedirectsChecks] - else 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") - await utils.copyCookie("searx", from, checkedInstances, "disabled_engines") - await utils.copyCookie("searx", from, checkedInstances, "disabled_plugins") - await utils.copyCookie("searx", from, checkedInstances, "doi_resolver") - await utils.copyCookie("searx", from, checkedInstances, "enabled_engines") - await utils.copyCookie("searx", from, checkedInstances, "enabled_plugins") - await utils.copyCookie("searx", from, checkedInstances, "image_proxy") - await utils.copyCookie("searx", from, checkedInstances, "language") - await utils.copyCookie("searx", from, checkedInstances, "locale") - await utils.copyCookie("searx", from, checkedInstances, "method") - await utils.copyCookie("searx", from, checkedInstances, "oscar-style") - await utils.copyCookie("searx", from, checkedInstances, "results_on_new_tab") - await utils.copyCookie("searx", from, checkedInstances, "safesearch") - await utils.copyCookie("searx", from, checkedInstances, "theme") - await utils.copyCookie("searx", from, checkedInstances, "tokens") - } - resolve(true) - }) -} - -function initSearxngCookies(test, from) { - return new Promise(async resolve => { - await init() - let protocolHost = utils.protocolHost(from) - if ( - ![ - ...searxngNormalRedirectsChecks, - ...searxngNormalCustomRedirects, - ...searxngTorRedirectsChecks, - ...searxngTorCustomRedirects, - ...searxngI2pRedirectsChecks, - ...searxngI2pCustomRedirects, - ...searxngLokiCustomRedirects, - ].includes(protocolHost) - ) { - resolve() - return - } - - if (!test) { - let checkedInstances = [] - if (protocol == "loki") checkedInstances = [...searxngLokiCustomRedirects] - else if (protocol == "i2p") checkedInstances = [...searxngI2pCustomRedirects, ...searxngI2pRedirectsChecks] - else 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") - await utils.copyCookie("searxng", from, checkedInstances, "disabled_plugins") - await utils.copyCookie("searxng", from, checkedInstances, "doi_resolver") - await utils.copyCookie("searxng", from, checkedInstances, "enabled_plugins") - await utils.copyCookie("searxng", from, checkedInstances, "enabled_engines") - await utils.copyCookie("searxng", from, checkedInstances, "image_proxy") - await utils.copyCookie("searxng", from, checkedInstances, "infinite_scroll") - await utils.copyCookie("searxng", from, checkedInstances, "language") - await utils.copyCookie("searxng", from, checkedInstances, "locale") - await utils.copyCookie("searxng", from, checkedInstances, "maintab") - await utils.copyCookie("searxng", from, checkedInstances, "method") - await utils.copyCookie("searxng", from, checkedInstances, "query_in_title") - await utils.copyCookie("searxng", from, checkedInstances, "results_on_new_tab") - await utils.copyCookie("searxng", from, checkedInstances, "safesearch") - await utils.copyCookie("searxng", from, checkedInstances, "simple_style") - await utils.copyCookie("searxng", from, checkedInstances, "theme") - await utils.copyCookie("searxng", from, checkedInstances, "tokens") - } - resolve(true) - }) -} - -function initLibrexCookies(test, from) { - return new Promise(async resolve => { - await init() - let protocolHost = utils.protocolHost(from) - if ( - ![ - ...librexNormalRedirectsChecks, - ...librexNormalCustomRedirects, - ...librexTorRedirectsChecks, - ...librexTorCustomRedirects, - ...librexI2pRedirectsChecks, - ...librexI2pCustomRedirects, - ...librexLokiCustomRedirects, - ].includes(protocolHost) - ) { - resolve() - return - } - - if (!test) { - let checkedInstances = [] - if (protocol == "loki") checkedInstances = [...librexLokiCustomRedirects] - else if (protocol == "i2p") checkedInstances = [...librexI2pCustomRedirects, ...librexI2pRedirectsChecks] - else 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") - await utils.copyCookie("librex", from, checkedInstances, "libreddit") - await utils.copyCookie("librex", from, checkedInstances, "nitter") - await utils.copyCookie("librex", from, checkedInstances, "proxitok") - await utils.copyCookie("librex", from, checkedInstances, "theme") - await utils.copyCookie("librex", from, checkedInstances, "wikiless") - } - resolve(true) - }) -} - -function redirect(url, disableOverride) { - if (disableSearch && !disableOverride) return - if (!targets.some(rx => rx.test(url.href))) return - if (url.searchParams.has("tbm")) return - if (url.hostname.includes("google") && !url.searchParams.has("q") && url.pathname != "/") return - let randomInstance - let path - if (searchFrontend == "searx") { - let instancesList = [] - if (protocol == "loki") instancesList = [...searxLokiCustomRedirects] - else if (protocol == "i2p") instancesList = [...searxI2pCustomRedirects, ...searxI2pRedirectsChecks] - else 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 (protocol == "loki") instancesList = [...searxngLokiCustomRedirects] - else if (protocol == "i2p") instancesList = [...searxngI2pCustomRedirects, ...searxngI2pRedirectsChecks] - else 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 (protocol == "loki") instancesList = [...whoogleLokiCustomRedirects] - else if (protocol == "i2p") instancesList = [...whoogleI2pCustomRedirects, ...whoogleI2pRedirectsChecks] - else 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 (protocol == "loki") instancesList = [...librexLokiCustomRedirects] - else if (protocol == "i2p") instancesList = [...librexI2pCustomRedirects, ...librexI2pRedirectsChecks] - else 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" - } - - if (((url.hostname.includes("google") || url.hostname.includes("bing")) && !url.searchParams.has("q")) || (url.hostname.includes("yandex") && !url.searchParams.has("text"))) path = "/" - - let searchQuery = "" - if ((url.hostname.includes("google") || url.hostname.includes("bing") || url.hostname.includes("search.libredirect.invalid")) && url.searchParams.has("q")) - searchQuery = `?q=${encodeURIComponent(url.searchParams.get("q"))}` - if (url.hostname.includes("yandex") && url.searchParams.has("text")) searchQuery = `?q=${url.searchParams.get("text")}` - - return `${randomInstance}${path}${searchQuery}` -} - -function switchInstance(url, disableOverride) { - return new Promise(async resolve => { - await init() - if (disableSearch && !disableOverride) { - resolve() - return - } - let protocolHost = utils.protocolHost(url) - if ( - ![ - ...searchRedirects.searx.normal, - ...searchRedirects.searx.tor, - ...searchRedirects.searx.i2p, - - ...searchRedirects.searxng.normal, - ...searchRedirects.searxng.tor, - ...searchRedirects.searxng.i2p, - - ...searchRedirects.whoogle.normal, - ...searchRedirects.whoogle.tor, - ...searchRedirects.whoogle.i2p, - - ...searchRedirects.librex.normal, - ...searchRedirects.librex.tor, - ...searchRedirects.librex.i2p, - - ...searxNormalCustomRedirects, - ...searxTorCustomRedirects, - ...searxI2pCustomRedirects, - ...searxLokiCustomRedirects, - - ...searxngNormalCustomRedirects, - ...searxngTorCustomRedirects, - ...searxngI2pCustomRedirects, - ...searxngLokiCustomRedirects, - - ...whoogleNormalCustomRedirects, - ...whoogleTorCustomRedirects, - ...whoogleI2pCustomRedirects, - ...whoogleLokiCustomRedirects, - - ...librexNormalCustomRedirects, - ...librexTorCustomRedirects, - ...librexI2pCustomRedirects, - ...librexLokiCustomRedirects, - ].includes(protocolHost) - ) { - resolve() - return - } - - let instancesList = [] - - if (protocol == "loki") { - if (searchFrontend == "searx") instancesList = [...searxLokiCustomRedirects] - else if (searchFrontend == "searxng") instancesList = [...searxngLokiCustomRedirects] - else if (searchFrontend == "whoogle") instancesList = [...whoogleLokiCustomRedirects] - else if (searchFrontend == "librex") instancesList = [...librexLokiCustomRedirects] - } else 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 (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 - } - - const randomInstance = utils.getRandomInstance(instancesList) - resolve(`${randomInstance}${url.pathname}${url.search}`) - }) -} - -function initDefaults() { - 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.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) - - const b = searxngNormalRedirectsChecks.indexOf(instance) - if (b > -1) searxngNormalRedirectsChecks.splice(b, 1) - - const c = whoogleNormalRedirectsChecks.indexOf(instance) - if (c > -1) whoogleNormalRedirectsChecks.splice(c, 1) - - const d = librexNormalRedirectsChecks.indexOf(instance) - if (d > -1) librexNormalRedirectsChecks.splice(d, 1) - } - browser.storage.local.set( - { - disableSearch: false, - searchFrontend: "searxng", - searchRedirects: redirects, - searxngCustomSettings: false, - - whoogleNormalRedirectsChecks, - whoogleNormalCustomRedirects: [], - - whoogleTorRedirectsChecks: [...redirects.whoogle.tor], - whoogleTorCustomRedirects: [], - - whoogleI2pRedirectsChecks: [...redirects.whoogle.i2p], - whoogleI2pCustomRedirects: [], - - whoogleLokiRedirectsChecks: [...redirects.whoogle.loki], - whoogleLokiCustomRedirects: [], - - searxNormalRedirectsChecks, - searxNormalCustomRedirects: [], - - searxTorRedirectsChecks: [...redirects.searx.tor], - searxTorCustomRedirects: [], - - searxI2pRedirectsChecks: [...redirects.searx.i2p], - searxI2pCustomRedirects: [], - - searxLokiRedirectsChecks: [...redirects.searx.loki], - searxLokiCustomRedirects: [], - - searxngNormalRedirectsChecks, - searxngNormalCustomRedirects: [], - - searxngTorRedirectsChecks: [...redirects.searxng.tor], - searxngTorCustomRedirects: [], - - searxngI2pRedirectsChecks: [...redirects.searxng.i2p], - searxngI2pCustomRedirects: [], - - searxngLokiRedirectsChecks: [...redirects.searxng.loki], - searxngLokiCustomRedirects: [], - - librexNormalRedirectsChecks, - librexNormalCustomRedirects: [], - - librexTorRedirectsChecks: [...redirects.librex.tor], - librexTorCustomRedirects: [], - - librexI2pRedirectsChecks: [...redirects.librex.i2p], - librexI2pCustomRedirects: [], - - librexLokiRedirectsChecks: [...redirects.librex.loki], - librexLokiCustomRedirects: [], - }, - () => resolve() - ) - }) - }) - }) -} - -export default { - setRedirects, - initSearxCookies, - initSearxngCookies, - initLibrexCookies, - redirect, - initDefaults, - switchInstance, -} diff --git a/src/assets/javascripts/sendTargets.js b/src/assets/javascripts/sendTargets.js deleted file mode 100644 index a52ab6ff..00000000 --- a/src/assets/javascripts/sendTargets.js +++ /dev/null @@ -1,195 +0,0 @@ -window.browser = window.browser || window.chrome - -import utils from "./utils.js" - -const targets = [/^https?:\/{2}send\.libredirect\.invalid\/$/, /^ https ?: \/\/send\.firefox\.com\/$/, /^https?:\/{2}sendfiles\.online\/$/] - -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", "offlineBlackList"], r => { - redirects.send = val - 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({ - sendTargetsRedirects: redirects, - sendNormalRedirectsChecks, - sendTorRedirectsChecks: [...redirects.send.tor], - sendI2pRedirectsChecks: [...redirects.send.i2p], - sendLokiRedirectsChecks: [...redirects.send.loki], - }) - }) -} - -let disableSendTarget, - sendTargetsRedirects, - sendNormalRedirectsChecks, - sendNormalCustomRedirects, - sendTorRedirectsChecks, - sendTorCustomRedirects, - sendI2pCustomRedirects, - sendLokiCustomRedirects, - protocol, - protocolFallback - -function init() { - return new Promise(resolve => { - browser.storage.local.get( - [ - "disableSendTarget", - "sendTargetsRedirects", - "protocol", - "protocolFallback", - "sendNormalRedirectsChecks", - "sendNormalCustomRedirects", - "sendTorRedirectsChecks", - "sendTorCustomRedirects", - "sendI2pCustomRedirects", - "sendLokiCustomRedirects", - ], - r => { - disableSendTarget = r.disableSendTarget - sendTargetsRedirects = r.sendTargetsRedirects - sendNormalRedirectsChecks = r.sendNormalRedirectsChecks - sendNormalCustomRedirects = r.sendNormalCustomRedirects - sendTorRedirectsChecks = r.sendTorRedirectsChecks - sendTorCustomRedirects = r.sendTorCustomRedirects - sendI2pCustomRedirects = r.sendI2pCustomRedirects - sendLokiCustomRedirects = r.sendLokiCustomRedirects - protocol = r.protocol - protocolFallback = r.protocolFallback - resolve() - } - ) - }) -} - -init() -browser.storage.onChanged.addListener(init) - -function all() { - return [ - ...sendTargetsRedirects.send.normal, - ...sendTargetsRedirects.send.tor, - ...sendNormalCustomRedirects, - ...sendTorRedirectsChecks, - ...sendTorCustomRedirects, - ...sendI2pCustomRedirects, - ...sendLokiCustomRedirects, - ] -} - -function switchInstance(url, disableOverride) { - return new Promise(async resolve => { - await init() - if (disableSendTarget && !disableOverride) { - resolve() - return - } - const protocolHost = utils.protocolHost(url) - if (!all().includes(protocolHost)) { - resolve() - return - } - if (url.pathname != "/") { - resolve() - return - } - - let instancesList = [] - if (protocol == "loki") instancesList = [...sendLokiCustomRedirects] - else if (protocol == "i2p") instancesList = [...sendI2pCustomRedirects] - else 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) - if (instancesList.length === 0) { - resolve() - return - } - - const randomInstance = utils.getRandomInstance(instancesList) - resolve(`${randomInstance}${url.pathname}${url.search}`) - }) -} - -function redirect(url, type, initiator, disableOverride) { - if (disableSendTarget && !disableOverride) return - if (type != "main_frame") return - if (initiator && (all().includes(initiator.origin) || targets.includes(initiator.host))) return - if (!targets.some(rx => rx.test(url.href))) return - - let instancesList = [] - if (protocol == "loki") instancesList = [...sendLokiCustomRedirects] - else if (protocol == "i2p") instancesList = [...sendI2pCustomRedirects] - else 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) - return randomInstance -} - -function initDefaults() { - return new Promise(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.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, - sendNormalCustomRedirects: [], - - sendTorRedirectsChecks: [...redirects.send.tor], - sendTorCustomRedirects: [], - - sendI2pRedirectsChecks: [...redirects.send.i2p], - sendI2pCustomRedirects: [], - - sendLokiRedirectsChecks: [...redirects.send.loki], - sendLokiCustomRedirects: [], - }, - () => resolve() - ) - }) - }) - }) -} - -export default { - setRedirects, - redirect, - switchInstance, - initDefaults, -} diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js index 3db12595..49af6d1f 100644 --- a/src/assets/javascripts/services.js +++ b/src/assets/javascripts/services.js @@ -550,29 +550,30 @@ function unifyPreferences(url) { } function setRedirects(redirects) { - browser.storage.local.get(["options", "blacklists"], async r => { - let options = r.options - let targets = {} - for (const service in config.services) { - if (config.services[service].targets == "datajson") { - targets[service] = redirects[service] - } - for (const frontend in config.services[service].frontends) { - if (config.services[service].frontends[frontend].instanceList) { - for (const network in config.networks) { - options[frontend][network].enabled = redirects[frontend][network] - } - for (const blacklist in r.blacklists) { - for (const instance of blacklist) { - let i = options[frontend].clearnet.enabled.indexOf(instance) - if (i > -1) options[frontend].clearnet.enabled.splice(i, 1) - } + //browser.storage.local.get(["options", "blacklists"], async r => { + //let options = r.options + let targets = {} + for (const service in config.services) { + if (config.services[service].targets == "datajson") { + targets[service] = redirects[service] + } + for (const frontend in config.services[service].frontends) { + if (config.services[service].frontends[frontend].instanceList) { + for (const network in config.networks) { + options[frontend][network].enabled = redirects[frontend][network] + } + for (const blacklist in blacklists) { + for (const instance of blacklist) { + let i = options[frontend].clearnet.enabled.indexOf(instance) + if (i > -1) options[frontend].clearnet.enabled.splice(i, 1) } } } } - browser.storage.local.set({ redirects, targets, options }) - }) + } + console.log(redirects) + browser.storage.local.set({ redirects, targets, options }) + //}) } export default { diff --git a/src/assets/javascripts/tiktok.js b/src/assets/javascripts/tiktok.js deleted file mode 100644 index 71f07687..00000000 --- a/src/assets/javascripts/tiktok.js +++ /dev/null @@ -1,246 +0,0 @@ -window.browser = window.browser || window.chrome - -import utils from "./utils.js" - -const targets = [/^https?:\/{2}(www\.|)tiktok\.com.*/] - -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", "offlineBlackList"], r => { - redirects.proxiTok = val - proxiTokNormalRedirectsChecks = [...redirects.proxiTok.normal] - for (const instance of [...r.cloudflareBlackList, ...r.offlineBlackList]) { - const a = proxiTokNormalRedirectsChecks.indexOf(instance) - if (a > -1) proxiTokNormalRedirectsChecks.splice(a, 1) - } - browser.storage.local.set({ - tiktokRedirects: redirects, - proxiTokNormalRedirectsChecks, - proxiTokTorRedirectsChecks: [...redirects.proxiTok.tor], - proxiTokI2pRedirectsChecks: [...redirects.proxiTok.i2p], - proxiTokLokiRedirectsChecks: [...redirects.proxiTok.loki], - }) - }) -} - -function initProxiTokCookies(test, from) { - return new Promise(async resolve => { - await init() - let protocolHost = utils.protocolHost(from) - if ( - ![ - ...proxiTokNormalRedirectsChecks, - ...proxiTokNormalCustomRedirects, - ...proxiTokTorRedirectsChecks, - ...proxiTokTorCustomRedirects, - ...proxiTokI2pCustomRedirects, - ...proxiTokLokiCustomRedirects, - ].includes(protocolHost) - ) - resolve() - - if (!test) { - let checkedInstances = [] - if (protocol == "loki") checkedInstances = [...proxiTokI2pCustomRedirects] - else if (protocol == "i2p") checkedInstances = [...proxiTokLokiCustomRedirects] - else if (protocol == "tor") checkedInstances = [...proxiTokTorRedirectsChecks, ...proxiTokTorCustomRedirects] - if ((checkedInstances.length === 0 && protocolFallback) || protocol == "normal") { - checkedInstances = [...proxiTokNormalRedirectsChecks, ...proxiTokNormalCustomRedirects] - } - await utils.copyCookie("proxitok", from, checkedInstances, "theme") - await utils.copyCookie("proxitok", from, checkedInstances, "api-legacy") - } - resolve(true) - }) -} - -let disableTiktok, - protocol, - protocolFallback, - tiktokRedirects, - proxiTokNormalRedirectsChecks, - proxiTokNormalCustomRedirects, - proxiTokTorRedirectsChecks, - proxiTokTorCustomRedirects, - proxiTokI2pCustomRedirects, - proxiTokLokiCustomRedirects - -function init() { - return new Promise(async resolve => { - browser.storage.local.get( - [ - "disableTiktok", - "protocol", - "protocolFallback", - "tiktokRedirects", - "proxiTokNormalRedirectsChecks", - "proxiTokNormalCustomRedirects", - "proxiTokTorRedirectsChecks", - "proxiTokTorCustomRedirects", - "proxiTokI2pCustomRedirects", - "proxiTokLokiCustomRedirects", - ], - r => { - disableTiktok = r.disableTiktok - protocol = r.protocol - protocolFallback = r.protocolFallback - tiktokRedirects = r.tiktokRedirects - proxiTokNormalRedirectsChecks = r.proxiTokNormalRedirectsChecks - proxiTokNormalCustomRedirects = r.proxiTokNormalCustomRedirects - proxiTokTorRedirectsChecks = r.proxiTokTorRedirectsChecks - proxiTokTorCustomRedirects = r.proxiTokTorCustomRedirects - proxiTokI2pCustomRedirects = r.proxiTokI2pCustomRedirects - proxiTokLokiCustomRedirects = r.proxiTokLokiCustomRedirects - resolve() - } - ) - }) -} - -init() -browser.storage.onChanged.addListener(init) - -// https://www.tiktok.com/@keysikaspol/video/7061265241887345946 -// https://www.tiktok.com/@keysikaspol -function redirect(url, type, initiator, disableOverride) { - if (disableTiktok && !disableOverride) return - if (type != "main_frame") return - const all = [...tiktokRedirects.proxiTok.normal, ...proxiTokNormalCustomRedirects] - if (initiator && (all.includes(initiator.origin) || targets.includes(initiator.host))) return - if (!targets.some(rx => rx.test(url.href))) return - - let instancesList = [] - if (protocol == "loki") instancesList = [...proxiTokI2pCustomRedirects] - else if (protocol == "i2p") instancesList = [...proxiTokLokiCustomRedirects] - else 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) - return `${randomInstance}${url.pathname}` -} - -function reverse(url) { - return new Promise(async resolve => { - await init() - let protocolHost = utils.protocolHost(url) - const all = [ - ...tiktokRedirects.proxiTok.normal, - ...tiktokRedirects.proxiTok.tor, - ...proxiTokNormalCustomRedirects, - ...proxiTokTorCustomRedirects, - ...proxiTokI2pCustomRedirects, - ...proxiTokLokiCustomRedirects, - ] - if (!all.includes(protocolHost)) { - resolve() - return - } - - resolve(`https://tiktok.com${url.pathname}${url.search}`) - }) -} - -function switchInstance(url, disableOverride) { - return new Promise(async resolve => { - await init() - if (disableTiktok && !disableOverride) { - resolve() - return - } - let protocolHost = utils.protocolHost(url) - const all = [ - ...tiktokRedirects.proxiTok.tor, - ...tiktokRedirects.proxiTok.normal, - - ...proxiTokNormalCustomRedirects, - ...proxiTokTorCustomRedirects, - ...proxiTokI2pCustomRedirects, - ...proxiTokLokiCustomRedirects, - ] - if (!all.includes(protocolHost)) { - resolve() - return - } - - let instancesList = [] - if (protocol == "loki") instancesList = [...proxiTokI2pCustomRedirects] - else if (protocol == "i2p") instancesList = [...proxiTokLokiCustomRedirects] - else 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) - if (instancesList.length === 0) { - resolve() - return - } - - const randomInstance = utils.getRandomInstance(instancesList) - resolve(`${randomInstance}${url.pathname}${url.search}`) - }) -} - -function initDefaults() { - 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.get(["cloudflareBlackList", "offlineBlackList"], async r => { - proxiTokNormalRedirectsChecks = [...redirects.proxiTok.normal] - 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, - proxiTokNormalCustomRedirects: [], - - proxiTokTorRedirectsChecks: [...redirects.proxiTok.tor], - proxiTokTorCustomRedirects: [], - - proxiTokI2pRedirectsChecks: [...redirects.proxiTok.i2p], - proxiTokI2pCustomRedirects: [], - - proxiTokLokiRedirectsChecks: [...redirects.proxiTok.loki], - proxiTokLokiCustomRedirects: [], - }, - () => resolve() - ) - }) - }) - }) -} - -export default { - setRedirects, - redirect, - reverse, - switchInstance, - initProxiTokCookies, - initDefaults, -} diff --git a/src/assets/javascripts/translate/get_lingva_preferences.js b/src/assets/javascripts/translate/get_lingva_preferences.js deleted file mode 100644 index 0d6ff6ec..00000000 --- a/src/assets/javascripts/translate/get_lingva_preferences.js +++ /dev/null @@ -1,10 +0,0 @@ -window.browser = window.browser || window.chrome - -browser.storage.local.set({ - ["lingva_chakra-ui-color-mode"]: localStorage.getItem("chakra-ui-color-mode"), - lingva_isauto: localStorage.getItem("isauto"), - lingva_source: localStorage.getItem("source"), - lingva_target: localStorage.getItem("target"), -}) - -console.log(localStorage.getItem("target")) diff --git a/src/assets/javascripts/translate/set_lingva_preferences.js b/src/assets/javascripts/translate/set_lingva_preferences.js deleted file mode 100644 index 04a36e1b..00000000 --- a/src/assets/javascripts/translate/set_lingva_preferences.js +++ /dev/null @@ -1,9 +0,0 @@ -window.browser = window.browser || window.chrome - -browser.storage.local.get(["lingva_chakra-ui-color-mode", "lingva_isauto", "lingva_source", "lingva_target"], r => { - if (r["lingva_chakra-ui-color-mode"] !== undefined) localStorage.setItem("chakra-ui-color-mode", r["lingva_chakra-ui-color-mode"]) - if (r.lingva_isauto !== undefined) localStorage.setItem("isauto", r.lingva_isauto) - if (r.lingva_source !== undefined) localStorage.setItem("source", r.lingva_source) - if (r.lingva_target !== undefined) localStorage.setItem("target", r.lingva_target) - window.close() -}) diff --git a/src/assets/javascripts/translate/translate.js b/src/assets/javascripts/translate/translate.js deleted file mode 100644 index 993c630f..00000000 --- a/src/assets/javascripts/translate/translate.js +++ /dev/null @@ -1,372 +0,0 @@ -window.browser = window.browser || window.chrome - -import utils from "../utils.js" - -const targets = [/^https?:\/{2}translate\.google(\.[a-z]{2,3}){1,2}\//] - -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, - protocol, - protocolFallback, - translateRedirects, - simplyTranslateNormalRedirectsChecks, - simplyTranslateNormalCustomRedirects, - simplyTranslateTorRedirectsChecks, - simplyTranslateTorCustomRedirects, - simplyTranslateI2pRedirectsChecks, - simplyTranslateI2pCustomRedirects, - simplyTranslateLokiRedirectsChecks, - simplyTranslateLokiCustomRedirects, - lingvaNormalRedirectsChecks, - lingvaNormalCustomRedirects, - lingvaTorRedirectsChecks, - lingvaTorCustomRedirects, - lingvaI2pCustomRedirects, - lingvaLokiCustomRedirects - -function init() { - return new Promise(resolve => { - browser.storage.local.get( - [ - "translateDisable", - "translateFrontend", - "protocol", - "protocolFallback", - "translateRedirects", - "simplyTranslateNormalRedirectsChecks", - "simplyTranslateNormalCustomRedirects", - "simplyTranslateTorRedirectsChecks", - "simplyTranslateTorCustomRedirects", - "simplyTranslateI2pRedirectsChecks", - "simplyTranslateI2pCustomRedirects", - "simplyTranslateLokiRedirectsChecks", - "simplyTranslateLokiCustomRedirects", - - "lingvaNormalRedirectsChecks", - "lingvaNormalCustomRedirects", - "lingvaTorRedirectsChecks", - "lingvaTorCustomRedirects", - "lingvaI2pCustomRedirects", - "lingvaLokiCustomRedirects", - ], - r => { - translateDisable = r.translateDisable - translateFrontend = r.translateFrontend - 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 - simplyTranslateLokiRedirectsChecks = r.simplyTranslateLokiRedirectsChecks - simplyTranslateLokiCustomRedirects = r.simplyTranslateLokiCustomRedirects - lingvaNormalRedirectsChecks = r.lingvaNormalRedirectsChecks - lingvaNormalCustomRedirects = r.lingvaNormalCustomRedirects - lingvaTorRedirectsChecks = r.lingvaTorRedirectsChecks - lingvaTorCustomRedirects = r.lingvaTorCustomRedirects - lingvaI2pCustomRedirects = r.lingvaI2pCustomRedirects - lingvaLokiCustomRedirects = r.lingvaLokiCustomRedirects - resolve() - } - ) - }) -} - -init() -browser.storage.onChanged.addListener(init) - -function setRedirects(val) { - browser.storage.local.get(["cloudflareBlackList", "offlineBlackList"], r => { - redirects = val - simplyTranslateNormalRedirectsChecks = [...redirects.simplyTranslate.normal] - lingvaNormalRedirectsChecks = [...redirects.lingva.normal] - 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({ - translateRedirects: redirects, - simplyTranslateNormalRedirectsChecks, - simplyTranslateTorRedirectsChecks: [...redirects.simplyTranslate.tor], - simplyTranslateI2pRedirectsChecks: [...redirects.simplyTranslate.i2p], - simplyTranslateLokiRedirectsChecks: [...redirects.simplyTranslate.loki], - lingvaNormalRedirectsChecks, - lingvaTorRedirectsChecks: [...redirects.lingva.tor], - lingvaI2pRedirectsChecks: [...redirects.lingva.i2p], - lingvaLokiRedirectsChecks: [...redirects.lingva.loki], - }) - }) -} - -function copyPasteLingvaLocalStorage(test, url, tabId) { - return new Promise(async resolve => { - await init() - if (translateDisable || translateFrontend != "lingva") { - resolve() - return - } - const protocolHost = utils.protocolHost(url) - if ( - ![...lingvaNormalRedirectsChecks, ...lingvaNormalCustomRedirects, ...lingvaTorRedirectsChecks, ...lingvaTorCustomRedirects, ...lingvaI2pCustomRedirects, ...lingvaLokiCustomRedirects].includes( - protocolHost - ) - ) { - resolve() - return - } - - if (!test) { - browser.tabs.executeScript(tabId, { - file: "/assets/javascripts/translate/get_lingva_preferences.js", - runAt: "document_start", - }) - - let checkedInstances = [] - if (protocol == "loki") checkedInstances = [...lingvaLokiCustomRedirects] - //...lingvaLokiRedirectsChecks, - else if (protocol == "i2p") checkedInstances = [...lingvaI2pCustomRedirects] - //...lingvaI2pRedirectsChecks, - else 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 - } - 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", - }) - ) - } - resolve(true) - }) -} - -function copyPasteSimplyTranslateCookies(test, from) { - return new Promise(async resolve => { - await init() - const protocolHost = utils.protocolHost(from) - if ( - ![ - ...simplyTranslateNormalRedirectsChecks, - ...simplyTranslateNormalCustomRedirects, - ...simplyTranslateTorRedirectsChecks, - ...simplyTranslateTorCustomRedirects, - ...simplyTranslateI2pRedirectsChecks, - ...simplyTranslateI2pCustomRedirects, - ...simplyTranslateLokiRedirectsChecks, - ...simplyTranslateLokiCustomRedirects, - ].includes(protocolHost) - ) { - resolve() - return - } - if (!test) { - let checkedInstances = [] - if (protocol == "loki") checkedInstances = [...simplyTranslateLokiRedirectsChecks, ...simplyTranslateLokiCustomRedirects] - 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") - await utils.copyCookie("simplyTranslate", from, checkedInstances, "use_text_fields") - } - resolve(true) - }) -} - -function redirect(url, disableOverride) { - if (translateDisable && !disableOverride) return - if (!targets.some(rx => rx.test(url.href))) return - - if (translateFrontend == "simplyTranslate") { - let instancesList = [] - if (protocol == "loki") instancesList = [...simplyTranslateLokiRedirectsChecks, ...simplyTranslateLokiCustomRedirects] - 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) - return `${randomInstance}/${url.search}` - } else if (translateFrontend == "lingva") { - let params_arr = url.search.split("&") - params_arr[0] = params_arr[0].substring(1) - let params = {} - for (let i = 0; i < params_arr.length; i++) { - let pair = params_arr[i].split("=") - params[pair[0]] = pair[1] - } - let instancesList = [] - if (protocol == "loki") instancesList = [...lingvaLokiCustomRedirects] - //...lingvaLokiRedirectsChecks, - else if (protocol == "i2p") instancesList = [...lingvaI2pCustomRedirects] //...lingvaI2pRedirectsChecks, - 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) - if (params.sl && params.tl && params.text) { - return `${randomInstance}/${params.sl}/${params.tl}/${params.text}` - } - return randomInstance - } -} - -function switchInstance(url, disableOverride) { - return new Promise(async resolve => { - await init() - if (translateDisable && !disableOverride) { - resolve() - return - } - const protocolHost = utils.protocolHost(url) - if ( - ![ - ...translateRedirects.simplyTranslate.normal, - ...translateRedirects.simplyTranslate.tor, - ...translateRedirects.simplyTranslate.i2p, - ...translateRedirects.simplyTranslate.loki, - - ...simplyTranslateNormalCustomRedirects, - ...simplyTranslateTorCustomRedirects, - ...simplyTranslateI2pCustomRedirects, - ...simplyTranslateLokiCustomRedirects, - - ...translateRedirects.lingva.normal, - ...translateRedirects.lingva.tor, - - ...lingvaNormalCustomRedirects, - ...lingvaTorCustomRedirects, - ...lingvaI2pCustomRedirects, - ...lingvaLokiCustomRedirects, - ].includes(protocolHost) - ) { - resolve() - return - } - - let instancesList = [] - - if (protocol == "loki") { - if (translateFrontend == "simplyTranslate") instancesList = [...simplyTranslateLokiRedirectsChecks, ...simplyTranslateLokiCustomRedirects] - else if (translateFrontend == "lingva") instancesList = [...lingvaLokiCustomRedirects] //...lingvaLokiRedirectsChecks, - } else if (protocol == "i2p") { - if (translateFrontend == "simplyTranslate") instancesList = [...simplyTranslateI2pRedirectsChecks, ...simplyTranslateI2pCustomRedirects] - else if (translateFrontend == "lingva") instancesList = [...lingvaI2pCustomRedirects] //...lingvaI2pRedirectsChecks, - } else if (protocol == "tor") { - if (translateFrontend == "simplyTranslate") instancesList = [...simplyTranslateTorRedirectsChecks, ...simplyTranslateTorCustomRedirects] - else if (translateFrontend == "lingva") instancesList = [...lingvaTorRedirectsChecks, ...lingvaTorCustomRedirects] - } - 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) - if (i > -1) instancesList.splice(i, 1) - if (instancesList.length === 0) { - resolve() - return - } - - const randomInstance = utils.getRandomInstance(instancesList) - resolve(`${randomInstance}${url.pathname}${url.search}`) - }) -} - -function initDefaults() { - 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.get(["cloudflareBlackList", "offlineBlackList"], async r => { - simplyTranslateNormalRedirectsChecks = [...redirects.simplyTranslate.normal] - lingvaNormalRedirectsChecks = [...redirects.lingva.normal] - for (const instance of [...r.cloudflareBlackList, ...r.offlineBlackList]) { - const a = simplyTranslateNormalRedirectsChecks.indexOf(instance) - if (a > -1) simplyTranslateNormalRedirectsChecks.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, - simplyTranslateNormalCustomRedirects: [], - - simplyTranslateTorRedirectsChecks: [...redirects.simplyTranslate.tor], - simplyTranslateTorCustomRedirects: [], - - simplyTranslateI2pRedirectsChecks: [...redirects.simplyTranslate.i2p], - simplyTranslateI2pCustomRedirects: [], - - simplyTranslateLokiRedirectsChecks: [...redirects.simplyTranslate.loki], - simplyTranslateLokiCustomRedirects: [], - - lingvaNormalRedirectsChecks, - lingvaNormalCustomRedirects: [], - - lingvaTorRedirectsChecks: [...redirects.lingva.tor], - lingvaTorCustomRedirects: [], - - lingvaI2pRedirectsChecks: [...redirects.lingva.i2p], - lingvaI2pCustomRedirects: [], - - lingvaLokiRedirectsChecks: [...redirects.lingva.loki], - lingvaLokiCustomRedirects: [], - }, - () => resolve() - ) - }) - }) - }) -} - -export default { - copyPasteSimplyTranslateCookies, - copyPasteLingvaLocalStorage, - setRedirects, - redirect, - initDefaults, - switchInstance, -} diff --git a/src/assets/javascripts/twitter.js b/src/assets/javascripts/twitter.js deleted file mode 100644 index 7111ad00..00000000 --- a/src/assets/javascripts/twitter.js +++ /dev/null @@ -1,268 +0,0 @@ -window.browser = window.browser || window.chrome - -import utils from "./utils.js" - -const targets = [/^https?:\/{2}(www\.|mobile\.|)twitter\.com/, /^https?:\/{2}(pbs\.|video\.|)twimg\.com/, /^https?:\/{2}platform\.twitter\.com\/embed/, /^https?:\/{2}t\.co/] - -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", "offlineBlackList"], r => { - redirects.nitter = val - 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({ - twitterRedirects: redirects, - nitterNormalRedirectsChecks, - nitterTorRedirectsChecks: [...redirects.nitter.tor], - nitterI2pRedirectsChecks: [...redirects.nitter.i2p], - nitterLokiRedirectsChecks: [...redirects.nitter.loki], - }) - }) -} - -let disableTwitter, - protocol, - protocolFallback, - twitterRedirects, - twitterRedirectType, - nitterNormalRedirectsChecks, - nitterNormalCustomRedirects, - nitterTorRedirectsChecks, - nitterTorCustomRedirects, - nitterI2pCustomRedirects, - nitterLokiCustomRedirects - -function init() { - return new Promise(async resolve => { - browser.storage.local.get( - [ - "disableTwitter", - "protocol", - "protocolFallback", - "twitterRedirects", - "twitterRedirectType", - "nitterNormalRedirectsChecks", - "nitterNormalCustomRedirects", - "nitterTorRedirectsChecks", - "nitterTorCustomRedirects", - "nitterI2pCustomRedirects", - "nitterLokiCustomRedirects", - ], - r => { - disableTwitter = r.disableTwitter - protocol = r.protocol - protocolFallback = r.protocolFallback - twitterRedirects = r.twitterRedirects - twitterRedirectType = r.twitterRedirectType - nitterNormalRedirectsChecks = r.nitterNormalRedirectsChecks - nitterNormalCustomRedirects = r.nitterNormalCustomRedirects - nitterTorRedirectsChecks = r.nitterTorRedirectsChecks - nitterTorCustomRedirects = r.nitterTorCustomRedirects - nitterI2pCustomRedirects = r.nitterI2pCustomRedirects - nitterLokiCustomRedirects = r.nitterLokiCustomRedirects - resolve() - } - ) - }) -} - -init() -browser.storage.onChanged.addListener(init) - -function all() { - return [...nitterNormalRedirectsChecks, ...nitterTorRedirectsChecks, ...nitterNormalCustomRedirects, ...nitterTorCustomRedirects, ...nitterI2pCustomRedirects, ...nitterLokiCustomRedirects] -} - -function redirect(url, type, initiator, disableOverride) { - if (disableTwitter && !disableOverride) return - if (!targets.some(rx => rx.test(url.href))) return - if (url.pathname.split("/").includes("home")) return - if (initiator && all().includes(initiator.origin)) return "BYPASSTAB" - if (twitterRedirectType == "sub_frame" && type == "main_frame") return - if (twitterRedirectType == "main_frame" && type != "main_frame") return - - let instancesList = [] - if (protocol == "loki") instancesList = [...nitterI2pCustomRedirects] - else if (protocol == "i2p") instancesList = [...nitterLokiCustomRedirects] - else 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) - // https://pbs.twimg.com/profile_images/648888480974508032/66_cUYfj_400x400.jpg - if (url.host.split(".")[0] === "pbs" || url.host.split(".")[0] === "video") { - const [, id, format, extra] = url.search.match(/(.*)\?format=(.*)&(.*)/) - const query = encodeURIComponent(`${id}.${format}?${extra}`) - return `${randomInstance}/pic${url.pathname}${query}` - } else if (url.pathname.split("/").includes("tweets")) return `${randomInstance}${url.pathname.replace("/tweets", "")}${url.search}` - else if (url.host == "t.co") return `${randomInstance}/t.co${url.pathname}` - else return `${randomInstance}${url.pathname}${url.search}` -} - -function reverse(url) { - return new Promise(async resolve => { - await init() - const protocolHost = utils.protocolHost(url) - if (!all().includes(protocolHost)) { - resolve() - return - } - resolve(`https://twitter.com${url.pathname}${url.search}`) - }) -} - -function switchInstance(url, disableOverride) { - return new Promise(async resolve => { - await init() - if (disableTwitter && !disableOverride) { - resolve() - return - } - const protocolHost = utils.protocolHost(url) - if (!all().includes(protocolHost)) { - resolve() - return - } - let instancesList = [] - if (protocol == "loki") instancesList = [...nitterI2pCustomRedirects] - else if (protocol == "i2p") instancesList = [...nitterLokiCustomRedirects] - else 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) - if (instancesList.length === 0) { - resolve() - return - } - - const randomInstance = utils.getRandomInstance(instancesList) - resolve(`${randomInstance}${url.pathname}${url.search}`) - }) -} - -function removeXFrameOptions(e) { - if (e.type != "sub_frame") return - let url = new URL(e.url) - let protocolHost = utils.protocolHost(url) - if (!all().includes(protocolHost)) return - let isChanged = false - for (const i in e.responseHeaders) { - if (e.responseHeaders[i].name == "x-frame-options") { - e.responseHeaders.splice(i, 1) - isChanged = true - } else if (e.responseHeaders[i].name == "content-security-policy") { - e.responseHeaders.splice(i, 1) - isChanged = true - } - } - if (isChanged) return { responseHeaders: e.responseHeaders } -} - -function initNitterCookies(test, from) { - return new Promise(async resolve => { - await init() - const protocolHost = utils.protocolHost(from) - if (!all().includes(protocolHost)) { - resolve() - return - } - if (!test) { - let checkedInstances = [] - if (protocol == "loki") checkedInstances = [...nitterI2pCustomRedirects] - else if (protocol == "i2p") checkedInstances = [...nitterLokiCustomRedirects] - else 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") - await utils.copyCookie("nitter", from, checkedInstances, "bidiSupport") - await utils.copyCookie("nitter", from, checkedInstances, "hideTweetStats") - await utils.copyCookie("nitter", from, checkedInstances, "hideBanner") - await utils.copyCookie("nitter", from, checkedInstances, "hidePins") - await utils.copyCookie("nitter", from, checkedInstances, "hideReplies") - await utils.copyCookie("nitter", from, checkedInstances, "squareAvatars") - await utils.copyCookie("nitter", from, checkedInstances, "mp4Playback") - await utils.copyCookie("nitter", from, checkedInstances, "hlsPlayback") - await utils.copyCookie("nitter", from, checkedInstances, "proxyVideos") - await utils.copyCookie("nitter", from, checkedInstances, "muteVideos") - await utils.copyCookie("nitter", from, checkedInstances, "autoplayGifs") - - await utils.copyCookie("nitter", from, checkedInstances, "replaceInstagram") - await utils.copyCookie("nitter", from, checkedInstances, "replaceReddit") - await utils.copyCookie("nitter", from, checkedInstances, "replaceTwitter") - await utils.copyCookie("nitter", from, checkedInstances, "replaceYouTube") - } - resolve(true) - }) -} - -function initDefaults() { - return new Promise(resolve => { - fetch("/instances/data.json") - .then(response => response.text()) - .then(data => { - let dataJson = JSON.parse(data) - for (let i = 0; i < frontends.length; i++) { - redirects[frontends[i]] = dataJson[frontends[i]] - } - 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, - nitterNormalCustomRedirects: [], - - nitterTorRedirectsChecks: [...redirects.nitter.tor], - nitterTorCustomRedirects: [], - - nitterI2pRedirectsChecks: [...redirects.nitter.i2p], - nitterI2pCustomRedirects: [], - - nitterLokiRedirectsChecks: [...redirects.nitter.loki], - nitterLokiCustomRedirects: [], - }, - () => resolve() - ) - }) - }) - }) -} - -export default { - setRedirects, - redirect, - switchInstance, - reverse, - removeXFrameOptions, - initNitterCookies, - initDefaults, -} diff --git a/src/assets/javascripts/utils.js b/src/assets/javascripts/utils.js index 70a93240..186fae43 100644 --- a/src/assets/javascripts/utils.js +++ b/src/assets/javascripts/utils.js @@ -1,22 +1,5 @@ window.browser = window.browser || window.chrome -import twitterHelper from "./twitter.js" -import youtubeHelper from "./youtube/youtube.js" -import instagramHelper from "./instagram.js" -import mediumHelper from "./medium.js" -import redditHelper from "./reddit.js" -import searchHelper from "./search.js" -import translateHelper from "./translate/translate.js" -import wikipediaHelper from "./wikipedia.js" -import peertubeHelper from "./peertube.js" -import lbryHelper from "./lbry.js" -import sendTargetsHelper from "./sendTargets.js" -import tiktokHelper from "./tiktok.js" -import quoraHelper from "./quora.js" -import libremdbHelper from "./imdb.js" -import imgurHelper from "./imgur.js" -import reutersHelper from "./reuters.js" -import youtubeMusicHelper from "./youtubeMusic.js" -import mapsHelper from "./maps.js" + import localise from "./localise.js" import servicesHelper from "./services.js" @@ -48,10 +31,10 @@ function updateInstances() { return new Promise(async resolve => { let http = new XMLHttpRequest() let fallback = new XMLHttpRequest() - http.open("GET", "https://raw.githubusercontent.com/libredirect/libredirect/master/src/instances/data.json", false) + http.open("GET", "https://codeberg.org/LibRedirect/libredirect/raw/branch/master/src/instances/data.json", false) http.send(null) if (http.status != 200) { - fallback.open("GET", "https://codeberg.org/LibRedirect/libredirect/raw/branch/master/src/instances/data.json", false) + fallback.open("GET", "https://raw.githubusercontent.com/libredirect/libredirect/master/src/instances/data.json", false) fallback.send(null) if (fallback.status === 200) { http = fallback @@ -63,42 +46,7 @@ function updateInstances() { await initBlackList() const instances = JSON.parse(http.responseText) - youtubeHelper.setRedirects({ - invidious: instances.invidious, - piped: instances.piped, - pipedMaterial: instances.pipedMaterial, - cloudtube: instances.cloudtube, - }) - twitterHelper.setRedirects(instances.nitter) - instagramHelper.setRedirects(instances.bibliogram) - redditHelper.setRedirects({ - libreddit: instances.libreddit, - teddit: instances.teddit, - }) - translateHelper.setRedirects({ - simplyTranslate: instances.simplyTranslate, - lingva: instances.lingva, - }) - searchHelper.setRedirects({ - searx: instances.searx, - searxng: instances.searxng, - whoogle: instances.whoogle, - librex: instances.librex, - }) - wikipediaHelper.setRedirects(instances.wikiless) - mediumHelper.setRedirects(instances.scribe) - quoraHelper.setRedirects(instances.quetre) - libremdbHelper.setRedirects(instances.libremdb) - sendTargetsHelper.setRedirects(instances.send) - tiktokHelper.setRedirects(instances.proxiTok) - lbryHelper.setRedirects(instances.librarian) - reutersHelper.setRedirects(instances.neuters) - youtubeMusicHelper.setRedirects({ - beatbump: instances.beatbump, - hyperpipe: instances.hyperpipe, - }) - mapsHelper.setRedirects(instances.facil) - peertubeHelper.setRedirects(instances.simpleertube) + servicesHelper.setRedirects(instances) console.info("Successfully updated Instances") resolve(true) diff --git a/src/assets/javascripts/wikipedia.js b/src/assets/javascripts/wikipedia.js deleted file mode 100644 index 2d0f75a1..00000000 --- a/src/assets/javascripts/wikipedia.js +++ /dev/null @@ -1,242 +0,0 @@ -window.browser = window.browser || window.chrome - -import utils from "./utils.js" - -const targets = /^https?:\/{2}([a-z]+\.)*wikipedia\.org/ - -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", "offlineBlackList"], r => { - redirects.wikiless = val - 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({ - wikipediaRedirects: redirects, - wikilessNormalRedirectsChecks, - wikilessTorRedirectsChecks: [...redirects.wikiless.tor], - wikilessI2pRedirectsChecks: [...redirects.wikiless.i2p], - wikilessLokiRedirectsChecks: [...redirects.wikiless.loki], - }) - }) -} - -let disableWikipedia, - wikipediaRedirects, - protocol, - protocolFallback, - wikilessNormalRedirectsChecks, - wikilessTorRedirectsChecks, - wikilessI2pRedirectsChecks, - wikilessNormalCustomRedirects, - wikilessTorCustomRedirects, - wikilessI2pCustomRedirects, - wikilessLokiCustomRedirects - -function init() { - return new Promise(async resolve => { - browser.storage.local.get( - [ - "disableWikipedia", - "wikipediaRedirects", - "protocol", - "protocolFallback", - "wikilessNormalRedirectsChecks", - "wikilessTorRedirectsChecks", - "wikilessI2pRedirectsChecks", - "wikilessNormalCustomRedirects", - "wikilessTorCustomRedirects", - "wikilessI2pCustomRedirects", - "wikilessLokiCustomRedirects", - ], - r => { - disableWikipedia = r.disableWikipedia - wikipediaRedirects = r.wikipediaRedirects - protocol = r.protocol - protocolFallback = r.protocolFallback - wikilessNormalRedirectsChecks = r.wikilessNormalRedirectsChecks - wikilessTorRedirectsChecks = r.wikilessTorRedirectsChecks - wikilessI2pRedirectsChecks = r.wikilessI2pRedirectsChecks - wikilessNormalCustomRedirects = r.wikilessNormalCustomRedirects - wikilessTorCustomRedirects = r.wikilessTorCustomRedirects - wikilessI2pCustomRedirects = r.wikilessI2pCustomRedirects - wikilessLokiCustomRedirects = r.wikilessLokiCustomRedirects - resolve() - } - ) - }) -} - -init() -browser.storage.onChanged.addListener(init) - -function initWikilessCookies(test, from) { - return new Promise(async resolve => { - await init() - const protocolHost = utils.protocolHost(from) - const all = [ - ...wikilessNormalRedirectsChecks, - ...wikilessNormalCustomRedirects, - ...wikilessTorRedirectsChecks, - ...wikilessTorCustomRedirects, - ...wikilessI2pRedirectsChecks, - ...wikilessI2pCustomRedirects, - ...wikilessLokiCustomRedirects, - ] - if (!all.includes(protocolHost)) { - resolve() - return - } - - if (!test) { - let checkedInstances = [] - if (protocol == "loki") checkedInstances = [...wikilessLokiCustomRedirects] - else if (protocol == "i2p") checkedInstances = [...wikilessI2pCustomRedirects, ...wikilessI2pRedirectsChecks] - else 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") - } - resolve(true) - }) -} - -function redirect(url, disableOverride) { - if (disableWikipedia && !disableOverride) return - if (!targets.test(url.href)) return - - let GETArguments = [] - if (url.search.length > 0) { - let search = url.search.substring(1) //get rid of '?' - let argstrings = search.split("&") - for (let i = 0; i < argstrings.length; i++) { - let args = argstrings[i].split("=") - GETArguments.push([args[0], args[1]]) - } - } - let instancesList = [] - if (protocol == "loki") instancesList = [...wikilessLokiCustomRedirects] - else 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) - - let link = `${randomInstance}${url.pathname}` - let urlSplit = url.host.split(".") - if (urlSplit[0] != "wikipedia" && urlSplit[0] != "www") { - if (urlSplit[0] == "m") GETArguments.push(["mobileaction", "toggle_view_mobile"]) - else GETArguments.push(["lang", urlSplit[0]]) - if (urlSplit[1] == "m") GETArguments.push(["mobileaction", "toggle_view_mobile"]) - // wikiless doesn't have mobile view support yet - } - for (let i = 0; i < GETArguments.length; i++) link += (i == 0 ? "?" : "&") + GETArguments[i][0] + "=" + GETArguments[i][1] - return link -} - -function switchInstance(url, disableOverride) { - return new Promise(async resolve => { - await init() - if (disableWikipedia && !disableOverride) { - resolve() - return - } - const protocolHost = utils.protocolHost(url) - const wikipediaList = [ - ...wikipediaRedirects.wikiless.normal, - ...wikipediaRedirects.wikiless.tor, - ...wikipediaRedirects.wikiless.i2p, - - ...wikilessNormalCustomRedirects, - ...wikilessTorCustomRedirects, - ...wikilessI2pCustomRedirects, - ...wikilessLokiCustomRedirects, - ] - if (!wikipediaList.includes(protocolHost)) { - resolve() - return - } - - let instancesList = [] - if (protocol == "loki") instancesList = [...wikilessLokiCustomRedirects] - else 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) - if (instancesList.length === 0) { - resolve() - return - } - - const randomInstance = utils.getRandomInstance(instancesList) - resolve(`${randomInstance}${url.pathname}${url.search}`) - }) -} - -function initDefaults() { - return new Promise(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.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, - wikilessNormalCustomRedirects: [], - - wikilessTorRedirectsChecks: [...redirects.wikiless.tor], - wikilessTorCustomRedirects: [], - - wikilessI2pRedirectsChecks: [...redirects.wikiless.i2p], - wikilessI2pCustomRedirects: [], - - wikilessLokiRedirectsChecks: [...redirects.wikiless.loki], - wikilessLokiCustomRedirects: [], - }, - () => resolve() - ) - }) - }) - }) -} - -export default { - setRedirects, - initWikilessCookies, - redirect, - initDefaults, - switchInstance, -} diff --git a/src/assets/javascripts/youtube/get_pipedMaterial_preferences.js b/src/assets/javascripts/youtube/get_pipedMaterial_preferences.js deleted file mode 100644 index df79e13c..00000000 --- a/src/assets/javascripts/youtube/get_pipedMaterial_preferences.js +++ /dev/null @@ -1,5 +0,0 @@ -window.browser = window.browser || window.chrome - -browser.storage.local.set({ - pipedMaterial_PREFERENCES: localStorage.getItem("PREFERENCES"), -}) diff --git a/src/assets/javascripts/youtube/get_piped_preferences.js b/src/assets/javascripts/youtube/get_piped_preferences.js deleted file mode 100644 index 388ecd19..00000000 --- a/src/assets/javascripts/youtube/get_piped_preferences.js +++ /dev/null @@ -1,22 +0,0 @@ -window.browser = window.browser || window.chrome - -browser.storage.local.set({ - piped_bufferGoal: localStorage.getItem("bufferGoal"), - piped_comments: localStorage.getItem("comments"), - piped_disableLBRY: localStorage.getItem("disableLBRY"), - piped_enabledCodecs: localStorage.getItem("enabledCodecs"), - piped_hl: localStorage.getItem("hl"), - piped_homepage: localStorage.getItem("homepage"), - piped_instance: localStorage.getItem("instance"), - piped_listen: localStorage.getItem("listen"), - piped_minimizeDescription: localStorage.getItem("minimizeDescription"), - piped_playerAutoPlay: localStorage.getItem("playerAutoPlay"), - piped_proxyLBRY: localStorage.getItem("proxyLBRY"), - piped_quality: localStorage.getItem("quality"), - piped_region: localStorage.getItem("region"), - piped_selectedSkip: localStorage.getItem("selectedSkip"), - piped_sponsorblock: localStorage.getItem("sponsorblock"), - piped_theme: localStorage.getItem("theme"), - piped_volume: localStorage.getItem("volume"), - piped_watchHistory: localStorage.getItem("watchHistory"), -}) diff --git a/src/assets/javascripts/youtube/set_pipedMaterial_preferences.js b/src/assets/javascripts/youtube/set_pipedMaterial_preferences.js deleted file mode 100644 index 59d6dcc4..00000000 --- a/src/assets/javascripts/youtube/set_pipedMaterial_preferences.js +++ /dev/null @@ -1,7 +0,0 @@ -window.browser = window.browser || window.chrome - -browser.storage.local.get("pipedMaterial_PREFERENCES", r => { - if (r.pipedMaterial_PREFERENCES !== undefined) localStorage.setItem("PREFERENCES", r.pipedMaterial_PREFERENCES) - - window.close() -}) diff --git a/src/assets/javascripts/youtube/set_piped_preferences.js b/src/assets/javascripts/youtube/set_piped_preferences.js deleted file mode 100644 index 374f2d61..00000000 --- a/src/assets/javascripts/youtube/set_piped_preferences.js +++ /dev/null @@ -1,45 +0,0 @@ -window.browser = window.browser || window.chrome - -browser.storage.local.get( - [ - "piped_bufferGoal", - "piped_comments", - "piped_disableLBRY", - "piped_enabledCodecs", - "piped_homepage", - "piped_instance", - "piped_listen", - "piped_minimizeDescription", - "piped_playerAutoPlay", - "piped_proxyLBRY", - "piped_quality", - "piped_region", - "piped_selectedSkip", - "piped_sponsorblock", - "piped_theme", - "piped_volume", - "piped_watchHistory", - ], - r => { - if (r.piped_bufferGoal !== undefined) localStorage.setItem("bufferGoal", r.piped_bufferGoal) - if (r.piped_comments !== undefined) localStorage.setItem("comments", r.piped_comments) - if (r.piped_disableLBRY !== undefined) localStorage.setItem("disableLBRY", r.piped_disableLBRY) - if (r.piped_hl !== undefined) localStorage.setItem("hl", r.piped_hl) - if (r.piped_enabledCodecs !== undefined) localStorage.setItem("enabledCodecs", r.piped_enabledCodecs) - if (r.piped_homepage !== undefined) localStorage.setItem("homepage", r.piped_homepage) - if (r.piped_instance !== undefined) localStorage.setItem("instance", r.piped_instance) - if (r.piped_listen !== undefined) localStorage.setItem("listen", r.piped_listen) - if (r.piped_minimizeDescription !== undefined) localStorage.setItem("minimizeDescription", r.piped_minimizeDescription) - if (r.piped_playerAutoPlay !== undefined) localStorage.setItem("playerAutoPlay", r.piped_playerAutoPlay) - if (r.piped_proxyLBRY !== undefined) localStorage.setItem("proxyLBRY", r.piped_proxyLBRY) - if (r.piped_quality !== undefined) localStorage.setItem("quality", r.piped_quality) - if (r.piped_region !== undefined) localStorage.setItem("region", r.piped_region) - if (r.piped_selectedSkip !== undefined) localStorage.setItem("selectedSkip", r.piped_selectedSkip) - if (r.piped_sponsorblock !== undefined) localStorage.setItem("sponsorblock", r.piped_sponsorblock) - if (r.piped_theme !== undefined) localStorage.setItem("theme", r.piped_theme) - if (r.piped_volume !== undefined) localStorage.setItem("volume", r.piped_volume) - if (r.piped_watchHistory !== undefined) localStorage.setItem("watchHistory", r.piped_watchHistory) - - window.close() - } -) diff --git a/src/assets/javascripts/youtube/youtube.js b/src/assets/javascripts/youtube/youtube.js deleted file mode 100644 index 32f06b9c..00000000 --- a/src/assets/javascripts/youtube/youtube.js +++ /dev/null @@ -1,792 +0,0 @@ -"use strict" - -window.browser = window.browser || window.chrome - -import utils from "../utils.js" - -const targets = [ - /^https?:\/{2}(www\.|music\.|m\.|)youtube\.com(\/.*|$)/, - - /^https?:\/{2}img\.youtube\.com\/vi\/.*\/..*/, // https://stackoverflow.com/questions/2068344/how-do-i-get-a-youtube-video-thumbnail-from-the-youtube-api - /^https?:\/{2}(i|s)\.ytimg\.com\/vi\/.*\/..*/, - - /^https?:\/{2}(www\.|music\.|)youtube\.com\/watch\?v\=..*/, - - /^https?:\/{2}youtu\.be\/..*/, - - /^https?:\/{2}(www\.|)(youtube|youtube-nocookie)\.com\/embed\/..*/, -] - -const frontends = new Array("invidious", "piped", "pipedMaterial", "cloudtube") -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", "offlineBlackList"], r => { - redirects = val - invidiousNormalRedirectsChecks = [...redirects.invidious.normal] - pipedNormalRedirectsChecks = [...redirects.piped.normal] - pipedMaterialNormalRedirectsChecks = [...redirects.pipedMaterial.normal] - cloudtubeNormalRedirectsChecks = [...redirects.cloudtube.normal] - for (const instance of [...r.cloudflareBlackList, ...r.offlineBlackList]) { - const a = invidiousNormalRedirectsChecks.indexOf(instance) - if (a > -1) invidiousNormalRedirectsChecks.splice(a, 1) - - const b = pipedNormalRedirectsChecks.indexOf(instance) - if (b > -1) pipedNormalRedirectsChecks.splice(b, 1) - - const c = pipedMaterialNormalRedirectsChecks.indexOf(instance) - if (c > -1) pipedMaterialNormalRedirectsChecks.splice(c, 1) - - const d = cloudtubeNormalRedirectsChecks.indexOf(instance) - if (c > -1) cloudtubeNormalRedirectsChecks.splice(d, 1) - } - browser.storage.local.set({ - youtubeRedirects: redirects, - invidiousNormalRedirectsChecks, - invidiousTorRedirectsChecks: [...redirects.invidious.tor], - invidiousI2pRedirectsChecks: [...redirects.invidious.i2p], - invidiousLokiRedirectsChecks: [...redirects.invidious.loki], - pipedNormalRedirectsChecks, - pipedTorRedirectsChecks: [...redirects.piped.tor], - pipedI2pRedirectsChecks: [...redirects.piped.i2p], - pipedLokiRedirectsChecks: [...redirects.piped.loki], - pipedMaterialNormalRedirectsChecks, - pipedMaterialTorRedirectsChecks: [...redirects.pipedMaterial.tor], - pipedMaterialI2pRedirectsChecks: [...redirects.pipedMaterial.i2p], - pipedMaterialLokiRedirectsChecks: [...redirects.pipedMaterial.loki], - cloudtubeNormalRedirectsChecks, - cloudtubeTorRedirectsChecks: [...redirects.cloudtube.tor], - cloudtubeI2pRedirectsChecks: [...redirects.cloudtube.i2p], - cloudtubeLokiRedirectsChecks: [...redirects.cloudtube.loki], - }) - }) -} - -let disableYoutube, - onlyEmbeddedVideo, - youtubeFrontend, - protocol, - protocolFallback, - youtubeEmbedFrontend, - youtubeRedirects, - invidiousNormalRedirectsChecks, - invidiousNormalCustomRedirects, - invidiousTorRedirectsChecks, - invidiousTorCustomRedirects, - invidiousI2pRedirectsChecks, - invidiousI2pCustomRedirects, - invidiousLokiRedirectsChecks, - invidiousLokiCustomRedirects, - pipedNormalRedirectsChecks, - pipedNormalCustomRedirects, - pipedTorRedirectsChecks, - pipedTorCustomRedirects, - pipedI2pRedirectsChecks, - pipedI2pCustomRedirects, - pipedLokiRedirectsChecks, - pipedLokiCustomRedirects, - pipedMaterialNormalRedirectsChecks, - pipedMaterialNormalCustomRedirects, - pipedMaterialTorRedirectsChecks, - pipedMaterialTorCustomRedirects, - pipedMaterialI2pRedirectsChecks, - pipedMaterialI2pCustomRedirects, - pipedMaterialLokiRedirectsChecks, - pipedMaterialLokiCustomRedirects, - cloudtubeNormalRedirectsChecks, - cloudtubeNormalCustomRedirects, - cloudtubeTorRedirectsChecks, - cloudtubeTorCustomRedirects, - cloudtubeI2pRedirectsChecks, - cloudtubeI2pCustomRedirects, - cloudtubeLokiRedirectsChecks, - cloudtubeLokiCustomRedirects - -function init() { - return new Promise(resolve => { - browser.storage.local.get( - [ - "disableYoutube", - "onlyEmbeddedVideo", - "youtubeFrontend", - "protocol", - "protocolFallback", - "youtubeEmbedFrontend", - "youtubeRedirects", - "invidiousNormalRedirectsChecks", - "invidiousNormalCustomRedirects", - "invidiousTorRedirectsChecks", - "invidiousTorCustomRedirects", - "invidiousI2pRedirectsChecks", - "invidiousI2pCustomRedirects", - "invidiousLokiRedirectsChecks", - "invidiousLokiCustomRedirects", - "pipedNormalRedirectsChecks", - "pipedNormalCustomRedirects", - "pipedTorRedirectsChecks", - "pipedTorCustomRedirects", - "pipedI2pRedirectsChecks", - "pipedI2pCustomRedirects", - "pipedLokiRedirectsChecks", - "pipedLokiCustomRedirects", - "pipedMaterialNormalRedirectsChecks", - "pipedMaterialNormalCustomRedirects", - "pipedMaterialTorRedirectsChecks", - "pipedMaterialTorCustomRedirects", - "pipedMaterialI2pRedirectsChecks", - "pipedMaterialI2pCustomRedirects", - "pipedMaterialLokiRedirectsChecks", - "pipedMaterialLokiCustomRedirects", - "cloudtubeNormalRedirectsChecks", - "cloudtubeNormalCustomRedirects", - "cloudtubeTorRedirectsChecks", - "cloudtubeTorCustomRedirects", - "cloudtubeI2pRedirectsChecks", - "cloudtubeI2pCustomRedirects", - "cloudtubeLokiRedirectsChecks", - "cloudtubeLokiCustomRedirects", - ], - r => { - disableYoutube = r.disableYoutube - onlyEmbeddedVideo = r.onlyEmbeddedVideo - youtubeFrontend = r.youtubeFrontend - protocol = r.protocol - protocolFallback = r.protocolFallback - youtubeEmbedFrontend = r.youtubeEmbedFrontend - youtubeRedirects = r.youtubeRedirects - invidiousNormalRedirectsChecks = r.invidiousNormalRedirectsChecks - invidiousNormalCustomRedirects = r.invidiousNormalCustomRedirects - invidiousTorRedirectsChecks = r.invidiousTorRedirectsChecks - invidiousTorCustomRedirects = r.invidiousTorCustomRedirects - invidiousI2pRedirectsChecks = r.invidiousI2pRedirectsChecks - invidiousI2pCustomRedirects = r.invidiousI2pCustomRedirects - invidiousLokiRedirectsChecks = r.invidiousLokiRedirectsChecks - invidiousLokiCustomRedirects = r.invidiousLokiCustomRedirects - pipedNormalRedirectsChecks = r.pipedNormalRedirectsChecks - pipedNormalCustomRedirects = r.pipedNormalCustomRedirects - pipedTorRedirectsChecks = r.pipedTorRedirectsChecks - pipedTorCustomRedirects = r.pipedTorCustomRedirects - pipedI2pRedirectsChecks = r.pipedI2pRedirectsChecks - pipedI2pCustomRedirects = r.pipedI2pCustomRedirects - pipedLokiRedirectsChecks = r.pipedLokiRedirectsChecks - pipedLokiCustomRedirects = r.pipedLokiCustomRedirects - pipedMaterialNormalRedirectsChecks = r.pipedMaterialNormalRedirectsChecks - pipedMaterialNormalCustomRedirects = r.pipedMaterialNormalCustomRedirects - pipedMaterialTorRedirectsChecks = r.pipedMaterialTorRedirectsChecks - pipedMaterialTorCustomRedirects = r.pipedMaterialTorCustomRedirects - pipedMaterialI2pRedirectsChecks = r.pipedMaterialI2pRedirectsChecks - pipedMaterialI2pCustomRedirects = r.pipedMaterialI2pCustomRedirects - pipedMaterialLokiRedirectsChecks = r.pipedMaterialLokiRedirectsChecks - pipedMaterialLokiCustomRedirects = r.pipedMaterialLokiCustomRedirects - cloudtubeNormalRedirectsChecks = r.cloudtubeNormalRedirectsChecks - cloudtubeNormalCustomRedirects = r.cloudtubeNormalCustomRedirects - cloudtubeTorRedirectsChecks = r.cloudtubeTorRedirectsChecks - cloudtubeTorCustomRedirects = r.cloudtubeTorCustomRedirects - cloudtubeI2pRedirectsChecks = r.cloudtubeI2pRedirectsChecks - cloudtubeI2pCustomRedirects = r.cloudtubeI2pCustomRedirects - cloudtubeLokiRedirectsChecks = r.cloudtubeLokiRedirectsChecks - cloudtubeLokiCustomRedirects = r.cloudtubeLokiCustomRedirects - resolve() - } - ) - }) -} - -init() -browser.storage.onChanged.addListener(init) - -function all() { - return [ - ...youtubeRedirects.invidious.normal, - ...youtubeRedirects.invidious.tor, - ...youtubeRedirects.invidious.i2p, - ...youtubeRedirects.invidious.loki, - - ...youtubeRedirects.piped.normal, - ...youtubeRedirects.piped.tor, - ...youtubeRedirects.piped.i2p, - ...youtubeRedirects.piped.loki, - - ...youtubeRedirects.pipedMaterial.normal, - ...youtubeRedirects.pipedMaterial.tor, - ...youtubeRedirects.pipedMaterial.i2p, - ...youtubeRedirects.pipedMaterial.loki, - - ...youtubeRedirects.cloudtube.normal, - ...youtubeRedirects.cloudtube.tor, - ...youtubeRedirects.cloudtube.i2p, - ...youtubeRedirects.cloudtube.loki, - - ...invidiousNormalCustomRedirects, - ...invidiousTorCustomRedirects, - ...invidiousI2pCustomRedirects, - ...invidiousLokiCustomRedirects, - - ...pipedNormalCustomRedirects, - ...pipedTorCustomRedirects, - ...pipedI2pCustomRedirects, - ...pipedLokiCustomRedirects, - - ...pipedMaterialNormalCustomRedirects, - ...pipedMaterialTorCustomRedirects, - ...pipedMaterialI2pCustomRedirects, - ...pipedMaterialLokiCustomRedirects, - - ...cloudtubeNormalCustomRedirects, - ...cloudtubeTorCustomRedirects, - ...cloudtubeI2pCustomRedirects, - ...cloudtubeLokiCustomRedirects, - ] -} - -function calculateFrontend(type) { - switch (type) { - case "main_frame": - return youtubeFrontend - case "sub_frame": - return youtubeEmbedFrontend - } -} - -function getInstanceList(type) { - let instancesList = [] - switch (calculateFrontend(type)) { - case "invidious": - switch (protocol) { - case "loki": - instancesList = [...invidiousLokiRedirectsChecks, ...invidiousLokiCustomRedirects] - break - case "i2p": - instancesList = [...invidiousI2pRedirectsChecks, ...invidiousI2pCustomRedirects] - break - case "tor": - instancesList = [...invidiousTorRedirectsChecks, ...invidiousTorCustomRedirects] - } - if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") { - instancesList = [...invidiousNormalRedirectsChecks, ...invidiousNormalCustomRedirects] - } - break - case "piped": - switch (protocol) { - case "loki": - instancesList = [...pipedLokiRedirectsChecks, ...pipedLokiCustomRedirects] - break - case "i2p": - instancesList = [...pipedI2pRedirectsChecks, ...pipedI2pCustomRedirects] - break - case "tor": - instancesList = [...pipedTorRedirectsChecks, ...pipedTorCustomRedirects] - } - if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") { - instancesList = [...pipedNormalRedirectsChecks, ...pipedNormalCustomRedirects] - } - break - case "pipedMaterial": - switch (protocol) { - case "loki": - instancesList = [...pipedMaterialLokiRedirectsChecks, ...pipedMaterialLokiCustomRedirects] - break - case "i2p": - instancesList = [...pipedMaterialI2pRedirectsChecks, ...pipedMaterialI2pCustomRedirects] - break - case "tor": - instancesList = [...pipedMaterialTorRedirectsChecks, ...pipedMaterialTorCustomRedirects] - } - if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") { - instancesList = [...pipedMaterialNormalRedirectsChecks, ...pipedMaterialNormalCustomRedirects] - } - case "cloudtube": - switch (protocol) { - case "loki": - instancesList = [...cloudtubeLokiRedirectsChecks, ...cloudtubeLokiCustomRedirects] - break - case "i2p": - instancesList = [...cloudtubeI2pRedirectsChecks, ...cloudtubeI2pCustomRedirects] - break - case "tor": - instancesList = [...cloudtubeTorRedirectsChecks, ...cloudtubeTorCustomRedirects] - } - if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") { - instancesList = [...cloudtubeNormalRedirectsChecks, ...cloudtubeNormalCustomRedirects] - } - } - return instancesList -} - -function redirect(url, type, initiator, disableOverride) { - if (disableYoutube && !disableOverride) return - if (!targets.some(rx => rx.test(url.href))) return - if (initiator && all().includes(initiator.origin)) return "BYPASSTAB" - - if (type != ("main_frame" || "sub_frame")) return - if (url.pathname.match(/iframe_api/) || url.pathname.match(/www-widgetapi/)) return // Don't redirect YouTube Player API. - if (onlyEmbeddedVideo == "onlyEmbedded" && type == "main_frame") return - if (onlyEmbeddedVideo == "onlyNotEmbedded" && type == "sub_frame") return - - if (type == "main_frame") { - switch (youtubeFrontend) { - case "yatte": - return url.href.replace(/^https?:\/{2}/, "yattee://") - case "freetube": - return `freetube://https://youtube.com${url.pathname}${url.search}` - } - } - - const instanceList = getInstanceList(type) - try { - if (instanceList.length >= 1) { - const randomInstance = utils.getRandomInstance(instanceList) - return `${randomInstance}${url.pathname}${url.search}` - } - } catch { - return - } -} - -function reverse(url) { - return new Promise(async resolve => { - await init() - const protocolHost = utils.protocolHost(url) - if (!all().includes(protocolHost)) { - resolve() - return - } - resolve(`https://youtube.com${url.pathname}${url.search}`) - }) -} - -function switchInstance(url, disableOverride) { - return new Promise(async resolve => { - await init() - if (disableYoutube && !disableOverride) { - resolve() - return - } - const protocolHost = utils.protocolHost(url) - if (!all().includes(protocolHost)) { - resolve() - return - } - - let instancesList = [] - switch (protocol) { - case "loki": - switch (youtubeFrontend) { - case "invidious": - instancesList = [...invidiousLokiRedirectsChecks, ...invidiousLokiCustomRedirects] - break - case "piped": - instancesList = [...pipedLokiRedirectsChecks, ...pipedLokiCustomRedirects] - break - case "pipedMaterial": - instancesList = [...pipedMaterialLokiRedirectsChecks, ...pipedMaterialLokiCustomRedirects] - break - case "cloudtube": - instancesList = [...cloudtubeLokiRedirectsChecks, ...cloudtubeLokiCustomRedirects] - } - break - case "i2p": - switch (youtubeFrontend) { - case "invidious": - instancesList = [...invidiousI2pRedirectsChecks, ...invidiousI2pCustomRedirects] - break - case "piped": - instancesList = [...pipedI2pRedirectsChecks, ...pipedI2pCustomRedirects] - break - case "pipedMaterial": - instancesList = [...pipedMaterialI2pRedirectsChecks, ...pipedMaterialI2pCustomRedirects] - break - case "cloudtube": - instancesList = [...cloudtubeI2pRedirectsChecks, ...cloudtubeI2pCustomRedirects] - } - break - case "tor": - switch (youtubeFrontend) { - case "invidious": - instancesList = [...invidiousTorRedirectsChecks, ...invidiousTorCustomRedirects] - break - case "piped": - instancesList = [...pipedTorRedirectsChecks, ...pipedTorCustomRedirects] - break - case "pipedMaterial": - instancesList = [...pipedMaterialTorRedirectsChecks, ...pipedMaterialTorCustomRedirects] - break - case "cloudtube": - instancesList = [...cloudtubeTorRedirectsChecks, ...cloudtubeTorCustomRedirects] - } - } - if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") { - switch (youtubeFrontend) { - case "invidious": - instancesList = [...invidiousNormalRedirectsChecks, ...invidiousNormalCustomRedirects] - break - case "piped": - instancesList = [...pipedNormalRedirectsChecks, ...pipedNormalCustomRedirects] - break - case "pipedMaterial": - instancesList = [...pipedMaterialNormalRedirectsChecks, ...pipedMaterialNormalCustomRedirects] - break - case "cloudtube": - instancesList = [...cloudtubeNormalRedirectsChecks, ...cloudtubeNormalCustomRedirects] - } - } - - const i = instancesList.indexOf(protocolHost) - if (i > -1) instancesList.splice(i, 1) - if (instancesList.length == 0) { - resolve() - return - } - - const randomInstance = utils.getRandomInstance(instancesList) - resolve(`${randomInstance}${url.pathname}${url.search}`) - }) -} - -function initDefaults() { - 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.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, ...r.offlineBlackList]) { - const a = invidiousNormalRedirectsChecks.indexOf(instance) - if (a > -1) invidiousNormalRedirectsChecks.splice(a, 1) - - const b = pipedNormalRedirectsChecks.indexOf(instance) - if (b > -1) pipedNormalRedirectsChecks.splice(b, 1) - - const c = pipedMaterialNormalRedirectsChecks.indexOf(instance) - if (c > -1) pipedMaterialNormalRedirectsChecks.splice(c, 1) - - const d = cloudtubeNormalRedirectsChecks.indexOf(instance) - if (c > -1) cloudtubeNormalRedirectsChecks.splice(d, 1) - } - browser.storage.local.set( - { - disableYoutube: false, - enableYoutubeCustomSettings: false, - onlyEmbeddedVideo: "both", - youtubeRedirects: redirects, - youtubeFrontend: "invidious", - - invidiousNormalRedirectsChecks, - invidiousNormalCustomRedirects: [], - - invidiousTorRedirectsChecks: [...redirects.invidious.tor], - invidiousTorCustomRedirects: [], - - invidiousI2pRedirectsChecks: [...redirects.invidious.i2p], - invidiousI2pCustomRedirects: [], - - invidiousLokiRedirectsChecks: [...redirects.invidious.loki], - invidiousLokiCustomRedirects: [], - - pipedNormalRedirectsChecks, - pipedNormalCustomRedirects: [], - - pipedTorRedirectsChecks: [...redirects.piped.tor], - pipedTorCustomRedirects: [], - - pipedI2pRedirectsChecks: [...redirects.piped.i2p], - pipedI2pCustomRedirects: [], - - pipedLokiRedirectsChecks: [...redirects.piped.loki], - pipedLokiCustomRedirects: [], - - pipedMaterialNormalRedirectsChecks: pipedMaterialNormalRedirectsChecks, - pipedMaterialNormalCustomRedirects: [], - - pipedMaterialTorRedirectsChecks: [...redirects.pipedMaterial.tor], - pipedMaterialTorCustomRedirects: [], - - pipedMaterialI2pRedirectsChecks: [...redirects.pipedMaterial.i2p], - pipedMaterialI2pCustomRedirects: [], - - pipedMaterialLokiRedirectsChecks: [...redirects.pipedMaterial.loki], - pipedMaterialLokiCustomRedirects: [], - - cloudtubeNormalRedirectsChecks: cloudtubeNormalRedirectsChecks, - cloudtubeNormalCustomRedirects: [], - - cloudtubeTorRedirectsChecks: [...redirects.cloudtube.tor], - cloudtubeTorCustomRedirects: [], - - cloudtubeI2pRedirectsChecks: [...redirects.cloudtube.i2p], - cloudtubeI2pCustomRedirects: [], - - cloudtubeLokiRedirectsChecks: [...redirects.cloudtube.loki], - cloudtubeLokiCustomRedirects: [], - - youtubeEmbedFrontend: "invidious", - }, - () => resolve() - ) - }) - }) - }) -} - -function copyPasteInvidiousCookies(test, from) { - return new Promise(async resolve => { - await init() - if (disableYoutube || youtubeFrontend != "invidious") { - resolve() - return - } - const protocolHost = utils.protocolHost(from) - if ( - ![ - ...invidiousNormalRedirectsChecks, - ...invidiousTorRedirectsChecks, - ...invidiousNormalCustomRedirects, - ...invidiousTorCustomRedirects, - ...invidiousI2pCustomRedirects, - ...invidiousLokiCustomRedirects, - ].includes(protocolHost) - ) { - resolve() - return - } - if (!test) { - let checkedInstances = [] - - if (protocol == "loki") checkedInstances = [...invidiousLokiCustomRedirects] - else if (protocol == "i2p") checkedInstances = [...invidiousI2pCustomRedirects] - else if (protocol == "tor") checkedInstances = [...invidiousTorRedirectsChecks, ...invidiousTorCustomRedirects] - if ((checkedInstances.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") - } - resolve(true) - }) -} - -function copyPastePipedLocalStorage(test, url, tabId) { - return new Promise(async resolve => { - await init() - if (disableYoutube || youtubeFrontend != "piped") { - resolve() - return - } - const protocolHost = utils.protocolHost(url) - if ( - ![...pipedNormalCustomRedirects, ...pipedNormalRedirectsChecks, ...pipedTorRedirectsChecks, ...pipedTorCustomRedirects, ...pipedI2pCustomRedirects, ...pipedLokiCustomRedirects].includes( - protocolHost - ) - ) { - resolve() - return - } - - if (!test) { - browser.tabs.executeScript(tabId, { - file: "/assets/javascripts/youtube/get_piped_preferences.js", - runAt: "document_start", - }) - - let checkedInstances = [] - if (protocol == "loki") checkedInstances = [...pipedLokiCustomRedirects] - else if (protocol == "i2p") checkedInstances = [...pipedI2pCustomRedirects] - else if (protocol == "tor") checkedInstances = [...pipedTorRedirectsChecks, ...pipedTorCustomRedirects] - if ((checkedInstances.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) { - browser.tabs.create({ url: to }, tab => - browser.tabs.executeScript(tab.id, { - file: "/assets/javascripts/youtube/set_piped_preferences.js", - runAt: "document_start", - }) - ) - } - } - resolve(true) - }) -} - -function copyPastePipedMaterialLocalStorage(test, url, tabId) { - return new Promise(async resolve => { - await init() - if (disableYoutube || youtubeFrontend != "pipedMaterial") { - resolve() - return - } - const protocolHost = utils.protocolHost(url) - if ( - ![ - ...pipedMaterialNormalRedirectsChecks, - ...pipedMaterialNormalCustomRedirects, - //...pipedMaterialTorRedirectsChecks, - ...pipedMaterialTorCustomRedirects, - ...pipedMaterialI2pCustomRedirects, - ...pipedMaterialLokiCustomRedirects, - ].includes(protocolHost) - ) { - resolve() - return - } - - if (!test) { - browser.tabs.executeScript(tabId, { - file: "/assets/javascripts/youtube/get_pipedMaterial_preferences.js", - runAt: "document_start", - }) - - let checkedInstances = [] - if (protocol == "loki") checkedInstances = [...pipedMaterialLokiCustomRedirects] - else if (protocol == "i2p") checkedInstances = [...pipedMaterialI2pCustomRedirects] - else if (protocol == "tor") checkedInstances = [...pipedMaterialTorCustomRedirects] //...pipedMaterialTorRedirectsChecks, - 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) - browser.tabs.create({ url: to }, tab => - browser.tabs.executeScript(tab.id, { - file: "/assets/javascripts/youtube/set_pipedMaterial_preferences.js", - runAt: "document_start", - }) - ) - } - resolve(true) - }) -} - -function removeXFrameOptions(e) { - let isChanged = false - - if (e.type == "main_frame") { - for (const i in e.responseHeaders) { - if (e.responseHeaders[i].name == "content-security-policy") { - let instancesList = [] - switch (protocol) { - case "loki": - switch (youtubeFrontend) { - case "invidious": - instancesList = [...invidiousLokiRedirectsChecks, ...invidiousLokiCustomRedirects] - break - case "piped": - instancesList = [...pipedLokiRedirectsChecks, ...pipedLokiCustomRedirects] - break - case "pipedMaterial": - instancesList = [...pipedMaterialLokiRedirectsChecks, ...pipedMaterialLokiCustomRedirects] - break - case "cloudtube": - instancesList = [...cloudtubeLokiRedirectsChecks, ...cloudtubeLokiCustomRedirects] - } - break - case "i2p": - switch (youtubeFrontend) { - case "invidious": - instancesList = [...invidiousI2pRedirectsChecks, ...invidiousI2pCustomRedirects] - break - case "piped": - instancesList = [...pipedI2pRedirectsChecks, ...pipedI2pCustomRedirects] - break - case "pipedMaterial": - instancesList = [...pipedMaterialI2pRedirectsChecks, ...pipedMaterialI2pCustomRedirects] - break - case "cloudtube": - instancesList = [...cloudtubeI2pRedirectsChecks, ...cloudtubeI2pCustomRedirects] - } - break - case "tor": - switch (youtubeFrontend) { - case "invidious": - instancesList = [...invidiousTorRedirectsChecks, ...invidiousTorCustomRedirects] - break - case "piped": - instancesList = [...pipedTorRedirectsChecks, ...pipedTorCustomRedirects] - break - case "pipedMaterial": - instancesList = [...pipedMaterialTorRedirectsChecks, ...pipedMaterialTorCustomRedirects] - break - case "cloudtube": - instancesList = [...cloudtubeTorRedirectsChecks, ...cloudtubeTorCustomRedirects] - } - } - if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") { - switch (youtubeFrontend) { - case "invidious": - instancesList = [...invidiousNormalRedirectsChecks, ...invidiousNormalCustomRedirects] - break - case "piped": - instancesList = [...pipedNormalRedirectsChecks, ...pipedNormalCustomRedirects] - break - case "pipedMaterial": - instancesList = [...pipedMaterialNormalRedirectsChecks, ...pipedMaterialNormalCustomRedirects] - break - case "cloudtube": - instancesList = [...cloudtubeNormalRedirectsChecks, ...cloudtubeNormalCustomRedirects] - } - } - let securityPolicyList = e.responseHeaders[i].value.split(";") - for (const i in securityPolicyList) securityPolicyList[i] = securityPolicyList[i].trim() - - let newSecurity = "" - for (const item of securityPolicyList) { - if (item.trim() == "") continue - let regex = item.match(/([a-z-]{0,}) (.*)/) - if (regex == null) continue - let [, key, vals] = regex - if (key == "frame-src") vals = vals + " " + instancesList.join(" ") - newSecurity += key + " " + vals + "; " - } - - e.responseHeaders[i].value = newSecurity - isChanged = true - } - } - } else if (e.type == "sub_frame") { - const url = new URL(e.url) - const protocolHost = utils.protocolHost(url) - if (all().includes(protocolHost)) { - for (const i in e.responseHeaders) { - if (e.responseHeaders[i].name == "x-frame-options") { - e.responseHeaders.splice(i, 1) - isChanged = true - } else if (e.responseHeaders[i].name == "content-security-policy") { - e.responseHeaders.splice(i, 1) - isChanged = true - } - } - } - } - if (isChanged) return { responseHeaders: e.responseHeaders } -} - -export default { - setRedirects, - copyPastePipedLocalStorage, - copyPastePipedMaterialLocalStorage, - copyPasteInvidiousCookies, - redirect, - reverse, - switchInstance, - initDefaults, - removeXFrameOptions, -} diff --git a/src/assets/javascripts/youtubeMusic.js b/src/assets/javascripts/youtubeMusic.js deleted file mode 100644 index 797da4d5..00000000 --- a/src/assets/javascripts/youtubeMusic.js +++ /dev/null @@ -1,327 +0,0 @@ -"use strict" - -import utils from "./utils.js" - -window.browser = window.browser || window.chrome - -const targets = [/^https?:\/{2}music\.youtube\.com(\/.*|$)/] - -const frontends = new Array("beatbump", "hyperpipe") -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", "offlineBlackList"], r => { - redirects = val - 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({ - youtubeMusicRedirects: redirects, - beatbumpNormalRedirectsChecks, - beatbumpTorRedirectsChecks: [...redirects.beatbump.tor], - beatbumpI2pRedirectsChecks: [...redirects.beatbump.i2p], - beatbumpLokiRedirectsChecks: [...redirects.beatbump.loki], - hyperpipeNormalRedirectsChecks, - hyperpipeTorRedirectsChecks: [...redirects.hyperpipe.tor], - hyperpipeI2pRedirectsChecks: [...redirects.hyperpipe.i2p], - hyperpipeLokiRedirectsChecks: [...redirects.hyperpipe.loki], - }) - }) -} - -let disableYoutubeMusic, - youtubeMusicFrontend, - youtubeMusicRedirects, - protocol, - protocolFallback, - beatbumpNormalRedirectsChecks, - beatbumpNormalCustomRedirects, - beatbumpTorRedirectsChecks, - beatbumpTorCustomRedirects, - beatbumpI2pRedirectsChecks, - beatbumpI2pCustomRedirects, - beatbumpLokiRedirectsChecks, - beatbumpLokiCustomRedirects, - hyperpipeNormalRedirectsChecks, - hyperpipeNormalCustomRedirects, - hyperpipeTorRedirectsChecks, - hyperpipeTorCustomRedirects, - hyperpipeI2pRedirectsChecks, - hyperpipeI2pCustomRedirects, - hyperpipeLokiRedirectsChecks, - hyperpipeLokiCustomRedirects - -function init() { - return new Promise(async resolve => { - browser.storage.local.get( - [ - "disableYoutubeMusic", - "youtubeMusicFrontend", - "youtubeMusicRedirects", - "protocol", - "protocolFallback", - "beatbumpNormalRedirectsChecks", - "beatbumpNormalCustomRedirects", - "beatbumpTorRedirectsChecks", - "beatbumpTorCustomRedirects", - "beatbumpI2pRedirectsChecks", - "beatbumpI2pCustomRedirects", - "beatbumpLokiRedirectsChecks", - "beatbumpLokiCustomRedirects", - "hyperpipeNormalRedirectsChecks", - "hyperpipeNormalCustomRedirects", - "hyperpipeTorRedirectsChecks", - "hyperpipeTorCustomRedirects", - "hyperpipeI2pRedirectsChecks", - "hyperpipeI2pCustomRedirects", - "hyperpipeLokiRedirectsChecks", - "hyperpipeLokiCustomRedirects", - ], - r => { - disableYoutubeMusic = r.disableYoutubeMusic - youtubeMusicFrontend = r.youtubeMusicFrontend - youtubeMusicRedirects = r.youtubeMusicRedirects - protocol = r.protocol - protocolFallback = r.protocolFallback - beatbumpNormalRedirectsChecks = r.beatbumpNormalRedirectsChecks - beatbumpNormalCustomRedirects = r.beatbumpNormalCustomRedirects - beatbumpTorRedirectsChecks = r.beatbumpTorRedirectsChecks - beatbumpTorCustomRedirects = r.beatbumpTorCustomRedirects - beatbumpI2pRedirectsChecks = r.beatbumpI2pRedirectsChecks - beatbumpI2pCustomRedirects = r.beatbumpI2pCustomRedirects - beatbumpLokiRedirectsChecks = r.beatbumpLokiRedirectsChecks - beatbumpLokiCustomRedirects = r.beatbumpLokiCustomRedirects - hyperpipeNormalRedirectsChecks = r.hyperpipeNormalRedirectsChecks - hyperpipeNormalCustomRedirects = r.hyperpipeNormalCustomRedirects - hyperpipeTorRedirectsChecks = r.hyperpipeTorRedirectsChecks - hyperpipeTorCustomRedirects = r.hyperpipeTorCustomRedirects - hyperpipeI2pRedirectsChecks = r.hyperpipeI2pRedirectsChecks - hyperpipeI2pCustomRedirects = r.hyperpipeI2pCustomRedirects - hyperpipeLokiRedirectsChecks = r.hyperpipeLokiRedirectsChecks - hyperpipeLokiCustomRedirects = r.hyperpipeLokiCustomRedirects - resolve() - } - ) - }) -} - -init() -browser.storage.onChanged.addListener(init) - -function all() { - return [ - ...beatbumpNormalRedirectsChecks, - ...beatbumpNormalCustomRedirects, - ...beatbumpTorRedirectsChecks, - ...beatbumpTorCustomRedirects, - ...beatbumpI2pRedirectsChecks, - ...beatbumpI2pCustomRedirects, - ...beatbumpLokiRedirectsChecks, - ...beatbumpLokiCustomRedirects, - ...hyperpipeNormalRedirectsChecks, - ...hyperpipeNormalCustomRedirects, - ...hyperpipeTorRedirectsChecks, - ...hyperpipeTorCustomRedirects, - ...hyperpipeI2pRedirectsChecks, - ...hyperpipeI2pCustomRedirects, - ...hyperpipeLokiRedirectsChecks, - ...hyperpipeLokiCustomRedirects, - ] -} - -function getInstanceList() { - let tmpList = [] - switch (youtubeMusicFrontend) { - case "beatbump": - switch (protocol) { - case "loki": - tmpList = [...beatbumpLokiRedirectsChecks, ...beatbumpLokiCustomRedirects] - break - case "i2p": - tmpList = [...beatbumpI2pRedirectsChecks, ...beatbumpI2pCustomRedirects] - break - case "tor": - tmpList = [...beatbumpTorRedirectsChecks, ...beatbumpTorCustomRedirects] - } - if ((tmpList.length === 0 && protocolFallback) || protocol == "normal") { - tmpList = [...beatbumpNormalRedirectsChecks, ...beatbumpNormalCustomRedirects] - } - break - case "hyperpipe": - switch (protocol) { - case "loki": - tmpList = [...hyperpipeLokiRedirectsChecks, ...hyperpipeLokiCustomRedirects] - break - case "i2p": - tmpList = [...hyperpipeI2pRedirectsChecks, ...hyperpipeI2pCustomRedirects] - break - case "tor": - tmpList = [...hyperpipeTorRedirectsChecks, ...hyperpipeTorCustomRedirects] - } - if ((tmpList.length === 0 && protocolFallback) || protocol == "normal") { - tmpList = [...hyperpipeNormalRedirectsChecks, ...hyperpipeNormalCustomRedirects] - } - } - return tmpList -} - -function getUrl(randomInstance, url) { - switch (youtubeMusicFrontend) { - case "beatbump": - return `${randomInstance}${url.pathname}${url.search}` - .replace("/watch?v=", "/listen?id=") - .replace("/channel/", "/artist/") - .replace("/playlist?list=", "/playlist/VL") - .replace(/\/search\?q=.*/, searchQuery => searchQuery.replace("?q=", "/") + "?filter=EgWKAQIIAWoKEAMQBBAKEAkQBQ%3D%3D") - case "hyperpipe": - return `${randomInstance}${url.pathname}${url.search}`.replace(/\/search\?q=.*/, searchQuery => searchQuery.replace("?q=", "/")) - } -} - -/* -Video -https://music.youtube.com/watch?v=_PkGiKBW-DA&list=RDAMVM_PkGiKBW-DA -https://beatbump.ml/listen?id=_PkGiKBW-DA&list=RDAMVM_PkGiKBW-DA - -Playlist -https://music.youtube.com/playlist?list=PLqxd0OMLeWy64zlwhjouj92ISc38FbOns -https://music.youtube.com/playlist?list=PLqxd0OMLeWy7lrJSzt9LnOJjbC1IaruPM -https://music.youtube.com/playlist?list=PLQod4DlD72ZMJmOrSNbmEmK_iZ1oXPzKd -https://beatbump.ml/playlist/VLPLqxd0OMLeWy64zlwhjouj92ISc38FbOns - -Channel -https://music.youtube.com/channel/UCfgmMDI7T5tOQqjnOBRe_wg -https://beatbump.ml/artist/UCfgmMDI7T5tOQqjnOBRe_wg - -Albums -https://music.youtube.com/playlist?list=OLAK5uy_n-9HVh3cryV2gREZM9Sc0JwEKYjjfi0dU -https://music.youtube.com/playlist?list=OLAK5uy_lcr5O1zS8f6WIFI_yxqVp2RK9Dyy2bbw0 -https://beatbump.ml/release?id=MPREb_3DURc4yEUtD -https://beatbump.ml/release?id=MPREb_evaZrV1WNdS - -https://music.youtube.com/playlist?list=OLAK5uy_n6OHVllUZUCnlIY1m-gUaH8uqkN3Y-Ca8 -https://music.youtube.com/playlist?list=OLAK5uy_nBOTxAc3_RGB82-Z54jdARGxGaCYlpngY -https://beatbump.ml/release?id=MPREb_QygdC0wEoLe - -https://music.youtube.com/watch?v=R6gSMSYKhKU&list=OLAK5uy_n-9HVh3cryV2gREZM9Sc0JwEKYjjfi0dU - -Search -https://music.youtube.com/search?q=test -https://beatbump.ml/search/test?filter=EgWKAQIIAWoKEAMQBBAKEAkQBQ%3D%3D - -*/ -function redirect(url, type, initiator, disableOverride) { - if (disableYoutubeMusic && !disableOverride) return - if (!targets.some(rx => rx.test(url.href))) return - - let instancesList = getInstanceList() - - if (instancesList.length === 0) return - const randomInstance = utils.getRandomInstance(instancesList) - return getUrl(randomInstance, url) -} - -function switchInstance(url, disableOverride) { - return new Promise(async resolve => { - await init() - if (disableYoutubeMusic && !disableOverride) { - resolve() - return - } - const protocolHost = utils.protocolHost(url) - if (!all().includes(protocolHost)) { - resolve() - return - } - - let instancesList = getInstanceList() - - const i = instancesList.indexOf(protocolHost) - if (i > -1) instancesList.splice(i, 1) - if (instancesList.length === 0) { - resolve() - return - } - - const randomInstance = utils.getRandomInstance(instancesList) - return getUrl(randomInstance, url) - }) -} - -function initDefaults() { - return new Promise(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.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, - beatbumpNormalCustomRedirects: [], - - beatbumpTorRedirectsChecks: [...redirects.beatbump.tor], - beatbumpTorCustomRedirects: [], - - beatbumpI2pRedirectsChecks: [...redirects.beatbump.i2p], - beatbumpI2pCustomRedirects: [], - - beatbumpLokiRedirectsChecks: [...redirects.beatbump.loki], - beatbumpLokiCustomRedirects: [], - - hyperpipeNormalRedirectsChecks, - hyperpipeNormalCustomRedirects: [], - - hyperpipeTorRedirectsChecks: [...redirects.hyperpipe.tor], - hyperpipeTorCustomRedirects: [], - - hyperpipeI2pRedirectsChecks: [...redirects.hyperpipe.i2p], - hyperpipeI2pCustomRedirects: [], - - hyperpipeLokiRedirectsChecks: [...redirects.hyperpipe.loki], - hyperpipeLokiCustomRedirects: [], - }, - () => resolve() - ) - }) - }) - }) -} - -export default { - setRedirects, - switchInstance, - redirect, - initDefaults, -} diff --git a/src/config/config.json b/src/config/config.json index 6f926034..e2b511b9 100644 --- a/src/config/config.json +++ b/src/config/config.json @@ -535,7 +535,7 @@ "instanceList": "true" } }, - "targets": ["^https?:\\/{2}send\\.libredirect\\.invalid\\/$", "^https?:\\/{2}send\\.firefox\\.com\\/$", "^https?:\\/{2}sendfiles\\.online\\/$"], + "targets": ["^https?:\\/{2}send\\.libredirect\\.invalid\\/?$", "^https?:\\/{2}send\\.firefox\\.com\\/?$", "^https?:\\/{2}sendfiles\\.online\\/?$"], "name": "Send Files", "options": { "enabled": true }, "imageType": "svgMono", diff --git a/src/instances/get_instances.py b/src/instances/get_instances.py index 3b773304..06b547b3 100644 --- a/src/instances/get_instances.py +++ b/src/instances/get_instances.py @@ -1,25 +1,26 @@ # Note: Run this script from the root of the repo +import traceback +import logging import requests import json from urllib.parse import urlparse import re -from colorama import Fore, Back, Style -from urllib.parse import urlparse +from colorama import Fore, Style import socket mightyList = {} config = {} -startRegex = "https?:\/{2}(?:[^\s\/]+\.)+" +startRegex = r"https?:\/{2}(?:[^\s\/]+\.)+" endRegex = "(?:\/[^\s\/]+)*\/?" torRegex = startRegex + "onion" + endRegex i2pRegex = startRegex + "i2p" + endRegex lokiRegex = startRegex + "loki" + endRegex -authRegex = "https?:\/{2}\S+:\S+@(?:[^\s\/]+\.)+[a-zA-Z0-9]+" + endRegex +authRegex = r"https?:\/{2}\S+:\S+@(?:[^\s\/]+\.)+[a-zA-Z0-9]+" + endRegex with open('./src/config/config.json', 'rt') as tmp: - config['networks'] = json.load(tmp)['config']['networks'] + config['networks'] = json.load(tmp)['networks'] def filterLastSlash(urlList): @@ -61,7 +62,7 @@ def is_cloudflare(url): instance_ip = socket.gethostbyname(urlparse(url).hostname) if instance_ip is None: return False - except: + except Exception: return False instance_bin = ip2bin(instance_ip) @@ -88,10 +89,11 @@ def is_authenticate(url): if 'www-authenticate' in r.headers: print(url + ' requires ' + Fore.RED + 'authentication' + Style.RESET_ALL) return True - except: + except Exception: return False return False + def is_offline(url): try: r = requests.get(url, timeout=5) @@ -102,21 +104,22 @@ def is_offline(url): return True else: return False - except: + except Exception: return False + def fetchCache(frontend, name): - # json_object = json.dumps(mightyList, ensure_ascii=False, indent=2) with open('./src/instances/data.json') as file: mightyList[frontend] = json.load(file)[frontend] print(Fore.YELLOW + 'Failed' + Style.RESET_ALL + ' to fetch ' + name) + def fetchFromFile(frontend, name): - #json_object = json.dumps(mightyList, ensure_ascii=False, indent=2) with open('./src/instances/' + frontend + '.json') as file: mightyList[frontend] = json.load(file) print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + name) + def fetchJsonList(frontend, name, url, urlItem): try: r = requests.get(url) @@ -127,13 +130,13 @@ def fetchJsonList(frontend, name, url, urlItem): if type(urlItem) == dict: for item in rJson: for network in config['networks']: - if urlItem[network] != None: + if urlItem[network] is not None: if urlItem[network] in item: if item[urlItem[network]].strip() != '': _list[network].append(item[urlItem[network]]) else: if frontend == 'librarian': - rJson = rJson['instances'] # I got lazy :p Might fix this at some point... + rJson = rJson['instances'] # I got lazy :p Might fix this at some point... for item in rJson: tmpItem = item if urlItem is not None: @@ -151,18 +154,20 @@ def fetchJsonList(frontend, name, url, urlItem): mightyList[frontend] = _list print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + name) - except: + except Exception: fetchCache(frontend, name) + logging.error(traceback.format_exc()) + -def fetchRegexList(frontend, name, url, regex): +def fetchRegexList(frontend, name, url, regex): try: r = requests.get(url) _list = {} for network in config['networks']: _list[network] = [] - + tmp = re.findall(regex, r.text) - + for item in tmp: if item.strip() == "": continue @@ -176,8 +181,10 @@ def fetchRegexList(frontend, name, url, regex): _list['clearnet'].append(item) mightyList[frontend] = _list print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + name) - except: + except Exception: fetchCache(frontend, name) + logging.error(traceback.format_exc()) + def fetchTextList(frontend, name, url, prepend): try: @@ -200,8 +207,9 @@ def fetchTextList(frontend, name, url, prepend): _list['clearnet'].append(item) mightyList[frontend] = _list print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + name) - except: + except Exception: fetchCache(frontend, name) + logging.error(traceback.format_exc()) def invidious(): @@ -223,8 +231,9 @@ def invidious(): _list['tor'].append(instance[1]['uri']) mightyList[frontend] = _list print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + name) - except: + except Exception: fetchCache(frontend, name) + logging.error(traceback.format_exc()) def piped(): @@ -240,7 +249,7 @@ def piped(): 'https://raw.githubusercontent.com/wiki/TeamPiped/Piped/Instances.md') tmp = re.findall( - '(?:[^\s\/]+\.)+[a-zA-Z]+ (?:\(Official\) )?\| (https:\/{2}(?:[^\s\/]+\.)+[a-zA-Z]+) \| ', r.text) + r'(?:[^\s\/]+\.)+[a-zA-Z]+ (?:\(Official\) )?\| (https:\/{2}(?:[^\s\/]+\.)+[a-zA-Z]+) \| ', r.text) for item in tmp: try: url = requests.get(item, timeout=5).url @@ -248,12 +257,14 @@ def piped(): continue else: _list['clearnet'].append(url) - except: + except Exception: + logging.error(traceback.format_exc()) continue mightyList[frontend] = _list print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + name) - except: + except Exception: fetchCache(frontend, name) + logging.error(traceback.format_exc()) def pipedMaterial(): @@ -265,20 +276,7 @@ def cloudtube(): def proxitok(): - r = requests.get( - 'https://raw.githubusercontent.com/wiki/pablouser1/ProxiTok/Public-instances.md') - - tmp = re.findall( - r"\| \[.*\]\(([-a-zA-Z0-9@:%_\+.~#?&//=]{2,}\.[a-z]{2,}\b(?:\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?)\)*\|*[A-Z]{0,}.*\|.*\|", r.text) - proxiTokList = {} - proxiTokList['clearnet'] = [] - proxiTokList['tor'] = [] - proxiTokList['i2p'] = [] - proxiTokList['loki'] = [] - for item in tmp: - proxiTokList['clearnet'].append(re.sub(r'/$', '', item)) - mightyList['proxiTok'] = proxiTokList - print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'ProxiTok') + fetchRegexList('proxiTok', 'ProxiTok', 'https://raw.githubusercontent.com/wiki/pablouser1/ProxiTok/Public-instances.md', r"\| \[.*\]\(([-a-zA-Z0-9@:%_\+.~#?&//=]{2,}\.[a-z]{2,}\b(?:\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?)\)(?: \(Official\))? +\|(?:(?: [A-Z]*.*\|.*\|)|(?:$))") def send(): @@ -298,11 +296,11 @@ def libreddit(): def teddit(): - fetchJsonList('teddit', 'Teddit', 'https://codeberg.org/teddit/teddit/raw/branch/main/instances.json', { 'clearnet': 'url', 'tor': 'onion', 'i2p': 'i2p', 'loki': None }) + fetchJsonList('teddit', 'Teddit', 'https://codeberg.org/teddit/teddit/raw/branch/main/instances.json', {'clearnet': 'url', 'tor': 'onion', 'i2p': 'i2p', 'loki': None}) def wikiless(): - fetchJsonList('wikiless', 'Wikiless', 'https://wikiless.org/instances.json', { 'clearnet': 'url', 'tor': 'onion', 'i2p': 'i2p', 'loki': None}) + fetchJsonList('wikiless', 'Wikiless', 'https://wikiless.org/instances.json', {'clearnet': 'url', 'tor': 'onion', 'i2p': 'i2p', 'loki': None}) def scribe(): @@ -401,6 +399,7 @@ def rimgo(): def librarian(): fetchJsonList('librarian', 'Librarian', 'https://codeberg.org/librarian/librarian/raw/branch/main/instances.json', 'url') + def neuters(): fetchFromFile('neuters', 'Neuters') @@ -434,7 +433,7 @@ def isValid(url): # This code is contributed by avanitrachhadiya2155 try: result = urlparse(url) return all([result.scheme, result.netloc]) - except: + except Exception: return False diff --git a/src/pages/options/widgets/general.js b/src/pages/options/widgets/general.js index 89d0b6b0..23ed73ee 100644 --- a/src/pages/options/widgets/general.js +++ b/src/pages/options/widgets/general.js @@ -37,7 +37,8 @@ function setOption(option, multiChoice, event) { browser.storage.local.get("options", r => { let options = r.options if (multiChoice) { - options[option] = event.target.options[[option].selectedIndex].value + console.log(event.target.options) + options[option] = event.target.options[event.target.options.selectedIndex].value } else { options[option] = event.target.checked } diff --git a/src/pages/options/widgets/services.js b/src/pages/options/widgets/services.js index d709a05b..873950f3 100644 --- a/src/pages/options/widgets/services.js +++ b/src/pages/options/widgets/services.js @@ -87,7 +87,7 @@ for (const service in config.services) { divs[service][option].addEventListener("change", () => { if (typeof config.services[service].options[option] == "boolean") options[service][option] = divs[service][option].checked else options[service][option] = divs[service][option].value - browser.local.storage.set({ options }) + browser.storage.local.set({ options }) changeFrontendsSettings(service) }) } -- cgit 1.4.1 From c1af086c2756f401d8403b259e29f1354c5e001f Mon Sep 17 00:00:00 2001 From: Hygna Date: Mon, 3 Oct 2022 06:44:49 +0100 Subject: Finished options upgrading --- src/_locales/filter.py | 8 - src/assets/images/sendFiles-icon.svg | 3 + src/assets/images/uploadFiles-icon.svg | 3 - src/assets/javascripts/services.js | 277 +++++++++++++++++---------------- src/assets/javascripts/utils.js | 8 +- src/config/config.json | 5 +- src/instances/get_instances.py | 1 + src/pages/options/index.html | 17 +- src/pages/options/widgets/general.js | 25 ++- src/pages/popup/popup.html | 12 +- src/pages/popup/popup.js | 6 +- 11 files changed, 190 insertions(+), 175 deletions(-) create mode 100644 src/assets/images/sendFiles-icon.svg delete mode 100644 src/assets/images/uploadFiles-icon.svg (limited to 'src/instances') diff --git a/src/_locales/filter.py b/src/_locales/filter.py index 581bb36c..0d5fb44d 100644 --- a/src/_locales/filter.py +++ b/src/_locales/filter.py @@ -1,12 +1,4 @@ -import requests import json -from urllib.parse import urlparse -from bs4 import BeautifulSoup -import re -from colorama import Fore, Back, Style -from urllib.parse import urlparse -import socket -import subprocess ar_json = {} diff --git a/src/assets/images/sendFiles-icon.svg b/src/assets/images/sendFiles-icon.svg new file mode 100644 index 00000000..5557664e --- /dev/null +++ b/src/assets/images/sendFiles-icon.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/assets/images/uploadFiles-icon.svg b/src/assets/images/uploadFiles-icon.svg deleted file mode 100644 index 5557664e..00000000 --- a/src/assets/images/uploadFiles-icon.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js index 279c8c21..59316dfc 100644 --- a/src/assets/javascripts/services.js +++ b/src/assets/javascripts/services.js @@ -406,123 +406,115 @@ function computeService(url, returnFrontend) { } } } - // if (returnFrontend) return [null, null] - // else return null + resolve() }) }) }) } -async function switchInstance(url) { - fetch("/config/config.json") - .then(response => response.text()) - .then(configData => { - const config = JSON.parse(configData) - browser.storage.local.get(["redirects", "options"], r => { - const redirects = r.redirects - const options = r.options - const protocolHost = utils.protocolHost(url) - for (const service in config.services) { - if (!options[service].enabled) continue - if (!all(service, null, options, config, redirects).includes(protocolHost)) continue - - let instancesList = [...options[options[service].frontend][options.network].enabled, ...options[options[service].frontend][options.network].custom] - if (instancesList.length === 0 && options.networkFallback) instancesList = [...options[options[service].frontend].clearnet.enabled, ...options[options[service].frontend].clearnet.custom] - - let oldInstance - const i = instancesList.indexOf(protocolHost) - if (i > -1) { - oldInstance = instancesList[i] - instancesList.splice(i, 1) - } - if (instancesList.length === 0) return - const randomInstance = utils.getRandomInstance(instancesList) - const oldUrl = `${oldInstance}${url.pathname}${url.search}` - // This is to make instance switching work when the instance depends on the pathname, eg https://darmarit.org/searx - // Doesn't work because of .includes array method, not a top priotiry atm - return oldUrl.replace(oldInstance, randomInstance) - } - }) - }) +function switchInstance(url) { + return new Promise(async resolve => { + await init() + const protocolHost = utils.protocolHost(url) + for (const service in config.services) { + if (!all(service, null, options, config, redirects).includes(protocolHost)) continue + + let instancesList = [...options[options[service].frontend][options.network].enabled, ...options[options[service].frontend][options.network].custom] + if (instancesList.length === 0 && options.networkFallback) instancesList = [...options[options[service].frontend].clearnet.enabled, ...options[options[service].frontend].clearnet.custom] + + let oldInstance + const i = instancesList.indexOf(protocolHost) + if (i > -1) { + oldInstance = instancesList[i] + instancesList.splice(i, 1) + } + if (instancesList.length === 0) { + resolve() + return + } + const randomInstance = utils.getRandomInstance(instancesList) + const oldUrl = `${oldInstance}${url.pathname}${url.search}` + // This is to make instance switching work when the instance depends on the pathname, eg https://darmarit.org/searx + // Doesn't work because of .includes array method, not a top priotiry atm + resolve(oldUrl.replace(oldInstance, randomInstance)) + return + } + resolve() + }) } -async function reverse(url) { - fetch("/config/config.json") - .then(response => response.text()) - .then(configData => { - const config = JSON.parse(configData) - browser.storage.local.get(["redirects", "options"], r => { - const redirects = r.redirects - const options = r.options - let protocolHost = utils.protocolHost(url) - for (const service in config.services) { - if (!all(service, null, options, config, redirects).includes(protocolHost)) continue - - switch (service) { - case "instagram": - if (url.pathname.startsWith("/p")) return `https://instagram.com${url.pathname.replace("/p", "")}${url.search}` - if (url.pathname.startsWith("/u")) return `https://instagram.com${url.pathname.replace("/u", "")}${url.search}` - return config.services[service].url + url.pathname + url.search - case "youtube": - case "imdb": - case "imgur": - case "tiktok": - case "twitter": - case "reddit": - return config.services[service].url + url.pathname + url.search - default: - return - } - } - }) - }) +function reverse(url) { + return new Promise(async resolve => { + await init() + let protocolHost = utils.protocolHost(url) + for (const service in config.services) { + if (!all(service, null, options, config, redirects).includes(protocolHost)) continue + + switch (service) { + case "instagram": + if (url.pathname.startsWith("/p")) resolve(`https://instagram.com${url.pathname.replace("/p", "")}${url.search}`) + if (url.pathname.startsWith("/u")) resolve(`https://instagram.com${url.pathname.replace("/u", "")}${url.search}`) + resolve(config.services[service].url + url.pathname + url.search) + return + case "youtube": + case "imdb": + case "imgur": + case "tiktok": + case "twitter": + case "reddit": + resolve(config.services[service].url + url.pathname + url.search) + return + default: + resolve() + return + } + } + resolve() + }) } -async function unifyPreferences(url, tabId) { - fetch("/config/config.json") - .then(response => response.text()) - .then(configData => { - const config = JSON.parse(configData) - browser.storage.local.get(["options", "reidrects"], r => { - const redirects = r.redirects - const options = r.options - const protocolHost = utils.protocolHost(url) - for (const service in config.services) { - for (const frontend in config.services[service].frontends) { - if (all(service, frontend, options, config, redirects).includes(protocolHost)) { - let instancesList = [...options[frontend][options.network].enabled, ...options[frontend][options.network].custom] - if (options.networkFallback && options.network != "clearnet") instancesList.push(...options[frontend].clearnet.enabled, ...options[frontend].clearnet.custom) - - const frontend = config.services[service].frontends[frontend] - if ("cookies" in frontend.preferences) { - for (const cookie of frontend.preferences.cookies) { - utils.copyCookie(frontend, url, instancesList, cookie) - } - } - if ("localstorage" in frontend.preferences) { - browser.storage.local.set({ tmp: [frontend, frontend.preferences.localstorage] }) - browser.tabs.executeScript(tabId, { - file: "/assets/javascripts/get-localstorage.js", +function unifyPreferences(url, tabId) { + return new Promise(async resolve => { + await init() + const protocolHost = utils.protocolHost(url) + for (const service in config.services) { + for (const frontend in config.services[service].frontends) { + if (all(service, frontend, options, config, redirects).includes(protocolHost)) { + let instancesList = [...options[frontend][options.network].enabled, ...options[frontend][options.network].custom] + if (options.networkFallback && options.network != "clearnet") instancesList.push(...options[frontend].clearnet.enabled, ...options[frontend].clearnet.custom) + + const frontendObject = config.services[service].frontends[frontend] + if ("cookies" in frontendObject.preferences) { + for (const cookie of frontendObject.preferences.cookies) { + utils.copyCookie(frontendObject, url, instancesList, cookie) + } + } + if ("localstorage" in frontendObject.preferences) { + browser.storage.local.set({ tmp: [frontend, frontendObject.preferences.localstorage] }) + browser.tabs.executeScript(tabId, { + file: "/assets/javascripts/get-localstorage.js", + runAt: "document_start", + }) + for (const instance of instancesList) + browser.tabs.create({ url: instance }, tab => + browser.tabs.executeScript(tab.id, { + file: "/assets/javascripts/set-localstorage.js", runAt: "document_start", }) - for (const instance of instancesList) - browser.tabs.create({ url: instance }, tab => - browser.tabs.executeScript(tab.id, { - file: "/assets/javascripts/set-localstorage.js", - runAt: "document_start", - }) - ) - } - if ("indexeddb" in frontend.preferences) { - } - if ("token" in frontend.preferences) { - } - return true - } + ) + } + /* + if ("indexeddb" in frontendObject.preferences) { } + if ("token" in frontendObject.preferences) { + } + */ + resolve(true) + return } - }) - }) + } + } + }) } async function setRedirects(redirects) { @@ -612,46 +604,67 @@ function upgradeOptions() { fetch("/config/config.json") .then(response => response.text()) .then(configData => { - browser.storage.local.get(["options", "exceptions", "theme", "popupFrontends", "autoRedirect", "firstPartyIsolate"], r => { + browser.storage.local.get(null, r => { let options = r.options let latency = {} const config = JSON.parse(configData) options.exceptions = r.exceptions if (r.theme != "DEFAULT") options.theme = r.theme options.popupServices = r.popupFrontends + let tmp = options.popupServices.indexOf("tikTok") + if (tmp > -1) { + options.popupServices.splice(tmp, 1) + options.popupServices.push("tiktok") + } + tmp = options.popupServices.indexOf("sendTarget") + if (tmp > -1) { + options.popupServices.splice(tmp, 1) + options.popupServices.push("sendFiles") + } options.firstPartyIsolate = r.firstPartyIsolate options.autoRedirect = r.autoRedirect + switch (r.onlyEmbeddedVideo) { + case "onlyNotEmbedded": + options.youtube.redirectType = "main_frame" + case "onlyEmbedded": + options.youtube.redirectType = "sub_frame" + case "both": + options.youtube.redirectType = "both" + } for (const service in config.services) { - browser.storage.local.get([`disable${utils.camelCase(service)}`, `${service}RedirectType`, `${service}Frontend`, `${service}Latency`, `${service}EmbedFrontend`], r => { - if (r) { - options[service].enabled = !r["disable" + utils.camelCase(service)] - if (r[service + "Frontend"]) { - if (r[service + "Frontend"] == "yatte") options[service].frontend = "yattee" - else options[service].frontend = r[service + "Frontend"] - } - if (r[service + "RedirectType"]) options[service].redirectType = r[service + "RedirectType"] - if (r[service + "EmbedFrontend"] && (service != "youtube" || r[service + "EmbedFrontend"] == "invidious" || "piped")) options[service].embedFrontend = r[service + "EmbedFrontend"] - for (const frontend in config.services[service].frontends) { - browser.local.storage.get(`${frontend}Latency`, r => { - if (r) latency[frontend] = r[frontend + "Latency"] - for (const network in config.networks) { - let protocol - if (network == "clearnet") protocol = "normal" - else protocol = network - browser.storage.local.get([`${frontend}${utils.camelCase(protocol)}RedirectsChecks`, `${frontend}${utils.camelCase(protocol)}CustomRedirects`], r => { - if (r) { - options[frontend][network].checks = r[frontend + utils.camelCase(protocol) + "RedirectsChecks"] - options[frontend][network].custom = r[frontend + utils.camelCase(protocol) + "CustomRedirects"] - } - }) - } - }) + let oldService + switch (service) { + case "tiktok": + oldService = "tikTok" + break + case "sendFiles": + oldService = "sendTarget" + break + default: + oldService = service + } + options[service].enabled = !r["disable" + utils.camelCase(oldService)] + if (r[oldService + "Frontend"]) { + if (r[oldService + "Frontend"] == "yatte") options[service].frontend = "yattee" + else options[service].frontend = r[oldService + "Frontend"] + } + if (r[oldService + "RedirectType"]) options[service].redirectType = r[oldService + "RedirectType"] + if (r[oldService + "EmbedFrontend"] && (service != "youtube" || r[oldService + "EmbedFrontend"] == "invidious" || r[oldService + "EmbedFrontend"] == "piped")) + options[service].embedFrontend = r[oldService + "EmbedFrontend"] + for (const frontend in config.services[service].frontends) { + if (r[frontend + "Latency"]) latency[frontend] = r[frontend + "Latency"] + for (const network in config.networks) { + let protocol + if (network == "clearnet") protocol = "normal" + else protocol = network + if (r[frontend + utils.camelCase(protocol) + "RedirectsChecks"]) { + options[frontend][network].enabled = r[frontend + utils.camelCase(protocol) + "RedirectsChecks"] + options[frontend][network].custom = r[frontend + utils.camelCase(protocol) + "CustomRedirects"] } } - }) + } } - browser.storage.local.set({ options, latency }) - resolve() + browser.storage.local.set({ options, latency }, () => resolve()) }) }) }) diff --git a/src/assets/javascripts/utils.js b/src/assets/javascripts/utils.js index 26fe11d6..056bbc00 100644 --- a/src/assets/javascripts/utils.js +++ b/src/assets/javascripts/utils.js @@ -342,7 +342,7 @@ function getPreferencesFromToken(frontend, targetUrl, urls, name, endpoint) { }) } -function copyRaw(test, copyRawElement, config) { +function copyRaw(test, copyRawElement) { return new Promise(resolve => { browser.tabs.query({ active: true, currentWindow: true }, async tabs => { let currTab = tabs[0] @@ -355,7 +355,7 @@ function copyRaw(test, copyRawElement, config) { return } - let newUrl = servicesHelper.reverse(url, config) + const newUrl = await servicesHelper.reverse(url) if (newUrl) { resolve(newUrl) @@ -387,9 +387,7 @@ function unify() { return } - const result = await servicesHelper.unifyPreferences(url, currTab.id) - - resolve(result) + resolve(await servicesHelper.unifyPreferences(url, currTab.id)) } }) }) diff --git a/src/config/config.json b/src/config/config.json index b15c20d4..6866453c 100644 --- a/src/config/config.json +++ b/src/config/config.json @@ -22,7 +22,8 @@ "frontends": { "invidious": { "preferences": { - "cookies": ["PREFS"] + "cookies": ["PREFS"], + "localstorage": ["dark_mode"] }, "name": "Invidious", "embeddable": true, @@ -529,7 +530,7 @@ "embeddable": false, "url": "https://maps.libredirect.invalid" }, - "uploadFiles": { + "sendFiles": { "frontends": { "send": { "name": "Send", diff --git a/src/instances/get_instances.py b/src/instances/get_instances.py index 06b547b3..9a53f927 100644 --- a/src/instances/get_instances.py +++ b/src/instances/get_instances.py @@ -431,6 +431,7 @@ def peertube(): def isValid(url): # This code is contributed by avanitrachhadiya2155 try: + url.encode('ascii') result = urlparse(url) return all([result.scheme, result.netloc]) except Exception: diff --git a/src/pages/options/index.html b/src/pages/options/index.html index 2549566c..5421bb81 100644 --- a/src/pages/options/index.html +++ b/src/pages/options/index.html @@ -84,7 +84,7 @@ - Send Files
+ Send Files
@@ -150,11 +150,6 @@
-
- +
@@ -3139,14 +3134,14 @@
-
+
-

Send Files

+

Send Files


Enable

- +

diff --git a/src/pages/options/widgets/general.js b/src/pages/options/widgets/general.js index 1a2f44c6..92632f23 100644 --- a/src/pages/options/widgets/general.js +++ b/src/pages/options/widgets/general.js @@ -49,16 +49,16 @@ function setOption(option, multiChoice, event) { let exportSettingsElement = document.getElementById("export-settings") function exportSettings() { - browser.storage.local.get(null, result => { - let resultString = JSON.stringify(result, null, " ") - exportSettingsElement.href = "data:application/json;base64," + btoa(encodeURI(resultString)) + browser.storage.local.get("options", result => { + result.options.version = browser.runtime.getManifest().version + let resultString = JSON.stringify(result.options, null, " ") + exportSettingsElement.href = "data:application/json;base64," + btoa(resultString) exportSettingsElement.download = "libredirect-settings.json" }) } exportSettings() document.getElementById("general_page").addEventListener("click", exportSettings) -document.getElementById("test").addEventListener("click", servicesHelper.upgradeOptions) let importSettingsElement = document.getElementById("import-settings") let importSettingsElementText = document.getElementById("import_settings_text") @@ -70,7 +70,22 @@ importSettingsElement.addEventListener("change", () => { reader.onload = async () => { const data = JSON.parse(reader.result) if ("theme" in data && "disableImgur" in data && "imgurRedirects" in data) { - browser.storage.local.clear(() => browser.storage.local.set({ ...data }, () => location.reload())) + browser.storage.local.clear(() => + browser.storage.local.set({ ...data }, () => { + fetch("/instances/blacklist.json") + .then(response => response.text()) + .then(async data => { + browser.storage.local.set({ blacklists: JSON.parse(data) }, async () => { + await generalHelper.initDefaults() + await servicesHelper.initDefaults() + await servicesHelper.upgradeOptions() + location.reload() + }) + }) + }) + ) + } else if ("version" in data) { + browser.storage.local.clear(() => browser.storage.local.set({ options: data }, () => location.reload())) } else { console.log("incompatible settings") importError() diff --git a/src/pages/popup/popup.html b/src/pages/popup/popup.html index 56e4ca14..b5076635 100644 --- a/src/pages/popup/popup.html +++ b/src/pages/popup/popup.html @@ -107,13 +107,13 @@

Maps

-
+
-

Send Files

- +

Send Files

+
@@ -220,13 +220,13 @@

Maps

-
+
-

Send Files

- +

Send Files

+
diff --git a/src/pages/popup/popup.js b/src/pages/popup/popup.js index 05dd70f7..ed1546c7 100644 --- a/src/pages/popup/popup.js +++ b/src/pages/popup/popup.js @@ -26,7 +26,7 @@ utils.switchInstance(true).then(r => { else document.getElementById("change_instance").addEventListener("click", () => utils.switchInstance(false)) }) -utils.copyRaw(true, null, config).then(r => { +utils.copyRaw(true).then(r => { if (!r) document.getElementById("copy_raw_div").style.display = "none" else { const copy_raw = document.getElementById("copy_raw") @@ -81,13 +81,13 @@ browser.storage.local.get("options", r => { let service = await serviceHelper.computeService(url, true) let frontend if (service) { - if (service[1]) { + if (service[0]) { frontend = service[1] service = service[0] } divs[service].current.classList.remove("hide") divs[service].all.classList.add("hide") - if (config.services[service].frontends[frontend].preferences && !config.services[service].frontends[frontend].preferences.token) { + if (frontend && config.services[service].frontends[frontend].preferences && !config.services[service].frontends[frontend].preferences.token) { const unify = document.getElementById("unify") const textElement = document.getElementById("unify").getElementsByTagName("h4")[0] unify.addEventListener("click", () => { -- cgit 1.4.1 From ebc1259ca4ade09e53af17ee86b67eb09f0f9c75 Mon Sep 17 00:00:00 2001 From: Hygna Date: Mon, 3 Oct 2022 19:49:12 +0100 Subject: Squashed many bugs --- src/assets/javascripts/services.js | 2 +- src/config/config.json | 2 +- src/instances/get_instances.py | 39 +++++++++++++++++++++-------- src/pages/options/index.html | 38 ++++++++++++++-------------- src/pages/options/widgets/general.ejs | 4 +-- src/pages/options/widgets/general.js | 47 +++++++++++++++++++---------------- src/pages/popup/popup.html | 4 +-- src/pages/stylesheets/styles.css | 13 ++++++++++ 8 files changed, 91 insertions(+), 58 deletions(-) (limited to 'src/instances') diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js index 59316dfc..afd7906f 100644 --- a/src/assets/javascripts/services.js +++ b/src/assets/javascripts/services.js @@ -76,7 +76,7 @@ function redirect(url, type, initiator) { } if (Object.keys(config.services[service].frontends).length > 1) { - if (type == "sub_frame") frontend = options[service].embedFrontend + if (type == "sub_frame" && config.services[service].embeddable && !config.services[service].frontends[options[service].frontend].embeddable) frontend = options[service].embedFrontend else frontend = options[service].frontend } else frontend = Object.keys(config.services[service].frontends)[0] diff --git a/src/config/config.json b/src/config/config.json index 6866453c..09c95bbb 100644 --- a/src/config/config.json +++ b/src/config/config.json @@ -279,7 +279,7 @@ "options": { "enabled": false }, "imageType": "svg", "embeddable": false, - "url": "https://wikipedia.com" + "url": "https://wikipedia.org" }, "medium": { "frontends": { diff --git a/src/instances/get_instances.py b/src/instances/get_instances.py index 9a53f927..c789f551 100644 --- a/src/instances/get_instances.py +++ b/src/instances/get_instances.py @@ -25,16 +25,33 @@ with open('./src/config/config.json', 'rt') as tmp: def filterLastSlash(urlList): tmp = {} - for x in urlList: - tmp[x] = {} - for y in urlList[x]: - tmp[x][y] = [] - for z in urlList[x][y]: - if z.endswith('/'): - tmp[x][y].append(z[:-1]) - print(Fore.YELLOW + "Fixed " + Style.RESET_ALL + z) + for frontend in urlList: + tmp[frontend] = {} + for network in urlList[frontend]: + tmp[frontend][network] = [] + for url in urlList[frontend][network]: + if url.endswith('/'): + tmp[frontend][network].append(url[:-1]) + print(Fore.YELLOW + "Fixed " + Style.RESET_ALL + url) else: - tmp[x][y].append(z) + tmp[frontend][network].append(url) + return tmp + + +def idnaEncode(urlList): + tmp = {} + for frontend in urlList: + tmp[frontend] = {} + for network in urlList[frontend]: + tmp[frontend][network] = [] + for url in urlList[frontend][network]: + try: + encodedUrl = url.encode("idna").decode("utf8") + tmp[frontend][network].append(encodedUrl) + if (encodedUrl != url): + print(Fore.YELLOW + "Fixed " + Style.RESET_ALL + url) + except Exception: + tmp[frontend][network].append(url) return tmp @@ -247,7 +264,7 @@ def piped(): _list['loki'] = [] r = requests.get( 'https://raw.githubusercontent.com/wiki/TeamPiped/Piped/Instances.md') - + tmp = re.findall( r'(?:[^\s\/]+\.)+[a-zA-Z]+ (?:\(Official\) )?\| (https:\/{2}(?:[^\s\/]+\.)+[a-zA-Z]+) \| ', r.text) for item in tmp: @@ -431,7 +448,6 @@ def peertube(): def isValid(url): # This code is contributed by avanitrachhadiya2155 try: - url.encode('ascii') result = urlparse(url) return all([result.scheme, result.netloc]) except Exception: @@ -465,6 +481,7 @@ hyperpipe() facil() simpleertube() mightyList = filterLastSlash(mightyList) +mightyList = idnaEncode(mightyList) cloudflare = [] authenticate = [] diff --git a/src/pages/options/index.html b/src/pages/options/index.html index 5421bb81..d79da014 100644 --- a/src/pages/options/index.html +++ b/src/pages/options/index.html @@ -116,7 +116,7 @@
-

Fallback to normal if no instances are available for the current network

+

Fallback to clearnet if no instances are available for the current network

@@ -182,56 +182,56 @@
- Youtube + Youtube
- YT Music + YT Music
- Twitter + Twitter
- Instagram + Instagram
- TikTok + TikTok
- Reddit + Reddit
- Imgur + Imgur
- Wikipedia + Wikipedia
@@ -243,42 +243,42 @@ - Medium + Medium
- Quora + Quora
- IMDb + IMDb
- Reuters + Reuters
- PeerTube + PeerTube
- LBRY + LBRY
@@ -288,7 +288,7 @@ - Search + Search
@@ -298,7 +298,7 @@ - Translate + Translate @@ -308,7 +308,7 @@ - Maps + Maps @@ -318,7 +318,7 @@ - Send Files + Send Files diff --git a/src/pages/options/widgets/general.ejs b/src/pages/options/widgets/general.ejs index 8f7ab029..77028ac2 100644 --- a/src/pages/options/widgets/general.ejs +++ b/src/pages/options/widgets/general.ejs @@ -21,7 +21,7 @@
-

Fallback to normal if no instances are available for the current network

+

Fallback to clearnet if no instances are available for the current network

@@ -92,7 +92,7 @@ <% } else { _%> <%- include ('src/assets/images/' + service + '-icon.svg') %> <% } _%> - <%= config.services[service].name %> + <%= config.services[service].name %> diff --git a/src/pages/options/widgets/general.js b/src/pages/options/widgets/general.js index 92632f23..a58ca3e6 100644 --- a/src/pages/options/widgets/general.js +++ b/src/pages/options/widgets/general.js @@ -28,7 +28,7 @@ async function getConfig() { }) } -function setOption(option, multiChoice, event) { +function setOption(option, type, event) { browser.storage.local.get("options", r => { let options = r.options browser.storage.local.set({ options }) @@ -36,13 +36,15 @@ function setOption(option, multiChoice, event) { browser.storage.local.get("options", r => { let options = r.options - if (multiChoice) { + if (type == "select") { options[option] = event.target.options[event.target.options.selectedIndex].value - } else { + } else if (type == "checkbox") { options[option] = event.target.checked + } else if (type == "range") { + options[option] = event.target.value } + browser.storage.local.set({ options }) - location.reload() }) } @@ -120,30 +122,30 @@ resetSettings.addEventListener("click", async () => { let autoRedirectElement = document.getElementById("auto-redirect") autoRedirectElement.addEventListener("change", event => { - setOption("autoRedirect", false, event) + setOption("autoRedirect", "checkbox", event) }) let themeElement = document.getElementById("theme") themeElement.addEventListener("change", event => { - setOption("theme", true, event) + setOption("theme", "select", event) location.reload() }) let networkElement = document.getElementById("network") networkElement.addEventListener("change", event => { - setOption("network", true, event) + setOption("network", "select", event) location.reload() }) let networkFallbackCheckbox = document.getElementById("network-fallback-checkbox") networkFallbackCheckbox.addEventListener("change", event => { - setOption("networkFallback", false, event) + setOption("networkFallback", "checkbox", event) }) let latencyOutput = document.getElementById("latency-output") let latencyInput = document.getElementById("latency-input") latencyInput.addEventListener("change", event => { - setOption("latencyThreshold", false, event) + setOption("latencyThreshold", "range", event) }) latencyInput.addEventListener("input", event => { latencyOutput.value = event.target.value @@ -153,18 +155,19 @@ let nameCustomInstanceInput = document.getElementById("exceptions-custom-instanc let instanceTypeElement = document.getElementById("exceptions-custom-instance-type") let instanceType = "url" -let popupServices - await getConfig() for (const service in config.services) { document.getElementById(service).addEventListener("change", event => { - if (event.target.checked && !popupServices.includes(service)) popupServices.push(service) - else if (popupServices.includes(service)) { - var index = popupServices.indexOf(service) - if (index !== -1) popupServices.splice(index, 1) - } - browser.storage.local.set({ popupServices }) + browser.storage.local.get("options", r => { + let options = r.options + if (event.target.checked && !options.popupServices.includes(service)) options.popupServices.push(service) + else if (options.popupServices.includes(service)) { + var index = options.popupServices.indexOf(service) + if (index !== -1) options.popupServices.splice(index, 1) + } + browser.storage.local.set({ options }) + }) }) } // const firstPartyIsolate = document.getElementById('firstPartyIsolate'); @@ -176,13 +179,14 @@ browser.storage.local.get("options", r => { networkElement.value = r.options.network networkFallbackCheckbox.checked = r.options.networkFallback latencyOutput.value = r.options.latencyThreshold + let options = r.options // firstPartyIsolate.checked = r.firstPartyIsolate; - let networkFallbackElement = document.getElementById("network-fallback") + //let networkFallbackElement = document.getElementById("network-fallback") if (networkElement.value == "clearnet") { - networkFallbackElement.style.display = "none" + networkFallbackCheckbox.disabled = true } else { - networkFallbackElement.style.display = "block" + networkFallbackCheckbox.disabled = false } instanceTypeElement.addEventListener("change", event => { @@ -251,6 +255,5 @@ browser.storage.local.get("options", r => { calcExceptionsCustomInstances() }) - popupServices = r.options.popupServices - for (const service in config.services) document.getElementById(service).checked = popupServices.includes(service) + for (const service in config.services) document.getElementById(service).checked = options.popupServices.includes(service) }) diff --git a/src/pages/popup/popup.html b/src/pages/popup/popup.html index b5076635..54c4fefa 100644 --- a/src/pages/popup/popup.html +++ b/src/pages/popup/popup.html @@ -43,7 +43,7 @@

Imgur

-
+

Wikipedia

@@ -156,7 +156,7 @@

Imgur

-
+

Wikipedia

diff --git a/src/pages/stylesheets/styles.css b/src/pages/stylesheets/styles.css index 06abab3a..eb599656 100644 --- a/src/pages/stylesheets/styles.css +++ b/src/pages/stylesheets/styles.css @@ -80,11 +80,13 @@ select { margin: 0; max-width: 500px; border-radius: 3px; + cursor: pointer; } input[type="url"], input[type="text"] { width: 400px; + cursor: text; } input:invalid { @@ -141,6 +143,7 @@ input[type="range"] { height: 7px; border-radius: 50px; background: var(--text); + cursor: ew-resize; } input[type="range"]:hover { @@ -464,3 +467,13 @@ div.about > div { div.about h4 { width: auto; } + +select:disabled { + opacity: 0.6; + cursor: not-allowed; +} + +input:disabled { + opacity: 0.6; + cursor: not-allowed; +} -- cgit 1.4.1