Merge pull request #34 from Lachcim/galleries

Collective fix for new Reddit features as of July 2020
This commit is contained in:
Tom Watson 2020-07-19 15:09:27 +02:00 committed by GitHub
commit ea26a03353
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 9 deletions

View File

@ -1,16 +1,22 @@
const oldReddit = "https://old.reddit.com";
const excludedPaths = [
"/gallery",
"/poll",
"/rpan",
"/settings",
"/topics"];
chrome.webRequest.onBeforeRequest.addListener(
function(details) {
// Exclude poll pages
if (details.url.match(/^https?:\/\/(www\.)*reddit.com\/poll/)) {
return;
const url = new URL(details.url);
if (url.hostname === "old.reddit.com") return;
for (const path of excludedPaths) {
if (url.pathname.indexOf(path) === 0) return;
}
return {
redirectUrl:
oldReddit + details.url.match(/^https?:\/\/[^\/]+([\S\s]*)/)[1]
};
return {redirectUrl: oldReddit + url.pathname + url.search + url.hash};
},
{
urls: [

View File

@ -1,7 +1,7 @@
{
"name": "Old Reddit Redirect",
"description": "Ensure Reddit always loads the old design",
"version": "1.1.4",
"version": "1.2.0",
"manifest_version": 2,
"background": {"scripts":["background.js"]},
"icons": {