From b7d68fda205e9b2b3e796fb27edcbcfa0bc5c00c Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Sat, 9 Jan 2021 17:45:21 +0100 Subject: [PATCH] Add New Left Review (United Kingdom) --- README.md | 1 + background.js | 3 ++- changelog.txt | 1 + contentScript.js | 31 +++++++++++++++++++++++++++++++ manifest.json | 3 ++- sites.js | 1 + 6 files changed, 38 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7e8890a..188dab3 100644 --- a/README.md +++ b/README.md @@ -160,6 +160,7 @@ Visit the [Chrome repository](https://gitlab.com/magnolia1234/bypass-paywalls-ch [Financial Times](https://www.ft.com) - [Irish Independent](https://www.independent.ie) - [London Review of Books](https://www.lrb.co.uk) - +[New Left Review](https://newleftreview.org) - [The Economist](https://www.economist.com) - [The Irish Times](https://www.irishtimes.com) - [The New Statesman](https://www.newstatesman.com) - diff --git a/background.js b/background.js index 61dc599..fd8cb59 100644 --- a/background.js +++ b/background.js @@ -4,7 +4,7 @@ var ext_api = (typeof browser === 'object') ? browser : chrome; var ext_name = ext_api.runtime.getManifest().name; -const cs_limit_except = ['afr.com', 'elcomercio.pe', 'elpais.com', 'faz.net', 'gestion.pe', 'harpers.org', 'inkl.com', 'la-croix.com', 'lescienze.it', 'techinasia.com']; +const cs_limit_except = ['afr.com', 'elcomercio.pe', 'elpais.com', 'faz.net', 'gestion.pe', 'harpers.org', 'inkl.com', 'la-croix.com', 'lescienze.it', 'newleftreview.org', 'techinasia.com']; var currentTabUrl = ''; var csDone = false; @@ -81,6 +81,7 @@ var allow_cookies_default = [ 'nationalgeographic.com', 'nationalpost.com', 'nationalreview.com', + 'newleftreview.org', 'newrepublic.com', 'noordhollandsdagblad.nl', 'nouvelobs.com', diff --git a/changelog.txt b/changelog.txt index 32a71d1..30435c5 100644 --- a/changelog.txt +++ b/changelog.txt @@ -3,6 +3,7 @@ Changelog Bypass Paywalls Clean - Firefox Post-release Add group TorStar (Canada) +Add New Left Review (United Kingdom) Fix-update Toronto Star (overlay) Update options (excluded sites) diff --git a/contentScript.js b/contentScript.js index 6997f78..6a44159 100644 --- a/contentScript.js +++ b/contentScript.js @@ -1891,6 +1891,37 @@ else if (matchDomain('seekingalpha.com')) { } } +else if (matchDomain('newleftreview.org')) { + let url = window.location.href; + let paywall = document.querySelector('div.promo-wrapper'); + if (paywall) { + let proxyurl = 'https://cors-anywhere.herokuapp.com/'; + let nlr_cache = 'https://webcache.googleusercontent.com/search?q=cache:' + url.split('//')[1]; + fetch(proxyurl + nlr_cache, { headers: {"Content-Type": "text/plain", "X-Requested-With": "XMLHttpRequest" } }) + .then(response => { + let article_old = document.querySelector('div.article-page'); + let footer = document.querySelector('div.article-footer'); + if (response.ok) { + response.text().then(html => { + let parser = new DOMParser(); + let doc = parser.parseFromString(html, 'text/html'); + let json = doc.querySelector('div.article-page'); + if (json) { + if (article_old && footer) { + removeDOMElement(article_old); + footer.parentElement.insertBefore(json, footer); + } + } + }); + } else { + if (article_old && footer) + article_old.appendChild(document.createTextNode('Article not yet in Google webcache ...')); + } + }); + removeDOMElement(paywall); + } +} + else if (matchDomain('lavanguardia.com')) { let paywall = document.querySelector('[class*="ev-open-modal-paywall"]'); let infinite_loading = document.querySelector('#infinite-loading'); diff --git a/manifest.json b/manifest.json index 7842a30..bd1d3db 100644 --- a/manifest.json +++ b/manifest.json @@ -256,6 +256,7 @@ "*://*.nautil.us/*", "*://*.neuepresse.de/*", "*://*.newcastleherald.com.au/*", + "*://*.newleftreview.org/*", "*://*.newrepublic.com/*", "*://*.news-gazette.com/*", "*://*.news-mail.com.au/*", @@ -420,5 +421,5 @@ "*://*.repstatic.it/*", "*://*.userzoom.com/*" ], - "version": "2.0.2.3" + "version": "2.0.2.4" } \ No newline at end of file diff --git a/sites.js b/sites.js index 05b4f94..f5c234b 100644 --- a/sites.js +++ b/sites.js @@ -138,6 +138,7 @@ var defaultSites = "National Review": "nationalreview.com", "Nautilus": "nautil.us", "Neue Zürcher Zeitung": "nzz.ch", + "New Left Review": "newleftreview.org", "New York Magazine (+ Grub Street, The Cut & Vulture)": "###_usa_nymag", "New Zealand Herald": "nzherald.co.nz", "Newsweek": "newsweek.com",