Updated reddit targets, actually fixed peertube redirects

This commit is contained in:
Hygna 2022-10-16 11:00:11 +01:00
parent 5ec2dca381
commit 2e1534e579
No known key found for this signature in database
2 changed files with 11 additions and 11 deletions

View File

@ -46,12 +46,14 @@ function all(service, frontend, options, config, redirects) {
}
function regexArray(service, url, config) {
let targetList
if (config.services[service].targets == "datajson") targetList = targets[service]
else targetList = config.services[service].targets
for (const targetString in targetList) {
const target = new RegExp(targetList[targetString])
if (target.test(url.href)) return true
if (config.services[service].targets == "datajson") {
if (targets[service].includes(utils.protocolHost(url))) return true
} else {
const targetList = config.services[service].targets
for (const targetString in targetList) {
const target = new RegExp(targetList[targetString])
if (target.test(url.href)) return true
}
}
return false
}
@ -398,9 +400,7 @@ function redirect(url, type, initiator, forceRedirection) {
if (url.href.search(/^https?:\/{2}(?:[im]\.)?stack\./) > -1) return `${randomInstance}/stack${url.pathname}${url.search}`
else return `${randomInstance}${url.pathname}${url.search}`
case "libreddit":
if (url.hostname.match(/^(i|preview)\.redd\.it/)) {
return `${randomInstance}/img${url.pathname}`
}
if (url.hostname.match(/^(i|preview)\.redd\.it/)) return `${randomInstance}/img${url.pathname}`
return `${randomInstance}${url.pathname}${url.search}`
default:
return `${randomInstance}${url.pathname}${url.search}`

View File

@ -93,7 +93,7 @@
}
},
"targets": [
"^https?:\\/{2}(?:www\\.|m\\.|)youtube.com(?!(?:iframe_api\\/.*)|(?:\/redirect))",
"^https?:\\/{2}(?:www\\.|m\\.|)youtube.com(?!(?:iframe_api\\/.*)|(?:\\/redirect))",
"^https?:\\/{2}img\\.youtube.com\\/vi\\/.*\\/..*",
"^https?:\\/{2}(?:i|s)\\.ytimg.com\\/vi\\/.*\\/..*",
"^https?:\\/{2}(?:www\\.|music\\.|)youtube.com\\/watch?v=..*",
@ -293,7 +293,7 @@
}
},
"targets": [
"^https?:\\/{2}(www\\.|old\\.|np\\.|new\\.|amp\\.|)reddit\\.com",
"^https?:\\/{2}(www\\.|old\\.|np\\.|new\\.|amp\\.|)reddit\\.com(?!\\/(gallery)|(rpan)|(settings)|(topics)|(dev))",
"^https?:\\/{2}(i\\.|preview\\.)redd\\.it"
],
"name": "Reddit",