http status

This commit is contained in:
BobIsMyManager 2022-08-01 14:28:15 +01:00 committed by ManeraKai
parent 9b30663111
commit 40e07fbc33
6 changed files with 43 additions and 11 deletions

View File

@ -32,7 +32,7 @@ Quora => [Quetre](https://github.com/zyachel/quetre)\
IMDb => [Libremdb](https://github.com/zyachel/libremdb)\ IMDb => [Libremdb](https://github.com/zyachel/libremdb)\
PeerTube => [SimpleerTube](https://git.sr.ht/~metalune/simpleweb_peertube)\ PeerTube => [SimpleerTube](https://git.sr.ht/~metalune/simpleweb_peertube)\
LBRY/Odysee => [Librarian](https://codeberg.org/librarian/librarian), [LBRY Desktop](https://lbry.com/get)\ 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)\ 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)\ Maps => [OpenStreetMap](https://www.openstreetmap.org/), [FacilMap](https://github.com/FacilMap/facilmap)\
Send Files => [Send](https://gitlab.com/timvisee/send) Send Files => [Send](https://gitlab.com/timvisee/send)

View File

@ -22,12 +22,13 @@
"bugs": { "bugs": {
"url": "https://github.com/LibRedirect/LibRedirect/issues" "url": "https://github.com/LibRedirect/LibRedirect/issues"
}, },
"homepage": "https://github.com/LibRedirect/LibRedirect", "homepage": "https://libredirect.github.io",
"devDependencies": { "devDependencies": {
"prettier": "2.7.1", "prettier": "2.7.1",
"web-ext": "^6.7.0" "web-ext": "^6.7.0"
}, },
"dependencies": { "dependencies": {
"buffer": "^6.0.3" "buffer": "^6.0.3",
"ejs": "^3.1.8"
} }
} }

View File

@ -25,13 +25,15 @@ function getRandomInstance(instances) {
let cloudflareBlackList = [] let cloudflareBlackList = []
let authenticateBlackList = [] let authenticateBlackList = []
async function initcloudflareBlackList() { let offlineBlacklist = []
async function initBlackList() {
return new Promise(resolve => { return new Promise(resolve => {
fetch("/instances/blacklist.json") fetch("/instances/blacklist.json")
.then(response => response.text()) .then(response => response.text())
.then(data => { .then(data => {
cloudflareBlackList = JSON.parse(data).cloudflare cloudflareBlackList = JSON.parse(data).cloudflare
authenticateBlackList = JSON.parse(data).authenticate authenticateBlackList = JSON.parse(data).authenticate
offlineBlacklist = JSON.parse(data).offlineBlacklist
resolve() resolve()
}) })
}) })
@ -53,7 +55,7 @@ function updateInstances() {
return return
} }
} }
await initcloudflareBlackList() await initBlackList()
const instances = JSON.parse(http.responseText) const instances = JSON.parse(http.responseText)
youtubeHelper.setRedirects({ youtubeHelper.setRedirects({
@ -114,7 +116,7 @@ async function processDefaultCustomInstances(target, name, protocol, document) {
let nameCustomInstances = [] let nameCustomInstances = []
let nameCheckListElement = nameProtocolElement.getElementsByClassName("checklist")[0] let nameCheckListElement = nameProtocolElement.getElementsByClassName("checklist")[0]
await initcloudflareBlackList() await initBlackList()
let nameDefaultRedirects let nameDefaultRedirects
@ -162,6 +164,7 @@ async function processDefaultCustomInstances(target, name, protocol, document) {
...redirects[name][protocol].map(x => { ...redirects[name][protocol].map(x => {
const cloudflare = cloudflareBlackList.includes(x) ? ' <span style="color:red;">cloudflare</span>' : "" const cloudflare = cloudflareBlackList.includes(x) ? ' <span style="color:red;">cloudflare</span>' : ""
const authenticate = authenticateBlackList.includes(x) ? ' <span style="color:orange;">authenticate</span>' : "" const authenticate = authenticateBlackList.includes(x) ? ' <span style="color:orange;">authenticate</span>' : ""
const offline = offlineBlacklist.includes(x) ? ' <span style="color:grey;">offline</span>' : ""
let ms = instancesLatency[x] let ms = instancesLatency[x]
let latencyColor = ms <= 1000 ? "green" : ms <= 2000 ? "orange" : "red" 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 ? '<span style="color:' + latencyColor + ';">' + latencyLimit + "</span>" : "" const latency = x in instancesLatency ? '<span style="color:' + latencyColor + ';">' + latencyLimit + "</span>" : ""
let warnings = [cloudflare, authenticate, latency].join(" ") let warnings = [cloudflare, authenticate, offline, latency].join(" ")
return `<div> return `<div>
<x><a href="${x}" target="_blank">${x}</a>${warnings}</x> <x><a href="${x}" target="_blank">${x}</a>${warnings}</x>
<input type="checkbox" class="${x}"/> <input type="checkbox" class="${x}"/>

View File

@ -89,6 +89,19 @@ def is_authenticate(url):
return False return False
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(): def invidious():
r = requests.get('https://api.invidious.io/instances.json') r = requests.get('https://api.invidious.io/instances.json')
@ -635,6 +648,7 @@ mightyList = filterLastSlash(mightyList)
cloudflare = [] cloudflare = []
authenticate = [] authenticate = []
offline = []
for k1, v1 in mightyList.items(): for k1, v1 in mightyList.items():
if type(mightyList[k1]) is dict: if type(mightyList[k1]) is dict:
for k2, v2 in mightyList[k1].items(): for k2, v2 in mightyList[k1].items():
@ -647,12 +661,15 @@ for k1, v1 in mightyList.items():
cloudflare.append(instance) cloudflare.append(instance)
if not instance.endswith('.onion') and not instance.endswith('.i2p') and not instance.endswith('.loki') and is_authenticate(instance): if not instance.endswith('.onion') and not instance.endswith('.i2p') and not instance.endswith('.loki') and is_authenticate(instance):
authenticate.append(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() peertube()
blacklist = { blacklist = {
'cloudflare': cloudflare, 'cloudflare': cloudflare,
'authenticate': authenticate 'authenticate': authenticate,
'offline': offline
} }
# Writing to file # Writing to file

View File

@ -156,6 +156,15 @@ protocolFallbackCheckbox.addEventListener("change", event => {
browser.storage.local.set({ protocolFallback: event.target.checked }) 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 nameCustomInstanceInput = document.getElementById("exceptions-custom-instance")
let instanceTypeElement = document.getElementById("exceptions-custom-instance-type") let instanceTypeElement = document.getElementById("exceptions-custom-instance-type")
let instanceType = "url" let instanceType = "url"
@ -181,6 +190,7 @@ browser.storage.local.get(
"exceptions", "exceptions",
"protocol", "protocol",
"protocolFallback", "protocolFallback",
"latencyThreshold",
// 'firstPartyIsolate' // 'firstPartyIsolate'
], ],
r => { r => {
@ -188,6 +198,7 @@ browser.storage.local.get(
themeElement.value = r.theme themeElement.value = r.theme
protocolElement.value = r.protocol protocolElement.value = r.protocol
protocolFallbackCheckbox.checked = r.protocolFallback protocolFallbackCheckbox.checked = r.protocolFallback
latencyOutput.value = r.latencyThreshold
// firstPartyIsolate.checked = r.firstPartyIsolate; // firstPartyIsolate.checked = r.firstPartyIsolate;
let protocolFallbackElement = document.getElementById("protocol-fallback") let protocolFallbackElement = document.getElementById("protocol-fallback")

View File

@ -31,7 +31,7 @@ mixin links(service)
a(href="#reddit" data-localise="__MSG_reddit__") Reddit a(href="#reddit" data-localise="__MSG_reddit__") Reddit
.title .title
img(src="../../../assets/images/imgur-icon.png") img(src="../../../assets/images/imgur.png")
a(href="#imgur" data-localise="__MSG_imgur__") Imgur a(href="#imgur" data-localise="__MSG_imgur__") Imgur
.title .title
@ -60,7 +60,7 @@ mixin links(service)
.title .title
img(src="../../../assets/images/lbry-icon.png") 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 .title
+search +search