Merge pull request #407 from magnolia1234/master

Fix Businessinsider & SfChronicle & Economist & BizJournals
This commit is contained in:
ghost 2019-11-21 21:10:45 -08:00 committed by GitHub
commit 1bbf2bf817
3 changed files with 56 additions and 16 deletions

View File

@ -219,12 +219,14 @@ 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)/,
'economist.com': /.+\.tinypass\.com\/.+/
};
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 +299,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/*", "*://*.theglobeandmail.com/*", "*://*.afr.com/*", "*://*.bostonglobe.com/*", "*://*.tinypass.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;

View File

@ -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/')) {
@ -198,6 +205,23 @@ 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);
}
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)

View File

@ -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',
@ -69,9 +69,9 @@ 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 (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',