diff --git a/background.js b/background.js index 2e140e8..1f8a63d 100644 --- a/background.js +++ b/background.js @@ -402,11 +402,7 @@ ext_api.webRequest.onBeforeSendHeaders.addListener(function(details) { var blockedDomains = Object.keys(blockedRegexes); var domain = matchUrlDomain(blockedDomains, header_referer); if (domain && details.url.match(blockedRegexes[domain]) && isSiteEnabled({url: header_referer})) { - // allow BG paywall-script to set cookies in homepage/sections (else no article-text) - if (domain == 'bostonglobe.com' && - (header_referer === 'https://www.bostonglobe.com/' || header_referer.includes('/?p1=BGHeader_') || header_referer.includes('/?p1=BGMenu_'))) { - ext_api.webRequest.handlerBehaviorChanged(); - } else if (domain == 'theglobeandmail.com' && !(header_referer.includes('/article-'))) { + if (domain == 'theglobeandmail.com' && !(header_referer.includes('/article-'))) { ext_api.webRequest.handlerBehaviorChanged(); } return { cancel: true }; diff --git a/contentScript.js b/contentScript.js index bf33c23..56bd3e8 100644 --- a/contentScript.js +++ b/contentScript.js @@ -665,6 +665,13 @@ else if (matchDomain('spectator.co.uk')) { }, 500); // Delay (in milliseconds) } +else if (matchDomain('bostonglobe.com')) { + if (!document.cookie.split(';').some(function(item) { return item.trim().indexOf('s_fid=') === 0 })) { + let s_fid = genHexString(16) + '-' + genHexString(16); + document.cookie = "s_fid=" + s_fid + "; domain=bostonglobe.com; path=/; max-age=1209600"; + } +} + // General Functions function removeDOMElement(...elements) { for (let element of elements) { @@ -691,6 +698,14 @@ function removeClassesByPrefix(el, prefix) { } } +function genHexString(len) { + let output = ''; + for (let i = 0; i < len; i++) { + output += (Math.floor(Math.random() * 16)).toString(16); + } + return output; +} + function pageContains(selector, text) { let elements = document.querySelectorAll(selector); return Array.prototype.filter.call(elements, function(element){