From 90181d412526e99435fb56dd99f0f456b94f55fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Szopi=C5=84ski?= Date: Thu, 16 Jul 2020 13:31:36 +0200 Subject: [PATCH] Add exception system --- background.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/background.js b/background.js index 9c28008..cefa8c1 100644 --- a/background.js +++ b/background.js @@ -1,4 +1,6 @@ const oldReddit = "https://old.reddit.com"; +const excludedSubdomains = ["blog.reddit.com", "oauth.reddit.com", "out.reddit.com"]; +const excludedPaths = ["/poll", "/gallery", "/rpan", "/settings"]; chrome.webRequest.onBeforeRequest.addListener( function(details) { @@ -7,6 +9,12 @@ chrome.webRequest.onBeforeRequest.addListener( if (urlParser.hostname == "old.reddit.com") return; + if (excludedSubdomains.indexOf(urlParser.hostname) != -1) return; + + for (const path of excludedPaths) + if (urlParser.pathname.indexOf(path) == 0) + return; + return {redirectUrl: oldReddit + urlParser.pathname}; }, {