diff --git a/changelog.txt b/changelog.txt
index dd40b82..0546e4b 100644
--- a/changelog.txt
+++ b/changelog.txt
@@ -4,6 +4,7 @@ Updates: https://gitlab.com/magnolia1234/bypass-paywalls-firefox-clean/-/release
Post-release
Add Haas Mediengruppe (opt-in to custom sites)
+Fix LesEchos.fr (json)
* v3.1.2.0 (2023-04-02)
Add Epicurious (Conde Nast)
diff --git a/contentScript.js b/contentScript.js
index a991e2c..403a3e8 100644
--- a/contentScript.js
+++ b/contentScript.js
@@ -1567,41 +1567,36 @@ else if (matchDomain('lesechos.fr')) {
removeDOMElement(abo_banner);
let url = window.location.href;
let html = document.documentElement.outerHTML;
- let state;
- let split1 = html.split('window.__CONFIG__=')[1];
- let split2 = split1.split('')[0].trim();
- if (split2.includes('window.__DATA__=')) {
- state = split2.split('window.__DATA__=')[1].split('};')[0] + '}';
- } else
- state = split2.substr(0, split2.length - 1);
try {
+ let split1 = html.split(/window\.__REACT_QUERY_STATE__\s?=/)[1];
+ let state = split1.split('')[0].trim().replace(/;$/, '');
let data = JSON.parse(state);
- let data_article = data.article ? data.article : data.pageProps;
- 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 data_article = data.queries[1].state;
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();
- let paywallNode = document.querySelector('.post-paywall');
- if (paywallNode) {
- let contentNode = document.createElement('div');
- let parser = new DOMParser();
- let article_html = parser.parseFromString('
' + article + '
', 'text/html');
- let article_par = article_html.querySelector('div');
- if (article_par) {
- contentNode.appendChild(article_par);
- contentNode.className = paywallNode.className;
- paywallNode.before(contentNode);
- removeDOMElement(paywallNode);
- let paywallLastChildNode = document.querySelector('.post-paywall > :last-child');
- if (paywallLastChildNode) {
- paywallLastChildNode.setAttribute('style', 'height: auto !important; overflow: hidden !important; max-height: none !important;');
+ else {
+ let article = data_article.data.stripes[0].mainContent[0].data.description.replace(/allowfullscreen='(true)?'/g, '');
+ let paywallNode = document.querySelector('.post-paywall');
+ if (paywallNode) {
+ let contentNode = document.createElement('div');
+ let parser = new DOMParser();
+ let article_html = parser.parseFromString('' + article + '
', 'text/html');
+ let article_par = article_html.querySelector('div');
+ if (article_par) {
+ contentNode.appendChild(article_par);
+ contentNode.className = paywallNode.className;
+ paywallNode.before(contentNode);
+ removeDOMElement(paywallNode);
+ 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) {
console.log(err);
}
diff --git a/custom/manifest.json b/custom/manifest.json
index 06208d3..6eda4c8 100644
--- a/custom/manifest.json
+++ b/custom/manifest.json
@@ -51,5 +51,5 @@
"webRequestBlocking",
"*://*/*"
],
- "version": "3.1.2.1"
+ "version": "3.1.2.2"
}
diff --git a/manifest.json b/manifest.json
index 4162e66..470d5b3 100644
--- a/manifest.json
+++ b/manifest.json
@@ -748,5 +748,5 @@
"*://*.wallkit.net/*",
"*://webcache.googleusercontent.com/*"
],
- "version": "3.1.2.1"
+ "version": "3.1.2.2"
}