Add exception system

This commit is contained in:
Michał Szopiński 2020-07-16 13:31:36 +02:00
parent 9f06826bed
commit 90181d4125
1 changed files with 8 additions and 0 deletions

View File

@ -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};
},
{