summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Brazell <simon@brazell.com.au>2021-04-16 09:34:39 +1000
committerGitHub <noreply@github.com>2021-04-16 09:34:39 +1000
commita45e7def927fc486a6494592fb8b6c49823ea9de (patch)
tree28e85696fc90e81a6062c36dae868cdbfdc0a5b3
parent74f5642cc5b1106913572505bbcb94d6480e247f (diff)
parent905abce8f778e9a3edbd69b9f3183c93d11edffa (diff)
downloadprivacy-redirect-a45e7def927fc486a6494592fb8b6c49823ea9de.tar.gz
privacy-redirect-a45e7def927fc486a6494592fb8b6c49823ea9de.tar.bz2
privacy-redirect-a45e7def927fc486a6494592fb8b6c49823ea9de.zip
Merge pull request #219 from jaki/handle-reddit-img
Redirect reddit images for libreddit instances
-rw-r--r--src/assets/javascripts/helpers/reddit.js1
-rw-r--r--src/pages/background/background.js14
2 files changed, 15 insertions, 0 deletions
diff --git a/src/assets/javascripts/helpers/reddit.js b/src/assets/javascripts/helpers/reddit.js
index dad6a06..a21b328 100644
--- a/src/assets/javascripts/helpers/reddit.js
+++ b/src/assets/javascripts/helpers/reddit.js
@@ -3,6 +3,7 @@ const targets = [
"np.reddit.com",
"new.reddit.com",
"amp.reddit.com",
+ "i.redd.it",
];
const redirects = [
// libreddit: privacy w/ modern UI
diff --git a/src/pages/background/background.js b/src/pages/background/background.js
index 4199ab1..fe42626 100644
--- a/src/pages/background/background.js
+++ b/src/pages/background/background.js
@@ -464,6 +464,20 @@ function redirectReddit(url, initiator, type) {
if (type !== "main_frame" || url.pathname.match(redditBypassPaths)) {
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}`;
}