2019-01-09 00:29:22 -05:00
|
|
|
const oldReddit = "https://old.reddit.com";
|
2021-01-23 08:40:00 -05:00
|
|
|
const excludedPaths = ["/gallery", "/poll", "/rpan", "/settings", "/topics"];
|
2018-04-25 10:43:21 -04:00
|
|
|
|
|
|
|
chrome.webRequest.onBeforeRequest.addListener(
|
2021-01-23 08:40:00 -05:00
|
|
|
function (details) {
|
2020-07-18 16:01:26 -04:00
|
|
|
const url = new URL(details.url);
|
2021-01-23 08:40:00 -05:00
|
|
|
|
2020-07-18 16:01:26 -04:00
|
|
|
if (url.hostname === "old.reddit.com") return;
|
2021-01-23 08:40:00 -05:00
|
|
|
|
2020-07-16 09:01:19 -04:00
|
|
|
for (const path of excludedPaths) {
|
2020-07-18 16:01:26 -04:00
|
|
|
if (url.pathname.indexOf(path) === 0) return;
|
2018-11-20 01:59:07 -05:00
|
|
|
}
|
2021-01-23 08:40:00 -05:00
|
|
|
|
|
|
|
return { redirectUrl: oldReddit + url.pathname + url.search + url.hash };
|
2018-04-25 10:43:21 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
urls: [
|
|
|
|
"*://reddit.com/*",
|
|
|
|
"*://www.reddit.com/*",
|
2018-05-03 09:10:45 -04:00
|
|
|
"*://np.reddit.com/*",
|
2020-05-19 13:29:04 -04:00
|
|
|
"*://amp.reddit.com/*",
|
2021-01-24 06:07:25 -05:00
|
|
|
"*://i.reddit.com/*",
|
2018-04-25 10:43:21 -04:00
|
|
|
],
|
2019-01-09 00:29:22 -05:00
|
|
|
types: [
|
|
|
|
"main_frame",
|
|
|
|
"sub_frame",
|
|
|
|
"stylesheet",
|
|
|
|
"script",
|
|
|
|
"image",
|
|
|
|
"object",
|
|
|
|
"xmlhttprequest",
|
2021-01-23 08:40:00 -05:00
|
|
|
"other",
|
|
|
|
],
|
2018-04-25 10:43:21 -04:00
|
|
|
},
|
|
|
|
["blocking"]
|
2019-01-09 00:29:22 -05:00
|
|
|
);
|