2019-01-09 00:29:22 -05:00
|
|
|
const oldReddit = "https://old.reddit.com";
|
2018-04-25 10:43:21 -04:00
|
|
|
|
|
|
|
chrome.webRequest.onBeforeRequest.addListener(
|
|
|
|
function(details) {
|
2018-11-20 01:59:07 -05:00
|
|
|
// Exclude poll pages
|
2019-01-09 00:29:22 -05:00
|
|
|
if (details.url.match(/^https?:\/\/(www\.)*reddit.com\/poll/)) {
|
|
|
|
return;
|
2018-11-20 01:59:07 -05:00
|
|
|
}
|
|
|
|
|
2019-01-09 00:29:22 -05:00
|
|
|
return {
|
|
|
|
redirectUrl:
|
|
|
|
oldReddit + details.url.match(/^https?:\/\/[^\/]+([\S\s]*)/)[1]
|
|
|
|
};
|
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/*",
|
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",
|
|
|
|
"other"
|
|
|
|
]
|
2018-04-25 10:43:21 -04:00
|
|
|
},
|
|
|
|
["blocking"]
|
2019-01-09 00:29:22 -05:00
|
|
|
);
|