From 23d0e1a4c766d7fd1ee9783543c68d8980fd83ff Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Mon, 18 Nov 2019 08:42:17 +0100 Subject: [PATCH 1/6] Merge master (#11) * remove cookie banner on Financial Times * resolved conflicts: fix typo --- contentScript.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/contentScript.js b/contentScript.js index 8f5c11f..c8d97a4 100644 --- a/contentScript.js +++ b/contentScript.js @@ -170,6 +170,11 @@ if (window.location.href.indexOf("ledevoir.com") !== -1) { removeDOMElement(counter); } +if (window.location.href.includes('ft.com')) { + const cookie_banner = document.querySelector('.n-messaging-banner__outer'); + removeDOMElement(cookie_banner); +} + if (window.location.href.indexOf("thehindu.com") !== -1) { const paywall = document.getElementById('test'); removeDOMElement(paywall); From 20705f9c8a9f4333bb215b388d9f26c5524e38c5 Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Tue, 19 Nov 2019 00:02:46 +0100 Subject: [PATCH 2/6] Fix Businessinsider (by blocking external scripts) General javascript block blurs and hides pictures/videos. New option to block external scripts per referring (enabled) domain. --- background.js | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/background.js b/background.js index 0e12096..80e3189 100644 --- a/background.js +++ b/background.js @@ -219,12 +219,13 @@ function setDefaultOptions() { }); } -var blockedRegexes = [ -/.+:\/\/.+\.tribdss\.com\//, -/thenation\.com\/.+\/paywall-script\.php/, -/haaretz\.co\.il\/htz\/js\/inter\.js/, -/nzherald\.co\.nz\/.+\/headjs\/.+\.js/ -]; +var 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/, +'businessinsider.com': /(.+\.tinypass\.com\/.+|cdn\.onesignal\.com\/sdks\/.+\.js)/ +}; 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)" @@ -297,22 +298,36 @@ chrome.webRequest.onBeforeRequest.addListener(function(details) { return {cancel: true}; }, { - urls: ["*://*.thestar.com/*", "*://*.economist.com/*", "*://*.theglobeandmail.com/*", "*://*.afr.com/*", "*://*.bizjournals.com/*", "*://*.businessinsider.com/*", "*://*.bostonglobe.com/*"], + urls: ["*://*.thestar.com/*", "*://*.economist.com/*", "*://*.theglobeandmail.com/*", "*://*.afr.com/*", "*://*.bizjournals.com/*", "*://*.bostonglobe.com/*"], types: ["script"] }, ["blocking"] ); chrome.webRequest.onBeforeSendHeaders.addListener(function(details) { + 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 (!isSiteEnabled(details)) { return; } - if (blockedRegexes.some(function(regex) { return regex.test(details.url); })) { - return { cancel: true }; - } - - var requestHeaders = details.requestHeaders; var tabId = details.tabId; var useUserAgentMobile = false; From 84bd5148099009fd2288bbd31730e3b5bc409a97 Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Tue, 19 Nov 2019 12:35:27 +0100 Subject: [PATCH 3/6] Update Businessinsider description (option.js) No longer complete Javascript block. --- options.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/options.js b/options.js index 13a81b9..c854975 100644 --- a/options.js +++ b/options.js @@ -5,7 +5,7 @@ var defaultSites = { 'Barron\'s': 'barrons.com', 'Bloomberg': 'bloomberg.com', 'Bloomberg Quint': 'bloombergquint.com', - 'Business Insider (javascript disabled)': 'businessinsider.com', + 'Business Insider': 'businessinsider.com', 'Crain\'s Chicago Business': 'chicagobusiness.com', 'Chicago Tribune': 'chicagotribune.com', 'Corriere Della Sera': 'corriere.it', From f63d7be41931e7459c04060521c4db1cf49f24f7 Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Tue, 19 Nov 2019 13:45:15 +0100 Subject: [PATCH 4/6] Fix SfChronicle (reload loop) Exclusion from localstorage.clear (contentScript.js). --- contentScript.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/contentScript.js b/contentScript.js index c8d97a4..29dc11e 100644 --- a/contentScript.js +++ b/contentScript.js @@ -1,4 +1,11 @@ -window.localStorage.clear(); +var arr_localstorage_hold = ['sfchronicle.com']; +var localstorage_hold = arr_localstorage_hold.some(function(url) { + return window.location.href.indexOf(url) !== -1; +}); + +if (!localstorage_hold){ + window.localStorage.clear(); +} if (location.hostname.endsWith('rep.repubblica.it')) { if (location.href.includes('/pwa/')) { @@ -170,11 +177,6 @@ if (window.location.href.indexOf("ledevoir.com") !== -1) { removeDOMElement(counter); } -if (window.location.href.includes('ft.com')) { - const cookie_banner = document.querySelector('.n-messaging-banner__outer'); - removeDOMElement(cookie_banner); -} - if (window.location.href.indexOf("thehindu.com") !== -1) { const paywall = document.getElementById('test'); removeDOMElement(paywall); From 3391964ac91a7315bbe98224a9778b0fa38be637 Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Tue, 19 Nov 2019 14:25:29 +0100 Subject: [PATCH 5/6] Fix Economist (block external script) --- background.js | 5 +++-- contentScript.js | 5 +++++ options.js | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/background.js b/background.js index 80e3189..adfb1e1 100644 --- a/background.js +++ b/background.js @@ -224,7 +224,8 @@ var 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/, -'businessinsider.com': /(.+\.tinypass\.com\/.+|cdn\.onesignal\.com\/sdks\/.+\.js)/ +'businessinsider.com': /(.+\.tinypass\.com\/.+|cdn\.onesignal\.com\/sdks\/.+\.js)/, +'economist.com': /.+\.tinypass\.com\/.+/ }; const userAgentDesktop = "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" @@ -298,7 +299,7 @@ chrome.webRequest.onBeforeRequest.addListener(function(details) { return {cancel: true}; }, { - urls: ["*://*.thestar.com/*", "*://*.economist.com/*", "*://*.theglobeandmail.com/*", "*://*.afr.com/*", "*://*.bizjournals.com/*", "*://*.bostonglobe.com/*"], + urls: ["*://*.thestar.com/*", "*://*.theglobeandmail.com/*", "*://*.afr.com/*", "*://*.bizjournals.com/*", "*://*.bostonglobe.com/*"], types: ["script"] }, ["blocking"] diff --git a/contentScript.js b/contentScript.js index 29dc11e..dd358d7 100644 --- a/contentScript.js +++ b/contentScript.js @@ -200,6 +200,11 @@ if (window.location.href.indexOf("leparisien.fr") !== -1) { }, 300); // Delay (in milliseconds) } +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) diff --git a/options.js b/options.js index c854975..e71b334 100644 --- a/options.js +++ b/options.js @@ -71,7 +71,7 @@ var defaultSites = { 'The Boston Globe (javascript disabled)': 'bostonglobe.com', 'The Business Journals (javascript disabled)': 'bizjournals.com', 'The Canberra Times': 'canberratimes.com.au', - 'The Economist (javascript disabled)': 'economist.com', + 'The Economist': 'economist.com', 'The Globe and Mail (javascript disabled)': 'theglobeandmail.com', 'The Hindu': 'thehindu.com', 'The Irish Times': 'irishtimes.com', From f686876b16c313ea26b830d887f29635bea3fbfb Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Thu, 21 Nov 2019 22:15:35 +0100 Subject: [PATCH 6/6] Fix BizJournals No more Javascript-block necessary (resulted in hidden pictures etc.). --- background.js | 2 +- contentScript.js | 12 ++++++++++++ options.js | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/background.js b/background.js index adfb1e1..663a876 100644 --- a/background.js +++ b/background.js @@ -299,7 +299,7 @@ chrome.webRequest.onBeforeRequest.addListener(function(details) { return {cancel: true}; }, { - urls: ["*://*.thestar.com/*", "*://*.theglobeandmail.com/*", "*://*.afr.com/*", "*://*.bizjournals.com/*", "*://*.bostonglobe.com/*"], + urls: ["*://*.thestar.com/*", "*://*.theglobeandmail.com/*", "*://*.afr.com/*", "*://*.bostonglobe.com/*", "*://*.tinypass.com/*"], types: ["script"] }, ["blocking"] diff --git a/contentScript.js b/contentScript.js index dd358d7..0716b5d 100644 --- a/contentScript.js +++ b/contentScript.js @@ -205,6 +205,18 @@ if (window.location.href.indexOf("economist.com") !== -1) { removeDOMElement(wrapper); } +if (window.location.href.indexOf("bizjournals.com") !== -1) { + const sheet_overlay = document.querySelector('.sheet-overlay'); + const chunk_paywall = document.querySelector('.chunk--paywall'); + removeDOMElement(sheet_overlay, chunk_paywall); + const overlaid = document.querySelectorAll('.is-overlaid'); + for (var i = 0; i < overlaid.length; i++) { + overlaid[i].classList.remove('is-overlaid'); + } + const body_hidden = document.querySelector('.js-pre-chunks__story-body'); + body_hidden.removeAttribute('style'); +} + function removeDOMElement(...elements) { for (let element of elements) { if (element) diff --git a/options.js b/options.js index e71b334..5dc892c 100644 --- a/options.js +++ b/options.js @@ -69,7 +69,7 @@ var defaultSites = { 'The Australian': 'theaustralian.com.au', 'The Australian Financial Review (javascript disabled)': 'afr.com', 'The Boston Globe (javascript disabled)': 'bostonglobe.com', - 'The Business Journals (javascript disabled)': 'bizjournals.com', + 'The Business Journals': 'bizjournals.com', 'The Canberra Times': 'canberratimes.com.au', 'The Economist': 'economist.com', 'The Globe and Mail (javascript disabled)': 'theglobeandmail.com',