Added preview.redd.it for libreddit

This commit is contained in:
ManeraKai 2022-03-13 22:10:29 +03:00
parent fbbc82d0f2
commit fb123d5575
No known key found for this signature in database
GPG Key ID: 5ABC31FFD562E337
1 changed files with 12 additions and 1 deletions

View File

@ -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);