From a82d812c83ccf7581c641f09d268fb3a4f177dd9 Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Tue, 10 Dec 2019 19:02:16 +0100 Subject: [PATCH] Update fix Boston Globe & block scripts while site restrictions Only enable Boston Globe paywall-script to set cookies at homepage/sections (no text in articles while no cookies). + Option to block scripts while site restrictions. --- background.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/background.js b/background.js index 00c85886..3e69d93a 100644 --- a/background.js +++ b/background.js @@ -303,8 +303,13 @@ browser.webRequest.onBeforeSendHeaders.addListener(function(details) { // 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 ((isSiteEnabled({url: '.'+ domain}) || isSiteEnabled({url: header_referer})) && details.url.match(blockedRegexes[domain])) { if (details.url.indexOf(domain) !== -1 || header_referer.indexOf(domain) !== -1) { + // allow BG paywall-script to set cookies in homepage/sections (else no article-text) + if (details.url.indexOf('meter.bostonglobe.com/js/') !== -1 && (header_referer === 'https://www.bostonglobe.com/' + || header_referer.indexOf('/?p1=BGHeader_') !== -1 || header_referer.indexOf('/?p1=BGMenu_') !== -1)) { + break; + } return { cancel: true }; } }