Merge branch 'master' of https://codeberg.org/LibRedirect/libredirect
This commit is contained in:
commit
b3c44dfbd4
|
@ -0,0 +1,31 @@
|
||||||
|
---
|
||||||
|
name: "Report a bug"
|
||||||
|
about: "Is libredirect not behaving as expected? Report a bug so that it can be fixed as soon as possible."
|
||||||
|
labels:
|
||||||
|
- "Kind: Bug"
|
||||||
|
---
|
||||||
|
|
||||||
|
## What happened?
|
||||||
|
|
||||||
|
## What did you expect to happen?
|
||||||
|
|
||||||
|
## Steps to reproduce:
|
||||||
|
|
||||||
|
1.
|
||||||
|
2.
|
||||||
|
3.
|
||||||
|
|
||||||
|
<!-- and so on -->
|
||||||
|
|
||||||
|
## Debug information:
|
||||||
|
|
||||||
|
Browser and version number:
|
||||||
|
Libredirect version:
|
||||||
|
|
||||||
|
## Screenshots/Videos
|
||||||
|
|
||||||
|
<!--Just drag and drop any screenshots or videos you have of the issue below-->
|
||||||
|
|
||||||
|
<br>
|
||||||
|
<!--Put an "x" inbetween the brackets to confirm-->
|
||||||
|
[ ] I have checked on codeberg and github and can confirm this issue is not a duplicate.
|
|
@ -0,0 +1,14 @@
|
||||||
|
---
|
||||||
|
name: "Suggest a new feature"
|
||||||
|
about: "Is there something missing that you want to see in libredirect? Suggest a feature so it will exist in a future release."
|
||||||
|
labels:
|
||||||
|
- "Kind: Feature"
|
||||||
|
---
|
||||||
|
|
||||||
|
## Describe your current issue/inconvinience
|
||||||
|
|
||||||
|
## Explain how this new feature will solve this
|
||||||
|
|
||||||
|
<br>
|
||||||
|
<!--Put an "x" inbetween the brackets to confirm-->
|
||||||
|
[ ] I have checked on codeberg and github and can confirm this issue is not a duplicate.
|
|
@ -2,7 +2,7 @@ window.browser = window.browser || window.chrome
|
||||||
|
|
||||||
import utils from "./utils.js"
|
import utils from "./utils.js"
|
||||||
|
|
||||||
let targets = ["odysee.com"]
|
const targets = [/^https?:\/{2}odysee\.com/]
|
||||||
|
|
||||||
const frontends = new Array("librarian")
|
const frontends = new Array("librarian")
|
||||||
const protocols = new Array("normal", "tor", "i2p", "loki")
|
const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||||
|
@ -36,6 +36,7 @@ let disableLbryTargets,
|
||||||
protocol,
|
protocol,
|
||||||
protocolFallback,
|
protocolFallback,
|
||||||
lbryTargetsRedirects,
|
lbryTargetsRedirects,
|
||||||
|
lbryRedirectType,
|
||||||
librarianNormalRedirectsChecks,
|
librarianNormalRedirectsChecks,
|
||||||
librarianNormalCustomRedirects,
|
librarianNormalCustomRedirects,
|
||||||
librarianTorRedirectsChecks,
|
librarianTorRedirectsChecks,
|
||||||
|
@ -53,6 +54,7 @@ function init() {
|
||||||
"protocol",
|
"protocol",
|
||||||
"protocolFallback",
|
"protocolFallback",
|
||||||
"lbryTargetsRedirects",
|
"lbryTargetsRedirects",
|
||||||
|
"lbryRedirectType",
|
||||||
"librarianNormalRedirectsChecks",
|
"librarianNormalRedirectsChecks",
|
||||||
"librarianNormalCustomRedirects",
|
"librarianNormalCustomRedirects",
|
||||||
"librarianTorRedirectsChecks",
|
"librarianTorRedirectsChecks",
|
||||||
|
@ -67,6 +69,7 @@ function init() {
|
||||||
protocol = r.protocol
|
protocol = r.protocol
|
||||||
protocolFallback = r.protocolFallback
|
protocolFallback = r.protocolFallback
|
||||||
lbryTargetsRedirects = r.lbryTargetsRedirects
|
lbryTargetsRedirects = r.lbryTargetsRedirects
|
||||||
|
lbryRedirectType = r.lbryRedirectType
|
||||||
librarianNormalRedirectsChecks = r.librarianNormalRedirectsChecks
|
librarianNormalRedirectsChecks = r.librarianNormalRedirectsChecks
|
||||||
librarianNormalCustomRedirects = r.librarianNormalCustomRedirects
|
librarianNormalCustomRedirects = r.librarianNormalCustomRedirects
|
||||||
librarianTorRedirectsChecks = r.librarianTorRedirectsChecks
|
librarianTorRedirectsChecks = r.librarianTorRedirectsChecks
|
||||||
|
@ -86,6 +89,24 @@ function all() {
|
||||||
return [...redirects.librarian.normal, ...redirects.librarian.tor, ...librarianNormalCustomRedirects, ...librarianTorCustomRedirects, ...librarianI2pCustomRedirects, ...librarianLokiCustomRedirects]
|
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) {
|
function switchInstance(url, disableOverride) {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
await init()
|
await init()
|
||||||
|
@ -122,37 +143,27 @@ function switchInstance(url, disableOverride) {
|
||||||
function redirect(url, type, initiator, disableOverride) {
|
function redirect(url, type, initiator, disableOverride) {
|
||||||
if (disableLbryTargets && !disableOverride) return
|
if (disableLbryTargets && !disableOverride) return
|
||||||
if (initiator && (all().includes(initiator.origin) || targets.includes(initiator.host))) return
|
if (initiator && (all().includes(initiator.origin) || targets.includes(initiator.host))) return
|
||||||
if (!targets.includes(url.host)) return
|
if (!targets.some(rx => rx.test(url.href))) return
|
||||||
if (type != ("main_frame" || "sub_frame")) return
|
if ((type == "main_frame" && lbryRedirectType == "sub_frame") || (type == "sub_frame" && lbryRedirectType == "main_frame")) return
|
||||||
//https://odysee.com/$/embed/the-anti-smartphone-revolution/22b482e450c4ca13c464eee8f51b3a52bbb942ae?r=7pAWcQybShS63wz486r8wVv9FpsDJ47A
|
|
||||||
// to
|
|
||||||
//https://{instance}/embed/@Coldfusion:f/the-anti-smartphone-revolution:2
|
|
||||||
|
|
||||||
let instancesList = []
|
const instancesList = getInstancesList()
|
||||||
switch (lbryFrontend) {
|
switch (type) {
|
||||||
case "librarian":
|
case "main_frame":
|
||||||
switch (protocol) {
|
switch (lbryFrontend) {
|
||||||
case "loki":
|
case "librarian":
|
||||||
instancesList = [...librarianLokiCustomRedirects]
|
if (instancesList.length === 0) return
|
||||||
break
|
const randomInstance = utils.getRandomInstance(instancesList)
|
||||||
case "i2p":
|
return `${randomInstance}${url.pathname}${url.search}`
|
||||||
instancesList = [...librarianI2pRedirectsChecks, ...librarianI2pCustomRedirects]
|
case "lbryDesktop":
|
||||||
break
|
if (type == "main_frame") {
|
||||||
case "tor":
|
return url.href.replace(/^https?:\/{2}odysee\.com\//, "lbry://").replace(/:(?=[a-zA-Z0-9])/g, "#")
|
||||||
instancesList = [...librarianTorRedirectsChecks, ...librarianTorCustomRedirects]
|
}
|
||||||
}
|
|
||||||
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
|
||||||
instancesList = [...librarianNormalRedirectsChecks, ...librarianNormalCustomRedirects]
|
|
||||||
}
|
|
||||||
break
|
|
||||||
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
|
if (instancesList.length === 0) return
|
||||||
|
const randomInstance = utils.getRandomInstance(instancesList)
|
||||||
|
return `${randomInstance}${url.pathname}${url.search}`.replace(/\/(?=[a-f0-9]{40})/, ":")
|
||||||
}
|
}
|
||||||
const randomInstance = utils.getRandomInstance(instancesList)
|
|
||||||
return `${randomInstance}${url.pathname}${url.search}`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function initDefaults() {
|
function initDefaults() {
|
||||||
|
@ -169,6 +180,7 @@ function initDefaults() {
|
||||||
disableLbryTargets: true,
|
disableLbryTargets: true,
|
||||||
lbryFrontend: "librarian",
|
lbryFrontend: "librarian",
|
||||||
lbryTargetsRedirects: redirects,
|
lbryTargetsRedirects: redirects,
|
||||||
|
lbryRedirectType: "both",
|
||||||
|
|
||||||
librarianNormalRedirectsChecks: [...redirects.librarian.normal],
|
librarianNormalRedirectsChecks: [...redirects.librarian.normal],
|
||||||
librarianNormalCustomRedirects: [],
|
librarianNormalCustomRedirects: [],
|
||||||
|
|
|
@ -40,53 +40,61 @@ async function initcloudflareBlackList() {
|
||||||
function updateInstances() {
|
function updateInstances() {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
let http = new XMLHttpRequest()
|
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://raw.githubusercontent.com/libredirect/libredirect/master/src/instances/data.json", false)
|
||||||
http.send(null)
|
http.send(null)
|
||||||
if (http.status === 200) {
|
if (http.status != 200) {
|
||||||
await initcloudflareBlackList()
|
fallback.open("GET", "https://codeberg.org/LibRedirect/libredirect/raw/branch/master/src/instances/data.json", false)
|
||||||
const instances = JSON.parse(http.responseText)
|
fallback.send(null)
|
||||||
|
if (fallback.status === 200) {
|
||||||
youtubeHelper.setRedirects({
|
http = fallback
|
||||||
invidious: instances.invidious,
|
} else {
|
||||||
piped: instances.piped,
|
resolve()
|
||||||
pipedMaterial: instances.pipedMaterial,
|
return
|
||||||
})
|
}
|
||||||
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)
|
|
||||||
|
|
||||||
console.info("Successfully updated Instances")
|
|
||||||
resolve(true)
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
resolve()
|
await initcloudflareBlackList()
|
||||||
|
const instances = JSON.parse(http.responseText)
|
||||||
|
|
||||||
|
youtubeHelper.setRedirects({
|
||||||
|
invidious: instances.invidious,
|
||||||
|
piped: instances.piped,
|
||||||
|
pipedMaterial: instances.pipedMaterial,
|
||||||
|
})
|
||||||
|
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)
|
||||||
|
|
||||||
|
console.info("Successfully updated Instances")
|
||||||
|
resolve(true)
|
||||||
|
return
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -431,7 +431,7 @@ def searx_searxng():
|
||||||
searxngList['tor'].append(item[:-1])
|
searxngList['tor'].append(item[:-1])
|
||||||
else:
|
else:
|
||||||
searxList['tor'].append(item[:-1])
|
searxList['tor'].append(item[:-1])
|
||||||
elif re.search(torRegex, item[:-1]):
|
elif re.search(i2pRegex, item[:-1]):
|
||||||
if (rJson['instances'][item].get('generator') == 'searxng'):
|
if (rJson['instances'][item].get('generator') == 'searxng'):
|
||||||
searxngList['i2p'].append(item[:-1])
|
searxngList['i2p'].append(item[:-1])
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -2209,6 +2209,14 @@
|
||||||
<option value="lbryDesktop" data-localise="__MSG_lbryDesktop__">LBRY Desktop</option>
|
<option value="lbryDesktop" data-localise="__MSG_lbryDesktop__">LBRY Desktop</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="some-block option-block">
|
||||||
|
<h4 data-localise="__MSG_redirectType__">Redirect Type</h4>
|
||||||
|
<select id="lbry-redirect_type">
|
||||||
|
<option value="both" data-localise="__MSG_both__">both</option>
|
||||||
|
<option value="sub_frame" data-localise="__MSG_onlyEmbedded__">Only Embedded</option>
|
||||||
|
<option value="main_frame" data-localise="__MSG_onlyNotEmbedded__">Only Not Embedded</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
<div id="librarian">
|
<div id="librarian">
|
||||||
<hr>
|
<hr>
|
||||||
<div class="normal">
|
<div class="normal">
|
||||||
|
|
|
@ -5,6 +5,7 @@ const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||||
|
|
||||||
const enable = document.getElementById("lbry-enable")
|
const enable = document.getElementById("lbry-enable")
|
||||||
const lbry = document.getElementById("lbry_page")
|
const lbry = document.getElementById("lbry_page")
|
||||||
|
const redirectType = document.getElementById("lbry-redirect_type")
|
||||||
const frontend = document.getElementById("lbry-frontend")
|
const frontend = document.getElementById("lbry-frontend")
|
||||||
let protocol
|
let protocol
|
||||||
|
|
||||||
|
@ -33,9 +34,10 @@ function changeProtocolSettings() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
browser.storage.local.get(["disableLbryTargets", "protocol", "lbryFrontend"], r => {
|
browser.storage.local.get(["disableLbryTargets", "protocol", "lbryFrontend", "lbryRedirectType"], r => {
|
||||||
enable.checked = !r.disableLbryTargets
|
enable.checked = !r.disableLbryTargets
|
||||||
protocol = r.protocol
|
protocol = r.protocol
|
||||||
|
redirectType.value = r.lbryRedirectType
|
||||||
frontend.value = r.lbryFrontend
|
frontend.value = r.lbryFrontend
|
||||||
changeFrontendsSettings()
|
changeFrontendsSettings()
|
||||||
changeProtocolSettings()
|
changeProtocolSettings()
|
||||||
|
@ -44,6 +46,7 @@ browser.storage.local.get(["disableLbryTargets", "protocol", "lbryFrontend"], r
|
||||||
lbry.addEventListener("change", () => {
|
lbry.addEventListener("change", () => {
|
||||||
browser.storage.local.set({
|
browser.storage.local.set({
|
||||||
disableLbryTargets: !enable.checked,
|
disableLbryTargets: !enable.checked,
|
||||||
|
lbryRedirectType: redirectType.value,
|
||||||
lbryFrontend: frontend.value,
|
lbryFrontend: frontend.value,
|
||||||
})
|
})
|
||||||
changeFrontendsSettings()
|
changeFrontendsSettings()
|
||||||
|
|
|
@ -12,6 +12,13 @@ section#lbry_page.option-block
|
||||||
option(value="librarian") Librarian
|
option(value="librarian") Librarian
|
||||||
option(value="lbryDesktop" data-localise="__MSG_lbryDesktop__") LBRY Desktop
|
option(value="lbryDesktop" data-localise="__MSG_lbryDesktop__") LBRY Desktop
|
||||||
|
|
||||||
|
.some-block.option-block
|
||||||
|
h4(data-localise="__MSG_redirectType__") Redirect Type
|
||||||
|
select#lbry-redirect_type
|
||||||
|
option(value="both" data-localise="__MSG_both__") both
|
||||||
|
option(value="sub_frame" data-localise="__MSG_onlyEmbedded__") Only Embedded
|
||||||
|
option(value="main_frame" data-localise="__MSG_onlyNotEmbedded__") Only Not Embedded
|
||||||
|
|
||||||
#librarian
|
#librarian
|
||||||
hr
|
hr
|
||||||
.normal
|
.normal
|
||||||
|
|
Loading…
Reference in New Issue