diff --git a/background.js b/background.js index 7451fb5..edb050a 100644 --- a/background.js +++ b/background.js @@ -1,16 +1,22 @@ const oldReddit = "https://old.reddit.com"; +const excludedPaths = [ + "/gallery", + "/poll", + "/rpan", + "/settings", + "/topics"]; chrome.webRequest.onBeforeRequest.addListener( function(details) { - // Exclude poll pages - if (details.url.match(/^https?:\/\/(www\.)*reddit.com\/poll/)) { - return; + const url = new URL(details.url); + + if (url.hostname === "old.reddit.com") return; + + for (const path of excludedPaths) { + if (url.pathname.indexOf(path) === 0) return; } - - return { - redirectUrl: - oldReddit + details.url.match(/^https?:\/\/[^\/]+([\S\s]*)/)[1] - }; + + return {redirectUrl: oldReddit + url.pathname + url.search + url.hash}; }, { urls: [ diff --git a/manifest.json b/manifest.json index ab1a987..2c27b34 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "Old Reddit Redirect", "description": "Ensure Reddit always loads the old design", - "version": "1.1.4", + "version": "1.2.0", "manifest_version": 2, "background": {"scripts":["background.js"]}, "icons": {