diff --git a/README.md b/README.md index 3bbf2b3..a9e6839 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Quora => [Quetre](https://github.com/zyachel/quetre)\ IMDb => [Libremdb](https://github.com/zyachel/libremdb)\ PeerTube => [SimpleerTube](https://git.sr.ht/~metalune/simpleweb_peertube)\ LBRY/Odysee => [Librarian](https://codeberg.org/librarian/librarian), [LBRY Desktop](https://lbry.com/get)\ -Search => [SearXNG](https://github.com/searxng/searxng), [SearX](https://searx.github.io/searx/), [Whoogle](https://benbusby.com/projects/whoogle-search/), [Librex](https://github.com/hnhx/librex/)\ +Search => [SearXNG](https://github.com/searxng/searxng), [SearX](https://searx.github.io/searx/), [Whoogle](https://benbusby.com/projects/whoogle-search/), [LibreX](https://github.com/hnhx/librex/)\ Translate => [SimplyTranslate](https://git.sr.ht/~metalune/simplytranslate_web), [LingvaTranslate](https://github.com/TheDavidDelta/lingva-translate)\ Maps => [OpenStreetMap](https://www.openstreetmap.org/), [FacilMap](https://github.com/FacilMap/facilmap)\ Send Files => [Send](https://gitlab.com/timvisee/send) diff --git a/package.json b/package.json index e6214c8..50872aa 100644 --- a/package.json +++ b/package.json @@ -22,12 +22,13 @@ "bugs": { "url": "https://github.com/LibRedirect/LibRedirect/issues" }, - "homepage": "https://github.com/LibRedirect/LibRedirect", + "homepage": "https://libredirect.github.io", "devDependencies": { "prettier": "2.7.1", "web-ext": "^6.7.0" }, "dependencies": { - "buffer": "^6.0.3" + "buffer": "^6.0.3", + "ejs": "^3.1.8" } } diff --git a/src/assets/javascripts/utils.js b/src/assets/javascripts/utils.js index 9a7d37b..32167bc 100644 --- a/src/assets/javascripts/utils.js +++ b/src/assets/javascripts/utils.js @@ -25,13 +25,15 @@ function getRandomInstance(instances) { let cloudflareBlackList = [] let authenticateBlackList = [] -async function initcloudflareBlackList() { +let offlineBlacklist = [] +async function initBlackList() { return new Promise(resolve => { fetch("/instances/blacklist.json") .then(response => response.text()) .then(data => { cloudflareBlackList = JSON.parse(data).cloudflare authenticateBlackList = JSON.parse(data).authenticate + offlineBlacklist = JSON.parse(data).offlineBlacklist resolve() }) }) @@ -53,7 +55,7 @@ function updateInstances() { return } } - await initcloudflareBlackList() + await initBlackList() const instances = JSON.parse(http.responseText) youtubeHelper.setRedirects({ @@ -114,7 +116,7 @@ async function processDefaultCustomInstances(target, name, protocol, document) { let nameCustomInstances = [] let nameCheckListElement = nameProtocolElement.getElementsByClassName("checklist")[0] - await initcloudflareBlackList() + await initBlackList() let nameDefaultRedirects @@ -162,6 +164,7 @@ async function processDefaultCustomInstances(target, name, protocol, document) { ...redirects[name][protocol].map(x => { const cloudflare = cloudflareBlackList.includes(x) ? ' cloudflare' : "" const authenticate = authenticateBlackList.includes(x) ? ' authenticate' : "" + const offline = offlineBlacklist.includes(x) ? ' offline' : "" let ms = instancesLatency[x] let latencyColor = ms <= 1000 ? "green" : ms <= 2000 ? "orange" : "red" @@ -172,7 +175,7 @@ async function processDefaultCustomInstances(target, name, protocol, document) { const latency = x in instancesLatency ? '' + latencyLimit + "" : "" - let warnings = [cloudflare, authenticate, latency].join(" ") + let warnings = [cloudflare, authenticate, offline, latency].join(" ") return `
${x}${warnings} diff --git a/src/instances/get_instances.py b/src/instances/get_instances.py index 0d0e8c7..07adbce 100644 --- a/src/instances/get_instances.py +++ b/src/instances/get_instances.py @@ -89,6 +89,19 @@ def is_authenticate(url): return False return False +def is_offline(url): + try: + r = requests.get(url, timeout=5) + if r.status_code != 200: + print(url + ' is ' + Fore.RED + 'offline' + Style.RESET_ALL) + print("Status code") + print(r.status_code) + return True + else: + return False + except: + return False + def invidious(): r = requests.get('https://api.invidious.io/instances.json') @@ -635,6 +648,7 @@ mightyList = filterLastSlash(mightyList) cloudflare = [] authenticate = [] +offline = [] for k1, v1 in mightyList.items(): if type(mightyList[k1]) is dict: for k2, v2 in mightyList[k1].items(): @@ -647,12 +661,15 @@ for k1, v1 in mightyList.items(): cloudflare.append(instance) if not instance.endswith('.onion') and not instance.endswith('.i2p') and not instance.endswith('.loki') and is_authenticate(instance): authenticate.append(instance) + if not instance.endswith('.onion') and not instance.endswith('.i2p') and not instance.endswith('.loki') and is_offline(instance): + offline.append(instance) peertube() blacklist = { 'cloudflare': cloudflare, - 'authenticate': authenticate + 'authenticate': authenticate, + 'offline': offline } # Writing to file diff --git a/src/pages/options/widgets/general.js b/src/pages/options/widgets/general.js index 5407159..56439a9 100644 --- a/src/pages/options/widgets/general.js +++ b/src/pages/options/widgets/general.js @@ -156,6 +156,15 @@ protocolFallbackCheckbox.addEventListener("change", event => { browser.storage.local.set({ protocolFallback: event.target.checked }) }) +let latencyOutput = document.getElementById("latency-output") +let latencyInput = document.getElementById("latency-input") +latencyInput.addEventListener("change", event => { + browser.storage.local.set({ latencyThreshold: event.target.value}) +}) +latencyInput.addEventListener("input", event => { + latencyOutput.value = event.target.value +}) + let nameCustomInstanceInput = document.getElementById("exceptions-custom-instance") let instanceTypeElement = document.getElementById("exceptions-custom-instance-type") let instanceType = "url" @@ -181,6 +190,7 @@ browser.storage.local.get( "exceptions", "protocol", "protocolFallback", + "latencyThreshold", // 'firstPartyIsolate' ], r => { @@ -188,6 +198,7 @@ browser.storage.local.get( themeElement.value = r.theme protocolElement.value = r.protocol protocolFallbackCheckbox.checked = r.protocolFallback + latencyOutput.value = r.latencyThreshold // firstPartyIsolate.checked = r.firstPartyIsolate; let protocolFallbackElement = document.getElementById("protocol-fallback") diff --git a/src/pages/widgets/links.pug b/src/pages/widgets/links.pug index cac2ecb..c7f8e0a 100644 --- a/src/pages/widgets/links.pug +++ b/src/pages/widgets/links.pug @@ -31,7 +31,7 @@ mixin links(service) a(href="#reddit" data-localise="__MSG_reddit__") Reddit .title - img(src="../../../assets/images/imgur-icon.png") + img(src="../../../assets/images/imgur.png") a(href="#imgur" data-localise="__MSG_imgur__") Imgur .title @@ -60,7 +60,7 @@ mixin links(service) .title img(src="../../../assets/images/lbry-icon.png") - a(href="#lbry" data-localise="__MSG_lbry__") LBRY/Odysee + a(href="#lbry" data-localise="__MSG_lbry__") LBRY .title +search @@ -80,4 +80,4 @@ mixin links(service) .title +about - a(href="#about" data-localise="__MSG_about") About \ No newline at end of file + a(href="#about" data-localise="__MSG_about") About