mirror of
https://codeberg.org/LibRedirect/libredirect.git
synced 2025-02-08 08:08:50 +01:00
http status
This commit is contained in:
parent
4c69fa7e29
commit
9a884ca5c0
@ -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)
|
||||
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
@ -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) ? ' <span style="color:red;">cloudflare</span>' : ""
|
||||
const authenticate = authenticateBlackList.includes(x) ? ' <span style="color:orange;">authenticate</span>' : ""
|
||||
const offline = offlineBlacklist.includes(x) ? ' <span style="color:grey;">offline</span>' : ""
|
||||
|
||||
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 ? '<span style="color:' + latencyColor + ';">' + latencyLimit + "</span>" : ""
|
||||
|
||||
let warnings = [cloudflare, authenticate, latency].join(" ")
|
||||
let warnings = [cloudflare, authenticate, offline, latency].join(" ")
|
||||
return `<div>
|
||||
<x><a href="${x}" target="_blank">${x}</a>${warnings}</x>
|
||||
<input type="checkbox" class="${x}"/>
|
||||
|
@ -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
|
||||
|
@ -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")
|
||||
|
@ -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
|
||||
a(href="#about" data-localise="__MSG_about") About
|
||||
|
Loading…
x
Reference in New Issue
Block a user