Fix lesechos.fr

This commit is contained in:
Adam 2020-08-28 17:38:25 -07:00
parent b74edee2d7
commit 452e2c9932
2 changed files with 41 additions and 1 deletions

View File

@ -188,7 +188,8 @@ const blockedRegexes = {
'irishtimes.com': /cdn\.ampproject\.org\/v\d\/amp-access-.+\.js/,
'elmercurio.com': /(merreader\.emol\.cl\/assets\/js\/merPramV2.js|staticmer\.emol\.cl\/js\/inversiones\/PramModal.+\.js)/,
'sloanreview.mit.edu': /(.+\.tinypass\.com\/.+|.+\.netdna-ssl\.com\/wp-content\/themes\/smr\/assets\/js\/libs\/welcome-ad\.js)/,
'latercera.com': /.+\.cxense\.com\/+/
'latercera.com': /.+\.cxense\.com\/+/,
'lesechos.fr': /.+\.tinypass\.com\/.+/
};
const userAgentDesktop = 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)';

View File

@ -357,6 +357,45 @@ if (matchDomain('elmercurio.com')) {
} else if (matchDomain('thesaturdaypaper.com.au')) {
const paywall = document.querySelector('div.paywall-hard-always-show');
removeDOMElement(paywall);
} else if (matchDomain('lesechos.fr') && window.location.href.match(/-\d{6,}/)) {
window.setTimeout(function () {
const url = window.location.href;
const html = document.documentElement.outerHTML;
const split1 = html.split('window.__PRELOADED_STATE__')[1];
const split2 = split1.split('</script>')[0].trim();
const state = split2.substr(1, split2.length - 2);
try {
const data = JSON.parse(state);
const article = data.article.data.stripes[0].mainContent[0].data.description;
const urlLoaded = data.article.data.path;
if (!url.includes(urlLoaded)) { document.location.reload(true); }
const paywallNode = document.querySelector('.post-paywall');
if (paywallNode) {
const contentNode = document.createElement('div');
const parser = new DOMParser();
const articleHtml = parser.parseFromString('<div id="bypass">' + article + '</div>', 'text/html');
const articlePar = articleHtml.querySelector('div#bypass');
if (articlePar) {
contentNode.appendChild(articlePar);
contentNode.className = paywallNode.className;
paywallNode.parentNode.insertBefore(contentNode, paywallNode);
removeDOMElement(paywallNode);
const paywallLastChildNode = document.querySelector('.post-paywall > :last-child');
if (paywallLastChildNode) {
paywallLastChildNode.setAttribute('style', 'height: auto !important; overflow: hidden !important; max-height: none !important;');
}
}
}
} catch (err) {
console.warn(err);
}
const adBlocks = document.querySelectorAll('.jzxvkd-1');
for (const adBlock of adBlocks) {
adBlock.setAttribute('style', 'display:none');
}
const aboBanner = document.querySelector('[class^="pgxf3b"]');
removeDOMElement(aboBanner);
}, 500); // Delay (in milliseconds)
}
function matchDomain (domains) {