From 1adf9ce6331a074bc8edc5097cadd4a3cc04241e Mon Sep 17 00:00:00 2001 From: magnolia1234 <54500520+magnolia1234@users.noreply.github.com> Date: Wed, 23 Oct 2019 13:06:43 +0200 Subject: [PATCH] Add Le Monde & maintenance background.js Removing Le Monde paywall while keeping article recommendations in paywall-container. Also removes persistent cookie-banner which links to google.com (only visible with extension). Maintenance: sites only in remove_cookies settings are obsolete because cookies are erased by default (when not in allow_cookies). --- README.md | 1 + background.js | 100 +++++++++++++++++++++-------------------------- contentScript.js | 20 +++++++++- manifest.json | 18 +++++---- options.js | 1 + 5 files changed, 75 insertions(+), 65 deletions(-) diff --git a/README.md b/README.md index 13f7f3d..f2980ac 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ [Inc.com](https://www.inc.com)\ [Investors Chronicle](https://www.investorschronicle.co.uk)\ [La Repubblica](https://www.repubblica.it)\ +[Le Monde](https://www.lemonde.fr)\ [Le Temps](https://www.letemps.ch)\ [Los Angeles Times](https://www.latimes.com)\ [Medium](https://www.medium.com)\ diff --git a/background.js b/background.js index 485c953..17d041e 100644 --- a/background.js +++ b/background.js @@ -31,6 +31,7 @@ var defaultSites = { 'Inc.com': 'inc.com', 'Investors Chronicle': 'investorschronicle.co.uk', 'La Repubblica': 'repubblica.it', + 'Le Monde': 'lemonde.fr', 'Le Temps': 'letemps.ch', 'Los Angeles Times': 'latimes.com', 'Medium': 'medium.com', @@ -74,7 +75,7 @@ var defaultSites = { 'The Spectator': 'spectator.co.uk', 'The Seattle Times': 'seattletimes.com', 'The Sydney Morning Herald': 'smh.com.au', - 'The Telegraph': 'telegraph.co.uk', + 'The Telegraph': 'telegraph.co.uk', 'The Times': 'thetimes.co.uk', 'The Toronto Star': 'thestar.com', 'The Washington Post': 'washingtonpost.com', @@ -92,78 +93,65 @@ const restrictions = { // Don't remove cookies before page load const allow_cookies = [ +'ad.nl', 'asia.nikkei.com', -'nytimes.com', -'wsj.com', -'ft.com', -'letemps.ch', -'mercurynews.com', -'economist.com', 'bostonglobe.com', 'denverpost.com', -'hacked.com', -'ocregister.com', -'newstatesman.com', -'spectator.co.uk', -'towardsdatascience.com', -'medium.com', -'theadvocate.com.au', -'examiner.com.au', -'thestar.com', -'washingtonpost.com', -'hbr.org', -'nymag.com', -'theaustralian.com.au', -'ad.nl', +'economist.com', 'ed.nl', +'examiner.com.au', +'ft.com', +'hacked.com', +'hbr.org', +'lemonde.fr', +'letemps.ch', +'medium.com', +'mercurynews.com', +'newstatesman.com', +'nymag.com', +'nytimes.com', +'ocregister.com', 'parool.nl', +'spectator.co.uk', 'telegraaf.nl', +'theadvocate.com.au', +'theaustralian.com.au', +'thestar.com', +'towardsdatascience.com', 'trouw.nl', 'vn.nl', -'volkskrant.nl' +'volkskrant.nl', +'washingtonpost.com', +'wsj.com', ] // Removes cookies after page load const remove_cookies = [ +'ad.nl', 'asia.nikkei.com', -'nytimes.com', -'ft.com', -'letemps.ch', -'mercurynews.com', -'theage.com.au', -'economist.com', 'bostonglobe.com', 'denverpost.com', -'hacked.com', -'ocregister.com', -'newstatesman.com', -'spectator.co.uk', -'towardsdatascience.com', -'medium.com', -'theadvocate.com.au', -'examiner.com.au', -'thestar.com', -'centralwesterndaily.com.au', -'theherald.com.au', -'foreignpolicy.com', -'wsj.com', -'glassdoor.com', -'cen.acs.org', -'hbr.org', -'thenewsrep.com', -'washingtonpost.com', -'nymag.com', -'nationalpost.com', -'handelsblatt.com', -'thediplomat.com', -'latimes.com', -'theatlantic.com', -'chicagobusiness.com', -'qz.com', -'ad.nl', +'economist.com', 'ed.nl', +'examiner.com.au', +'ft.com', +'hacked.com', +'hbr.org', +'letemps.ch', +'medium.com', +'mercurynews.com', +'newstatesman.com', +'nymag.com', +'nytimes.com', +'ocregister.com', +'spectator.co.uk', 'telegraaf.nl', -'vn.nl' +'theadvocate.com.au', +'thestar.com', +'towardsdatascience.com', +'vn.nl', +'washingtonpost.com', +'wsj.com', ] // Override User-Agent with Googlebot diff --git a/contentScript.js b/contentScript.js index 432ce87..bbbc6f8 100644 --- a/contentScript.js +++ b/contentScript.js @@ -127,7 +127,25 @@ if (window.location.href.indexOf("parool.nl") !== -1 || window.location.href.ind }); } -function removeDOMElement(elements) { +if (window.location.href.indexOf('lemonde.fr') !== -1) { + document.addEventListener('DOMContentLoaded', () => { + const hidden_section = document.getElementsByClassName('article__content--restricted-media')[0]; + if (hidden_section) + hidden_section.classList.remove('article__content--restricted-media'); + const longform_article_restricted = document.getElementsByClassName('article__content--restricted')[0]; + if (longform_article_restricted) + longform_article_restricted.classList.remove('article__content--restricted'); + const longform_paywall = document.getElementsByClassName('paywall--longform')[0]; + if (longform_paywall) + longform_paywall.classList.remove('paywall--longform'); + const paywall = document.getElementById('js-paywall-content'); + const friend_paywall = document.getElementsByClassName('friend--paywall')[0]; + const cookie_banner = document.getElementById('cookie-banner'); + removeDOMElement(paywall, friend_paywall, cookie_banner); + }); +} + +function removeDOMElement(...elements) { for (let element of elements) { if (element) element.remove(); } diff --git a/manifest.json b/manifest.json index 3873395..556766b 100644 --- a/manifest.json +++ b/manifest.json @@ -5,18 +5,19 @@ "content_scripts": [ { "matches": [ - "*://*.bizjournals.com/*", - "*://*.businessinsider.com/*", - "*://*.haaretz.co.il/*", - "*://*.nzherald.co.nz/*", - "*://*.repubblica.it/*", - "*://*.washingtonpost.com/*", + "*://*.bizjournals.com/*", + "*://*.bloomberg.com/*", + "*://*.businessinsider.com/*", "*://*.ed.nl/*", + "*://*.haaretz.co.il/*", + "*://*.lemonde.fr/*", + "*://*.nzherald.co.nz/*", "*://*.parool.nl/*", + "*://*.repubblica.it/*", "*://*.telegraaf.nl/*", "*://*.trouw.nl/*", "*://*.volkskrant.nl/*", - "*://*.bloomberg.com/*" + "*://*.washingtonpost.com/*" ], "js": ["contentScript.js"] } @@ -136,7 +137,8 @@ "*://*.parool.nl/*", "*://*.telegraaf.nl/*", "*://*.trouw.nl/*", - "*://*.vn.nl/*" + "*://*.vn.nl/*", + "*://*.lemonde.fr/*" ], "version": "1.5.9" } diff --git a/options.js b/options.js index dfc1a74..19a0d34 100644 --- a/options.js +++ b/options.js @@ -29,6 +29,7 @@ var defaultSites = { 'Inc.com': 'inc.com', 'Investors Chronicle': 'investorschronicle.co.uk', 'La Repubblica': 'repubblica.it', + 'Le Monde': 'lemonde.fr', 'Le Temps': 'letemps.ch', 'Los Angeles Times': 'latimes.com', 'Medium': 'medium.com',