From 4cda414dc34e68be795e2c1a25deaab1f63abe0a Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Wed, 27 Nov 2019 19:23:00 +0100 Subject: [PATCH 1/9] Fix Economist (only block external paywall-script) Includes new option to block external scripts on referring (enabled) domain. --- background.js | 69 ++++++++++++++++++++---------------------------- contentScript.js | 5 ++++ manifest.json | 6 +++-- options.js | 2 +- 4 files changed, 39 insertions(+), 43 deletions(-) diff --git a/background.js b/background.js index 9bee6aed..bf6c2bda 100644 --- a/background.js +++ b/background.js @@ -179,7 +179,6 @@ const remove_cookies = [ // select specific cookie(s) to hold from remove_cookies domains const remove_cookies_select_hold = { - 'nrc.nl': ['nmt_closed_cookiebar'], 'washingtonpost.com': ['wp_gdpr'], 'wsj.com': ['wsjregion'] } @@ -214,12 +213,14 @@ function setDefaultOptions() { }); } -const blockedRegexes = [ -/.+:\/\/.+\.tribdss\.com\//, -/thenation\.com\/.+\/paywall-script\.php/, -/haaretz\.co\.il\/htz\/js\/inter\.js/, -/nzherald\.co\.nz\/.+\/headjs\/.+\.js/ -]; +// to block external script also add domain to manifest.json (permissions) +const blockedRegexes = { +'chicagotribune.com': /.+:\/\/.+\.tribdss\.com\//, +'thenation.com': /thenation\.com\/.+\/paywall-script\.php/, +'haaretz.co.il': /haaretz\.co\.il\/htz\/js\/inter\.js/, +'nzherald.co.nz': /nzherald\.co\.nz\/.+\/headjs\/.+\.js/, +'economist.com': /.+\.tinypass\.com\/.+/ +}; const userAgentDesktop = "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" const userAgentMobile = "Chrome/41.0.2272.96 Mobile Safari/537.36 (compatible ; Googlebot/2.1 ; +http://www.google.com/bot.html)" @@ -259,31 +260,6 @@ browser.runtime.onInstalled.addListener(function(details) { } }); -/** -// WSJ bypass -browser.webRequest.onBeforeSendHeaders.addListener(function(details) { - if (!isSiteEnabled(details) || details.url.indexOf("mod=rsswn") !== -1 || details.url.indexOf("/print-edition/") !== -1) { - return; - } - - var param; - var updatedUrl; - - param = getParameterByName("mod", details.url); - - if (param === null) { - updatedUrl = stripQueryStringAndHashFromPath(details.url); - updatedUrl += "?mod=rsswn"; - } else { - updatedUrl = details.url.replace(param, "rsswn"); - } - return { redirectUrl: updatedUrl}; -}, -{urls:["*://*.wsj.com/*"], types:["main_frame"]}, -["blocking"] -); -**/ - // Disable javascript for these sites chrome.webRequest.onBeforeRequest.addListener(function(details) { if (!isSiteEnabled(details) || details.url.indexOf("mod=rsswn") !== -1) { @@ -292,24 +268,38 @@ chrome.webRequest.onBeforeRequest.addListener(function(details) { return {cancel: true}; }, { - urls: ["*://*.theglobeandmail.com/*", "*://*.economist.com/*", "*://*.thestar.com/*", "*://*.newstatesman.com/*", "*://*.bostonglobe.com/*", "*://*.afr.com/*"], + urls: ["*://*.theglobeandmail.com/*", "*://*.thestar.com/*", "*://*.newstatesman.com/*", "*://*.bostonglobe.com/*", "*://*.afr.com/*"], types: ["script"] }, ["blocking"] ); browser.webRequest.onBeforeSendHeaders.addListener(function(details) { - if (!isSiteEnabled(details)) { - return; + var requestHeaders = details.requestHeaders; + + var header_referer = ''; + for (var n in requestHeaders) { + if (requestHeaders[n].name.toLowerCase() == 'referer') { + header_referer = requestHeaders[n].value; + continue; + } + } + + // check for blocked regular expression: domain enabled, match regex, block on an internal or external regex + for (var domain in blockedRegexes) { + if (isSiteEnabled({url: '.'+ domain}) && details.url.match(blockedRegexes[domain])) { + if (details.url.indexOf(domain) !== -1 || header_referer.indexOf(domain) !== -1) { + return { cancel: true }; + } + } } - if (blockedRegexes.some(function(regex) { return regex.test(details.url); })) { - return { cancel: true }; + if (!isSiteEnabled(details)) { + return; } - var requestHeaders = details.requestHeaders; var tabId = details.tabId; - + var useUserAgentMobile = false; var setReferer = false; @@ -423,7 +413,6 @@ browser.webRequest.onCompleted.addListener(function(details) { if ((rc_domain in remove_cookies_select_drop) && !(remove_cookies_select_drop[rc_domain].includes(cookies[i].name))){ continue; // only remove specific cookie } - browser.cookies.remove(cookie); } }); diff --git a/contentScript.js b/contentScript.js index 2e2dc481..7bae6989 100644 --- a/contentScript.js +++ b/contentScript.js @@ -171,6 +171,11 @@ if (window.location.href.indexOf("caixinglobal.com") !== -1) { } } +if (window.location.href.indexOf("economist.com") !== -1) { + const wrapper = document.getElementById('bottom-page-wrapper'); + removeDOMElement(wrapper); +} + function removeDOMElement(...elements) { for (let element of elements) { if (element) element.remove(); diff --git a/manifest.json b/manifest.json index 5547dfa3..af18f934 100644 --- a/manifest.json +++ b/manifest.json @@ -20,7 +20,8 @@ "*://*.telegraaf.nl/*", "*://*.trouw.nl/*", "*://*.volkskrant.nl/*", - "*://*.washingtonpost.com/*" + "*://*.washingtonpost.com/*", + "*://*.economist.com/*" ], "js": ["contentScript.js"] } @@ -145,7 +146,8 @@ "*://*.lemonde.fr/*", "*://*.scientificamerican.com/*", "*://*.thehindu.com/*", - "*://*.demorgen.be/*" + "*://*.demorgen.be/*", + "*://*.tinypass.com/*" ], "version": "1.6.2" } diff --git a/options.js b/options.js index d5f73860..e9d7300a 100644 --- a/options.js +++ b/options.js @@ -17,7 +17,7 @@ var defaultSites = { 'De Groene Amsterdammer': 'groene.nl', 'De Tijd': 'tijd.be', 'de Volkskrant': 'volkskrant.nl', - 'The Economist (javascript disabled)': 'economist.com', + 'The Economist': 'economist.com', 'Eindhovens Dagblad': 'ed.nl', 'Examiner': 'examiner.com.au', 'Financial Times': 'ft.com', From a2ea42bf436a702c26ab654a26fc7bb130c27635 Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Tue, 3 Dec 2019 11:53:30 +0100 Subject: [PATCH 2/9] Add London Review of Books Block paywall script. --- README.md | 1 + background.js | 4 +++- options.js | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 64389b29..0a2ce70b 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ [La Repubblica](https://www.repubblica.it)\ [Le Monde](https://www.lemonde.fr)\ [Le Temps](https://www.letemps.ch)\ +[London Review of Books] (https://lrb.co.uk)\ [Los Angeles Times](https://www.latimes.com)\ [Medium](https://www.medium.com)\ [Medscape](https://www.medscape.com)\ diff --git a/background.js b/background.js index bf6c2bda..06ce2c38 100644 --- a/background.js +++ b/background.js @@ -35,6 +35,7 @@ var defaultSites = { 'La Repubblica': 'repubblica.it', 'Le Monde': 'lemonde.fr', 'Le Temps': 'letemps.ch', + 'London Review of Books': 'lrb.co.uk', 'Los Angeles Times': 'latimes.com', 'Medium': 'medium.com', 'Medscape': 'medscape.com', @@ -219,7 +220,8 @@ const blockedRegexes = { 'thenation.com': /thenation\.com\/.+\/paywall-script\.php/, 'haaretz.co.il': /haaretz\.co\.il\/htz\/js\/inter\.js/, 'nzherald.co.nz': /nzherald\.co\.nz\/.+\/headjs\/.+\.js/, -'economist.com': /.+\.tinypass\.com\/.+/ +'economist.com': /.+\.tinypass\.com\/.+/, +'lrb.co.uk': /.+\.tinypass\.com\/.+/ }; const userAgentDesktop = "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" diff --git a/options.js b/options.js index e9d7300a..cb4ce542 100644 --- a/options.js +++ b/options.js @@ -33,6 +33,7 @@ var defaultSites = { 'La Repubblica': 'repubblica.it', 'Le Monde': 'lemonde.fr', 'Le Temps': 'letemps.ch', + 'London Review of Books': 'lrb.co.uk', 'Los Angeles Times': 'latimes.com', 'Medium': 'medium.com', 'Medscape': 'medscape.com', From ee5092f09d3f985ae34d26eaa9cafd99fa1b53fd Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Tue, 3 Dec 2019 11:59:03 +0100 Subject: [PATCH 3/9] Update manifest.json for London Review of Books --- manifest.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index af18f934..4a7caa19 100644 --- a/manifest.json +++ b/manifest.json @@ -147,7 +147,8 @@ "*://*.scientificamerican.com/*", "*://*.thehindu.com/*", "*://*.demorgen.be/*", - "*://*.tinypass.com/*" + "*://*.tinypass.com/*", + "*://*.lrb.co.uk/*" ], "version": "1.6.2" } From b3713b52ecfc0c58c9b855372dcb069202ca86ac Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Thu, 5 Dec 2019 21:32:20 +0100 Subject: [PATCH 4/9] Add Times Literary Supplement --- README.md | 1 + background.js | 1 + contentScript.js | 5 +++++ manifest.json | 8 +++++--- options.js | 1 + 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0a2ce70b..f2710120 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,7 @@ [The Toronto Star](https://www.thestar.com)\ [The Washington Post](https://www.washingtonpost.com)\ [The Wall Street Journal](https://www.wsj.com)\ +[Times Literary Supplement](https://www.the-tls.co.uk)\ [Towards Data Science](https://www.towardsdatascience.com)\ [Trouw](https://www.trouw.nl)\ [Vanity Fair](https://www.vanityfair.com)\ diff --git a/background.js b/background.js index 06ce2c38..312e00f7 100644 --- a/background.js +++ b/background.js @@ -86,6 +86,7 @@ var defaultSites = { 'The Toronto Star': 'thestar.com', 'The Washington Post': 'washingtonpost.com', 'The Wall Street Journal': 'wsj.com', + 'Times Literary Supplement': 'the-tls.co.uk', 'Towards Data Science': 'towardsdatascience.com', 'Trouw': 'trouw.nl', 'Vanity Fair': 'vanityfair.com', diff --git a/contentScript.js b/contentScript.js index 7bae6989..6e8fc094 100644 --- a/contentScript.js +++ b/contentScript.js @@ -176,6 +176,11 @@ if (window.location.href.indexOf("economist.com") !== -1) { removeDOMElement(wrapper); } +if (window.location.href.indexOf("the-tls.co.uk") !== -1) { + const paywall = document.querySelector('.tls-subscriptions-banner__closed-skin'); + removeDOMElement(paywall); +} + function removeDOMElement(...elements) { for (let element of elements) { if (element) element.remove(); diff --git a/manifest.json b/manifest.json index 4a7caa19..c41cd6be 100644 --- a/manifest.json +++ b/manifest.json @@ -21,7 +21,8 @@ "*://*.trouw.nl/*", "*://*.volkskrant.nl/*", "*://*.washingtonpost.com/*", - "*://*.economist.com/*" + "*://*.economist.com/*", + "*://*.the-tls.co.uk/*" ], "js": ["contentScript.js"] } @@ -147,8 +148,9 @@ "*://*.scientificamerican.com/*", "*://*.thehindu.com/*", "*://*.demorgen.be/*", - "*://*.tinypass.com/*", - "*://*.lrb.co.uk/*" + "*://*.tinypass.com/*", + "*://*.lrb.co.uk/*", + "*://*.the-tls.co.uk/*" ], "version": "1.6.2" } diff --git a/options.js b/options.js index cb4ce542..9b980b41 100644 --- a/options.js +++ b/options.js @@ -84,6 +84,7 @@ var defaultSites = { 'The Toronto Star (javascript disabled)': 'thestar.com', 'The Washington Post': 'washingtonpost.com', 'The Wall Street Journal': 'wsj.com', + 'Times Literary Supplement': 'the-tls.co.uk', 'Towards Data Science': 'towardsdatascience.com', 'Trouw': 'trouw.nl', 'Vanity Fair': 'vanityfair.com', From c01e2680fcbd58efc668a52520f4b9332e93b7e9 Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Fri, 6 Dec 2019 16:15:49 +0100 Subject: [PATCH 5/9] Fix Economist timing (mobile) Refresh when still paywall, remove specific cookie and hold on to local storage. --- background.js | 1 + contentScript.js | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/background.js b/background.js index 312e00f7..a6e95caa 100644 --- a/background.js +++ b/background.js @@ -189,6 +189,7 @@ const remove_cookies_select_hold = { const remove_cookies_select_drop = { 'ad.nl': ['temptationTrackingId'], 'demorgen.be': ['TID_ID'], + 'economist.com': ['rvuuid'], 'ed.nl': ['temptationTrackingId'], 'nrc.nl': ['counter'] } diff --git a/contentScript.js b/contentScript.js index 6e8fc094..a0aad283 100644 --- a/contentScript.js +++ b/contentScript.js @@ -1,4 +1,11 @@ -window.localStorage.clear(); +var arr_localstorage_hold = ['economist.com']; +var localstorage_hold = arr_localstorage_hold.some(function(url) { + return window.location.href.indexOf(url) !== -1; +}); + +if (!localstorage_hold){ + window.localStorage.clear(); +} if (window.location.href.indexOf("bizjournals.com") !== -1) { const hiddenStory = document.getElementsByClassName( "js-pre-chunks__story-body" @@ -172,8 +179,16 @@ if (window.location.href.indexOf("caixinglobal.com") !== -1) { } if (window.location.href.indexOf("economist.com") !== -1) { - const wrapper = document.getElementById('bottom-page-wrapper'); - removeDOMElement(wrapper); + document.addEventListener('DOMContentLoaded', () => { + const wrapper = document.getElementById('bottom-page-wrapper'); + removeDOMElement(wrapper); + setTimeout(function () { + const paywall = document.querySelector('.layout-article-regwall');; + if (paywall) { + window.location.reload(true); + } + }, 600); // Delay (in milliseconds) + }); } if (window.location.href.indexOf("the-tls.co.uk") !== -1) { From d2af3e054a65008d7bd828e62b2e1baa6b86dd82 Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Sat, 7 Dec 2019 18:33:38 +0100 Subject: [PATCH 6/9] Fix Boston Globe Only block paywall-script + cookie-fix. --- background.js | 6 ++++-- options.js | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/background.js b/background.js index a6e95caa..8548b7d4 100644 --- a/background.js +++ b/background.js @@ -188,6 +188,7 @@ const remove_cookies_select_hold = { // select only specific cookie(s) to drop from remove_cookies domains const remove_cookies_select_drop = { 'ad.nl': ['temptationTrackingId'], + 'bostonglobe.com': ['FMPaywall'], 'demorgen.be': ['TID_ID'], 'economist.com': ['rvuuid'], 'ed.nl': ['temptationTrackingId'], @@ -223,7 +224,8 @@ const blockedRegexes = { 'haaretz.co.il': /haaretz\.co\.il\/htz\/js\/inter\.js/, 'nzherald.co.nz': /nzherald\.co\.nz\/.+\/headjs\/.+\.js/, 'economist.com': /.+\.tinypass\.com\/.+/, -'lrb.co.uk': /.+\.tinypass\.com\/.+/ +'lrb.co.uk': /.+\.tinypass\.com\/.+/, +'bostonglobe.com': /meter\.bostonglobe\.com\/js\/.+/ }; const userAgentDesktop = "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" @@ -272,7 +274,7 @@ chrome.webRequest.onBeforeRequest.addListener(function(details) { return {cancel: true}; }, { - urls: ["*://*.theglobeandmail.com/*", "*://*.thestar.com/*", "*://*.newstatesman.com/*", "*://*.bostonglobe.com/*", "*://*.afr.com/*"], + urls: ["*://*.theglobeandmail.com/*", "*://*.thestar.com/*", "*://*.newstatesman.com/*", "*://*.afr.com/*"], types: ["script"] }, ["blocking"] diff --git a/options.js b/options.js index 9b980b41..b82905c9 100644 --- a/options.js +++ b/options.js @@ -60,7 +60,7 @@ var defaultSites = { 'The Atlantic': 'theatlantic.com', 'The Australian': 'theaustralian.com.au', 'The Australian Financial Review (javascript disabled)': 'afr.com', - 'The Boston Globe (javascript disabled)': 'bostonglobe.com', + 'The Boston Globe': 'bostonglobe.com', 'The Business Journals': 'bizjournals.com', 'The Diplomat': 'thediplomat.com', 'The Globe and Mail (javascript disabled)': 'theglobeandmail.com', From d080b15c384bd57aaf7309e10e2dfdff2c2a74fc Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Sat, 7 Dec 2019 19:28:19 +0100 Subject: [PATCH 7/9] Add Harper's Magazine Already in Chrome extension. --- README.md | 1 + background.js | 3 +++ options.js | 1 + 3 files changed, 5 insertions(+) diff --git a/README.md b/README.md index f2710120..a57d857e 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ [Haaretz.co.il](https://www.haaretz.co.il)\ [Haaretz.com](https://www.haaretz.com)\ [Handelsblatt](https://www.handelsblatt.com)\ +[Harper's Magazine](https://harpers.org)\ [Hartford Courant](https://www.courant.com)\ [Harvard Business Review](https://www.hbr.org)\ [Inc.com](https://www.inc.com)\ diff --git a/background.js b/background.js index 8548b7d4..e88dcb6a 100644 --- a/background.js +++ b/background.js @@ -28,6 +28,7 @@ var defaultSites = { 'Haaretz': 'haaretz.co.il', 'Haaretz English': 'haaretz.com', 'Handelsblatt': 'handelsblatt.com', + 'Harper\'s Magazine': 'harpers.org', 'Hartford Courant': 'courant.com', 'Harvard Business Review': 'hbr.org', 'Inc.com': 'inc.com', @@ -112,6 +113,7 @@ const allow_cookies = [ 'examiner.com.au', 'ft.com', 'hacked.com', +'harpers.org', 'hbr.org', 'lemonde.fr', 'letemps.ch', @@ -155,6 +157,7 @@ const remove_cookies = [ 'examiner.com.au', 'ft.com', 'hacked.com', +'harpers.org', 'hbr.org', 'letemps.ch', 'medium.com', diff --git a/options.js b/options.js index b82905c9..beebbe11 100644 --- a/options.js +++ b/options.js @@ -26,6 +26,7 @@ var defaultSites = { 'Haaretz': 'haaretz.co.il', 'Haaretz English': 'haaretz.com', 'Handelsblatt': 'handelsblatt.com', + 'Harper\'s Magazine': 'harpers.org', 'Hartford Courant': 'courant.com', 'Harvard Business Review': 'hbr.org', 'Inc.com': 'inc.com', From 5e2a3aeed904aad813e07f727aa96c6e1fc7f470 Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Sat, 7 Dec 2019 19:32:35 +0100 Subject: [PATCH 8/9] Update manifest.json for Harper's Magazine --- manifest.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index c41cd6be..1fb4bb04 100644 --- a/manifest.json +++ b/manifest.json @@ -22,7 +22,8 @@ "*://*.volkskrant.nl/*", "*://*.washingtonpost.com/*", "*://*.economist.com/*", - "*://*.the-tls.co.uk/*" + "*://*.the-tls.co.uk/*", + "*://*.harpers.org/*" ], "js": ["contentScript.js"] } From 02bd16cf9690ddc5ab7acac9cbedc515bab8a5d5 Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Sat, 7 Dec 2019 19:51:06 +0100 Subject: [PATCH 9/9] Fix update manifest.json Harper's Magazine ... --- manifest.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/manifest.json b/manifest.json index 1fb4bb04..bddb8b6e 100644 --- a/manifest.json +++ b/manifest.json @@ -22,8 +22,7 @@ "*://*.volkskrant.nl/*", "*://*.washingtonpost.com/*", "*://*.economist.com/*", - "*://*.the-tls.co.uk/*", - "*://*.harpers.org/*" + "*://*.the-tls.co.uk/*" ], "js": ["contentScript.js"] } @@ -151,7 +150,8 @@ "*://*.demorgen.be/*", "*://*.tinypass.com/*", "*://*.lrb.co.uk/*", - "*://*.the-tls.co.uk/*" + "*://*.the-tls.co.uk/*", + "*://*.harpers.org/*" ], "version": "1.6.2" }