From fb123d5575dbcbbc8c92e895c306e0e38781a7b4 Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Sun, 13 Mar 2022 22:10:29 +0300 Subject: [PATCH] Added preview.redd.it for libreddit --- src/assets/javascripts/helpers/reddit.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/assets/javascripts/helpers/reddit.js b/src/assets/javascripts/helpers/reddit.js index eff5c0e..e434731 100644 --- a/src/assets/javascripts/helpers/reddit.js +++ b/src/assets/javascripts/helpers/reddit.js @@ -4,7 +4,7 @@ import commonHelper from './common.js' const targets = [ /^https?:\/\/(www\.|old\.|np\.|new\.|amp\.|)reddit\.com/, - /^https?:\/\/(i\.|)redd\.it/, + /^https?:\/\/(i\.|preview\.)redd\.it/, ]; let redirects = { // modern UI @@ -341,6 +341,17 @@ function redirect(url, type, initiator) { return `${tedditRandomInstance}/comments${url.pathname}${url.search}`; } } + else if (url.host === 'preview.redd.it') { + if (frontend == 'teddit') { + return null; + } + if (frontend == 'libreddit') { + if (libredditInstancesList.length === 0) return null; + let libredditRandomInstance = commonHelper.getRandomInstance(libredditInstancesList); + return `${libredditRandomInstance}/preview/pre${url.pathname}${url.search}`; + } + } + if (frontend == 'libreddit') { if (libredditInstancesList.length === 0) return null; let libredditRandomInstance = commonHelper.getRandomInstance(libredditInstancesList);