Skip to content

Commit

Permalink
Updated reddit targets, actually fixed peertube redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
Hygna committed Oct 16, 2022
1 parent 5ec2dca commit 2e1534e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions src/assets/javascripts/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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}`
Expand Down
4 changes: 2 additions & 2 deletions src/config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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=..*",
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 2e1534e

Please sign in to comment.