Merge pull request #400 from magnolia1234/master

Fix Economist/Boston Globe & add London Review of Books/Times Literary Supplement/Harper's Magazine
merge-requests/1/head
ghost 5 years ago committed by GitHub
commit 807e5b9441

@ -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)\
@ -38,6 +39,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)\
@ -88,6 +90,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)\

@ -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',
@ -35,6 +36,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',
@ -85,6 +87,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',
@ -110,6 +113,7 @@ const allow_cookies = [
'examiner.com.au',
'ft.com',
'hacked.com',
'harpers.org',
'hbr.org',
'lemonde.fr',
'letemps.ch',
@ -153,6 +157,7 @@ const remove_cookies = [
'examiner.com.au',
'ft.com',
'hacked.com',
'harpers.org',
'hbr.org',
'letemps.ch',
'medium.com',
@ -179,7 +184,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']
}
@ -187,7 +191,9 @@ 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'],
'nrc.nl': ['counter']
}
@ -216,12 +222,16 @@ 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\/.+/,
'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)"
const userAgentMobile = "Chrome/41.0.2272.96 Mobile Safari/537.36 (compatible ; Googlebot/2.1 ; +http://www.google.com/bot.html)"
@ -261,31 +271,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) {
@ -294,24 +279,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/*", "*://*.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;
@ -425,7 +424,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);
}
});

@ -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"
@ -171,6 +178,24 @@ if (window.location.href.indexOf("caixinglobal.com") !== -1) {
}
}
if (window.location.href.indexOf("economist.com") !== -1) {
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) {
const paywall = document.querySelector('.tls-subscriptions-banner__closed-skin');
removeDOMElement(paywall);
}
function removeDOMElement(...elements) {
for (let element of elements) {
if (element) element.remove();

@ -20,7 +20,9 @@
"*://*.telegraaf.nl/*",
"*://*.trouw.nl/*",
"*://*.volkskrant.nl/*",
"*://*.washingtonpost.com/*"
"*://*.washingtonpost.com/*",
"*://*.economist.com/*",
"*://*.the-tls.co.uk/*"
],
"js": ["contentScript.js"]
}
@ -145,7 +147,11 @@
"*://*.lemonde.fr/*",
"*://*.scientificamerican.com/*",
"*://*.thehindu.com/*",
"*://*.demorgen.be/*"
"*://*.demorgen.be/*",
"*://*.tinypass.com/*",
"*://*.lrb.co.uk/*",
"*://*.the-tls.co.uk/*",
"*://*.harpers.org/*"
],
"version": "1.6.2"
}

@ -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',
@ -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',
@ -33,6 +34,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',
@ -59,7 +61,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',
@ -83,6 +85,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',

Loading…
Cancel
Save