diff options
Diffstat (limited to '')
| -rw-r--r-- | src/assets/javascripts/services.js | 16 | ||||
| -rw-r--r-- | src/config/config.json | 2 |
2 files changed, 16 insertions, 2 deletions
diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js index 8aa044ea..9c4205f6 100644 --- a/src/assets/javascripts/services.js +++ b/src/assets/javascripts/services.js @@ -400,7 +400,21 @@ 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}`
+ const subdomain = url.hostname.match(/^(?:(?:external-)?preview|i)(?=\.redd\.it)/)
+ if (!subdomain) return `${randomInstance}${url.pathname}${url.search}`
+ switch (subdomain[0]) {
+ case "preview":
+ return `${randomInstance}/preview/pre${url.pathname}${url.search}`
+ case "external-preview":
+ return `${randomInstance}/preview/external-pre${url.pathname}${url.search}`
+ case "i":
+ return `${randomInstance}/img${url.pathname}`
+ }
+ case "teddit":
+ if (/^(?:(?:external-)?preview|i)\.redd\.it/.test(url.hostname)) {
+ if (url.search == "") return `${randomInstance}${url.pathname}?teddit_proxy=${url.hostname}`
+ else return `${randomInstance}${url.pathname}${url.search}&teddit_proxy=${url.hostname}`
+ }
return `${randomInstance}${url.pathname}${url.search}`
default:
return `${randomInstance}${url.pathname}${url.search}`
diff --git a/src/config/config.json b/src/config/config.json index 13b069c1..7a8d2a78 100644 --- a/src/config/config.json +++ b/src/config/config.json @@ -253,7 +253,7 @@ "instanceList": true
}
},
- "targets": ["^https?:\\/{2}(www\\.|old\\.|np\\.|new\\.|amp\\.|)reddit\\.com(?=\\/u(ser)?\\/|\\/r\\/|\\/?$)", "^https?:\\/{2}(i\\.|preview\\.)redd\\.it"],
+ "targets": ["^https?:\\/{2}(www\\.|old\\.|np\\.|new\\.|amp\\.|)reddit\\.com(?=\\/u(ser)?\\/|\\/r\\/|\\/?$)", "^https?:\\/{2}(i\\.|(external-)?preview\\.|)redd\\.it"],
"name": "Reddit",
"options": {
"enabled": true,
|
