Fix-update Boston Globe

This commit is contained in:
magnolia1234 2020-05-29 15:34:02 +02:00
parent 8f6a57310a
commit 7a92e44b69
2 changed files with 16 additions and 5 deletions

View file

@ -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 };

View file

@ -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){