Fix Faz.net (json)

This commit is contained in:
magnolia1234 2023-10-26 20:46:10 +02:00
parent 7a8487c927
commit 0b2ed47b08
5 changed files with 32 additions and 29 deletions

View file

@ -7,6 +7,7 @@ Remove CodeSports.com.au (fix obsolete)
Remove VosgesMatin.fr (fix obsolete)
Fix Apollo Magazine
Fix Barron's (amp-redirect)
Fix Faz.net (json)
Fix Harvard Business Review (cookie)
Fix Spectator.com.au
Fix The Hindu (+ BusinessLine) epaper

View file

@ -767,38 +767,34 @@ else if (matchDomain('faz.net')) {
response.text().then(html => {
let parser = new DOMParser();
let doc = parser.parseFromString(html, 'text/html');
let json = doc.querySelector('script[id="schemaOrgJson"]');
if (json) {
let json_text = json.text.replace(/(\r|\n)/g, '');
let json_script = doc.querySelector('script[id="schemaOrgJson"]');
if (json_script) {
let json_text;
try {
let split1 = json_text.split('"ArticleBody": "');
let split2 = split1[1].split('","author":');
if (split2[0].includes('"'))
json_text = split1[0] + '"ArticleBody": "' + split2[0].replace(/(\\)?"/g, "'") + '","author":' + split2[1];
json_text = JSON.parse(json_text).ArticleBody;
let json = JSON.parse(json_script.text.replace(/(\r|\n)/g, ''));
json_text = json.articleBody;
} catch (err) {
console.log(err);
return;
}
if (json_text) {
let article_text = document.querySelector('div.art_txt.paywall, div.atc-Text.js-atc-Text');
if (article_text) {
article_text.innerText = '';
json_text = breakText(json_text);
json_text.split("\n\n").forEach(
(p_text) => {
let elem;
if (p_text.length < 80) {
elem = document.createElement("h2");
elem.setAttribute('class', 'atc-SubHeadline');
} else {
elem = document.createElement("p");
elem.setAttribute('class', 'atc-TextParagraph');
};
elem.innerText = p_text;
article_text.appendChild(elem);
});
}
let article_text = document.querySelector('div.art_txt.paywall, div.atc-Text.js-atc-Text');
if (json_text && article_text) {
let pars = article_text.querySelectorAll('p.atc-TextParagraph');
removeDOMElement(...pars);
json_text = breakText(json_text);
json_text.split("\n\n").forEach(
(p_text) => {
let elem;
if (p_text.length < 80) {
elem = document.createElement("h2");
elem.setAttribute('class', 'atc-SubHeadline');
} else {
elem = document.createElement("p");
elem.setAttribute('class', 'atc-TextParagraph');
};
elem.innerText = p_text;
article_text.appendChild(elem);
});
} else {
let json_script = getArticleJsonScript();
if (json_script) {

View file

@ -51,5 +51,5 @@
"webRequestBlocking",
"*://*/*"
],
"version": "3.3.9.5"
"version": "3.3.9.6"
}

View file

@ -805,5 +805,5 @@
"*://*.wyleex.com/*",
"*://webcache.googleusercontent.com/*"
],
"version": "3.3.9.5"
"version": "3.3.9.6"
}

View file

@ -43,6 +43,12 @@
"block_regex": "(\\.estadao\\.com\\.br\\/(paywall\\/|access\\.js)|cdn\\.ampproject\\.org\\/v\\d\\/amp-(access|subscriptions)-.+\\.js)",
"upd_version": "3.3.7.4"
},
"Frankfurter Allgemeine Zeitung": {
"domain": "faz.net",
"allow_cookies": 1,
"ld_json": "header.atc-Header span.ico-Base_FazPlus|div.atc-Text.js-atc-Text",
"upd_version": "3.3.9.6"
},
"Harvard Business Review": {
"domain": "hbr.org",
"block_regex": "cdn\\.cxense\\.com\\/",