Fix-update LesEchos.fr (premium)

Re-enable in options (title changed).
Updated code (originally https://github.com/adriantombu/open-press)
This commit is contained in:
magnolia1234 2020-05-01 17:50:15 +02:00
parent 3ffc02de8c
commit 8498a7abd9
3 changed files with 35 additions and 6 deletions

View file

@ -165,7 +165,7 @@ Install add-on by downloading xpi-file.
[La Dépêche](https://www.ladepeche.fr)
[Le Journal du Dimanche](https://lejdd.fr)
[Le Parisien](https://www.leparisien.fr) -
[Les Échos](https://www.lesechos.fr)* -
[Les Échos](https://www.lesechos.fr) -
[Libération](https://www.liberation.fr)*
[Science & Vie](https://www.science-et-vie.com) -
[Valeurs Actuelles](https://www.valeursactuelles.com)

View file

@ -429,10 +429,39 @@ else if (matchDomain("cen.acs.org")) {
}
else if (matchDomain("lesechos.fr")) {
const ad_block = document.querySelectorAll('.jzxvkd-1');
for (let i = 0; i < ad_block.length; i++) {
ad_block[i].setAttribute('style', 'display:none');
}
window.setTimeout(function () {
const ad_block = document.querySelectorAll('.jzxvkd-1');
for (let i = 0; i < ad_block.length; i++) {
ad_block[i].setAttribute('style', 'display:none');
}
const abo_banner = document.querySelector('[class^=pgxf3b]');
removeDOMElement(abo_banner);
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 paywallNode = document.querySelector('.post-paywall');
if (paywallNode) {
const contentNode = document.createElement('div');
contentNode.innerHTML = article;
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('unable to parse lesechos text');
console.warn(err);
}
}, 500); // Delay (in milliseconds)
}
else if (matchDomain(["lc.nl", "dvhn.nl"])) {

View file

@ -73,7 +73,7 @@ var defaultSites =
"Le Parisien": "leparisien.fr",
"Le Scienze": "lescienze.it",
"Leeuwarder Courant": "lc.nl",
"Les Échos (free articles only)": "lesechos.fr",
"Les Échos": "lesechos.fr",
"Libération (free articles only)": "liberation.fr",
"LiveMint": "livemint.com",
"Loeb Classical Library": "loebclassics.com",