Merge pull request #219 from jaki/handle-reddit-img
Redirect reddit images for libreddit instances
This commit is contained in:
commit
a45e7def92
|
@ -3,6 +3,7 @@ const targets = [
|
||||||
"np.reddit.com",
|
"np.reddit.com",
|
||||||
"new.reddit.com",
|
"new.reddit.com",
|
||||||
"amp.reddit.com",
|
"amp.reddit.com",
|
||||||
|
"i.redd.it",
|
||||||
];
|
];
|
||||||
const redirects = [
|
const redirects = [
|
||||||
// libreddit: privacy w/ modern UI
|
// libreddit: privacy w/ modern UI
|
||||||
|
|
|
@ -464,6 +464,20 @@ function redirectReddit(url, initiator, type) {
|
||||||
if (type !== "main_frame" || url.pathname.match(redditBypassPaths)) {
|
if (type !== "main_frame" || url.pathname.match(redditBypassPaths)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
if (url.host === "i.redd.it") {
|
||||||
|
if (redditInstance.includes("libredd")) {
|
||||||
|
return `${redditInstance}/img${url.pathname}${url.search}`;
|
||||||
|
} else if (redditInstance.includes("teddit")) {
|
||||||
|
// As of 2021-04-09, redirects for teddit images are nontrivial:
|
||||||
|
// - navigating to the image before ever navigating to its page causes
|
||||||
|
// 404 error (probably needs fix on teddit project)
|
||||||
|
// - some image links on teddit are very different
|
||||||
|
// Therefore, don't support redirecting image links for teddit.
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
return `${redditInstance}${url.pathname}${url.search}`;
|
return `${redditInstance}${url.pathname}${url.search}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue