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

View File

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