add unique redirect for gallery links
Closes https://github.com/tom-james-watson/old-reddit-redirect/issues/60 A gallery link in the form https://www.reddit.com/gallery/qnjjvh can be redirected to https://old.reddit.com/r/OnePiece/comments/qnjjvh/marines_as_shinigami_by_norridzuan_art. We only have the id to work with, but reddit will actually redirect https://old.reddit.com/qnjjvh to the full url, so we can just redirect to that instead.
This commit is contained in:
parent
92e7ecd25e
commit
7e41360e60
|
@ -1,5 +1,11 @@
|
||||||
const oldReddit = "https://old.reddit.com";
|
const oldReddit = "https://old.reddit.com";
|
||||||
const excludedPaths = ["/gallery", "/poll", "/rpan", "/settings", "/topics", "/community-points"];
|
const excludedPaths = [
|
||||||
|
"/poll",
|
||||||
|
"/rpan",
|
||||||
|
"/settings",
|
||||||
|
"/topics",
|
||||||
|
"/community-points",
|
||||||
|
];
|
||||||
|
|
||||||
chrome.webRequest.onBeforeRequest.addListener(
|
chrome.webRequest.onBeforeRequest.addListener(
|
||||||
function (details) {
|
function (details) {
|
||||||
|
@ -11,6 +17,10 @@ chrome.webRequest.onBeforeRequest.addListener(
|
||||||
if (url.pathname.indexOf(path) === 0) return;
|
if (url.pathname.indexOf(path) === 0) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (url.pathname.indexOf("/gallery") === 0) {
|
||||||
|
return { redirectUrl: oldReddit + url.pathname.slice("/gallery".length) };
|
||||||
|
}
|
||||||
|
|
||||||
return { redirectUrl: oldReddit + url.pathname + url.search + url.hash };
|
return { redirectUrl: oldReddit + url.pathname + url.search + url.hash };
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "Old Reddit Redirect",
|
"name": "Old Reddit Redirect",
|
||||||
"description": "Ensure Reddit always loads the old design",
|
"description": "Ensure Reddit always loads the old design",
|
||||||
"version": "1.5.1",
|
"version": "1.6.0",
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"background": { "scripts": ["background.js"] },
|
"background": { "scripts": ["background.js"] },
|
||||||
"icons": {
|
"icons": {
|
||||||
|
|
Loading…
Reference in New Issue