From 3f7484e5cee5e408fc028322efeb4ff4c9d968e5 Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Mon, 19 Oct 2020 17:06:31 +0200 Subject: [PATCH] Add The New York Review of Books --- README.md | 1 + background.js | 1 + changelog.txt | 1 + contentScript.js | 26 +++++++++++++++++--------- manifest.json | 3 ++- sites.js | 1 + 6 files changed, 23 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 5ac0f8e..476a5a2 100755 --- a/README.md +++ b/README.md @@ -73,6 +73,7 @@ Visit the [Firefox repository](https://bitbucket.org/magnolia1234/bypass-paywall [The Christian Science Monitor](https://www.csmonitor.com) - [The Nation](https://www.thenation.com) - [The New Republic](https://newrepublic.com) - +[The New York Review of Books](https://www.nybooks.com) - [The New York Times](https://www.nytimes.com) - [The New Yorker](https://www.newyorker.com) - [The Washington Post](https://www.washingtonpost.com) - diff --git a/background.js b/background.js index d35be6c..71353d1 100755 --- a/background.js +++ b/background.js @@ -63,6 +63,7 @@ var allow_cookies = [ 'nknews.org', 'noordhollandsdagblad.nl', 'nrz.de', +'nybooks.com', 'nytimes.com', 'nzz.ch', 'parool.nl', diff --git a/changelog.txt b/changelog.txt index 6b1bdb7..790c509 100644 --- a/changelog.txt +++ b/changelog.txt @@ -2,6 +2,7 @@ Changelog Bypass Paywalls Clean - Chrome Post-release +Add The New York Review of Books * v1.9.1.1 (2020-10-19) Hotfix remove cookies (www) diff --git a/contentScript.js b/contentScript.js index 566d36e..7c1eb76 100755 --- a/contentScript.js +++ b/contentScript.js @@ -815,15 +815,17 @@ else if (matchDomain('faz.net')) { str = str.replace(/(?:^|[\w\"\“])(\.|\?|!)(?=[A-ZÖÜ\„][A-Za-zÀ-ÿ\„]{1,})/gm, "$&\n\n"); str = str.replace(/([a-z\"\“])(?=[A-Z](?=[A-Za-zÀ-ÿ]+))/gm, "$&\n\n"); // exceptions: names with alternating lower/uppercase (no general fix) - str = str.replace(/Glaxo\n\nSmith\n\nKline/g, "GlaxoSmithKline"); - str = str.replace(/Ba\n\nFin/g, "BaFin"); - str = str.replace(/Bil\n\nMoG/g, "BilMoG"); - str = str.replace(/Eu\n\nGH/g, "EuGH"); - str = str.replace(/If\n\nSG/g, "IfSG"); - str = str.replace(/med\n\nRxiv/g, "medRxiv"); - str = str.replace(/m\n\nRNA/g, "mNRA"); - str = str.replace(/St\n\nVO/g, "StVO"); - str = str.replace(/Berl\n\nHG/g, "BerlHG"); + let str_rep_arr = ["BaFin", "BerlHG", "BilMoG", "EuGH", "GlaxoSmithKline", "IfSG", "iMessage", "iOS", "iPad", "iPhone", "medRxiv", "mNRA", "StVO"]; + let str_rep_split, str_rep_src; + for (let str_rep of str_rep_arr) { + str_rep_split = str_rep.split(/([a-z]+)(?=[A-Z](?=[A-Za-z]+))/); + str_rep_src = str_rep_split.reduce(function (accumulator, currentValue) { + return accumulator + currentValue + ((currentValue !== currentValue.toUpperCase()) ? '\n\n' : ''); + }); + if (str_rep_src.endsWith('\n\n')) + str_rep_src = str_rep_src.slice(0, -2); + str = str.replace(new RegExp(str_rep_src, "g"), str_rep); + } str = str.replace(/De\n\n([A-Z])/g, "De$1"); str = str.replace(/La\n\n([A-Z])/g, "La$1"); str = str.replace(/Le\n\n([A-Z])/g, "Le$1"); @@ -1382,6 +1384,12 @@ else if (matchDomain("quotidiano.net")) { } } +else if (matchDomain("nybooks.com")) { + let paywall_article = document.querySelector('.paywall-article'); + if (paywall_article) + paywall_article.classList.remove('paywall-article'); +} + // General Functions function removeDOMElement(...elements) { for (let element of elements) { diff --git a/manifest.json b/manifest.json index 082828f..07b1f3a 100644 --- a/manifest.json +++ b/manifest.json @@ -183,6 +183,7 @@ "*://*.nrc.nl/*", "*://*.nrz.de/*", "*://*.ntnews.com.au/*", + "*://*.nybooks.com/*", "*://*.nymag.com/*", "*://*.nytimes.com/*", "*://*.nzherald.co.nz/*", @@ -315,5 +316,5 @@ "webRequest", "webRequestBlocking" ], - "version": "1.9.1.1" + "version": "1.9.1.2" } \ No newline at end of file diff --git a/sites.js b/sites.js index 1498f9e..35da54e 100644 --- a/sites.js +++ b/sites.js @@ -176,6 +176,7 @@ var defaultSites = "The Nation": "thenation.com", "The New Republic": "newrepublic.com", "The New Statesman": "newstatesman.com", + "The New York Review of Books": "nybooks.com", "The New York Times": "nytimes.com", "The New Yorker": "newyorker.com", "The News-Gazette": "news-gazette.com",