Pail/background.js

42 lines
840 B
JavaScript
Raw Normal View History

const oldReddit = "https://old.reddit.com";
2020-07-16 07:52:58 -04:00
const excludedPaths = [
"/gallery",
"/poll",
"/rpan",
"/settings",
"/topics"];
2018-04-25 10:43:21 -04:00
chrome.webRequest.onBeforeRequest.addListener(
function(details) {
2020-07-18 16:01:26 -04:00
const url = new URL(details.url);
2020-07-16 07:15:38 -04:00
2020-07-18 16:01:26 -04:00
if (url.hostname === "old.reddit.com") return;
2020-07-16 07:15:38 -04: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
}
2020-07-16 07:31:36 -04:00
2020-07-18 16:01:26 -04: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/*",
2018-06-12 05:21:54 -04:00
"*://new.reddit.com/*",
"*://amp.reddit.com/*",
2018-04-25 10:43:21 -04:00
],
types: [
"main_frame",
"sub_frame",
"stylesheet",
"script",
"image",
"object",
"xmlhttprequest",
"other"
]
2018-04-25 10:43:21 -04:00
},
["blocking"]
);