Fix LesEchos.fr (json)

This commit is contained in:
magnolia1234 2023-04-06 19:39:32 +02:00
parent 446df430f0
commit c520bee8f4
4 changed files with 26 additions and 30 deletions

View file

@ -4,6 +4,7 @@ Updates: https://gitlab.com/magnolia1234/bypass-paywalls-firefox-clean/-/release
Post-release Post-release
Add Haas Mediengruppe (opt-in to custom sites) Add Haas Mediengruppe (opt-in to custom sites)
Fix LesEchos.fr (json)
* v3.1.2.0 (2023-04-02) * v3.1.2.0 (2023-04-02)
Add Epicurious (Conde Nast) Add Epicurious (Conde Nast)

View file

@ -1567,41 +1567,36 @@ else if (matchDomain('lesechos.fr')) {
removeDOMElement(abo_banner); removeDOMElement(abo_banner);
let url = window.location.href; let url = window.location.href;
let html = document.documentElement.outerHTML; let html = document.documentElement.outerHTML;
let state;
let split1 = html.split('window.__CONFIG__=')[1];
let split2 = split1.split('</script>')[0].trim();
if (split2.includes('window.__DATA__=')) {
state = split2.split('window.__DATA__=')[1].split('};')[0] + '}';
} else
state = split2.substr(0, split2.length - 1);
try { try {
let split1 = html.split(/window\.__REACT_QUERY_STATE__\s?=/)[1];
let state = split1.split('</script>')[0].trim().replace(/;$/, '');
let data = JSON.parse(state); let data = JSON.parse(state);
let data_article = data.article ? data.article : data.pageProps; let data_article = data.queries[1].state;
if (data_article.dehydratedState)
data_article = data_article.dehydratedState.queries[1].state;
let article = data_article.data.stripes[0].mainContent[0].data.description.replace(/allowfullscreen=''/g, '');
let url_loaded = data_article.data.path; let url_loaded = data_article.data.path;
if (url_loaded && !url.replace(/%20/g, '').includes(url_loaded)) if (url_loaded && (!url_loaded.slice(-7).match(/\d+/) || !url.includes(url_loaded.slice(-7))))
refreshCurrentTab(); refreshCurrentTab();
let paywallNode = document.querySelector('.post-paywall'); else {
if (paywallNode) { let article = data_article.data.stripes[0].mainContent[0].data.description.replace(/allowfullscreen='(true)?'/g, '');
let contentNode = document.createElement('div'); let paywallNode = document.querySelector('.post-paywall');
let parser = new DOMParser(); if (paywallNode) {
let article_html = parser.parseFromString('<div>' + article + '</div>', 'text/html'); let contentNode = document.createElement('div');
let article_par = article_html.querySelector('div'); let parser = new DOMParser();
if (article_par) { let article_html = parser.parseFromString('<div>' + article + '</div>', 'text/html');
contentNode.appendChild(article_par); let article_par = article_html.querySelector('div');
contentNode.className = paywallNode.className; if (article_par) {
paywallNode.before(contentNode); contentNode.appendChild(article_par);
removeDOMElement(paywallNode); contentNode.className = paywallNode.className;
let paywallLastChildNode = document.querySelector('.post-paywall > :last-child'); paywallNode.before(contentNode);
if (paywallLastChildNode) { removeDOMElement(paywallNode);
paywallLastChildNode.setAttribute('style', 'height: auto !important; overflow: hidden !important; max-height: none !important;'); let paywallLastChildNode = document.querySelector('.post-paywall > :last-child');
if (paywallLastChildNode) {
paywallLastChildNode.setAttribute('style', 'height: auto !important; overflow: hidden !important; max-height: none !important;');
}
} }
} }
let styleElem = document.head.appendChild(document.createElement('style'));
styleElem.innerHTML = ".post-paywall::after {height: auto !important;}";
} }
let styleElem = document.head.appendChild(document.createElement('style'));
styleElem.innerHTML = ".post-paywall::after {height: auto !important;}";
} catch (err) { } catch (err) {
console.log(err); console.log(err);
} }

View file

@ -51,5 +51,5 @@
"webRequestBlocking", "webRequestBlocking",
"*://*/*" "*://*/*"
], ],
"version": "3.1.2.1" "version": "3.1.2.2"
} }

View file

@ -748,5 +748,5 @@
"*://*.wallkit.net/*", "*://*.wallkit.net/*",
"*://webcache.googleusercontent.com/*" "*://webcache.googleusercontent.com/*"
], ],
"version": "3.1.2.1" "version": "3.1.2.2"
} }