From bb30ba96c3b68383be14fb9873609da98d71a5df Mon Sep 17 00:00:00 2001
From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com>
Date: Mon, 14 Feb 2022 21:24:58 +0100
Subject: [PATCH] Fix Lequipe.fr (json)
---
changelog.txt | 7 ++++---
contentScript.js | 44 ++++++++++++++++++++++++++------------------
custom/manifest.json | 2 +-
manifest.json | 2 +-
sites.js | 4 ++--
sites_updated.json | 2 +-
6 files changed, 35 insertions(+), 26 deletions(-)
diff --git a/changelog.txt b/changelog.txt
index b568f93..fe3c8de 100644
--- a/changelog.txt
+++ b/changelog.txt
@@ -2,6 +2,7 @@
Changelog Bypass Paywalls Clean - Chrome
Post-release
+Fix Lequipe.fr (json)
* v2.5.6.0 (2022-02-13)
Add Condé Nast magazines & Vogue Business
@@ -203,7 +204,7 @@ Update custom sites (block regex for default sites)
* v2.4.0.0 (2021-10-17)
Add Westfaelische Nachrichten (Germany)
-Remove Australian Provincial Newspapers (fix obsolete)
+Remove Australian Provincial Newspapers (obsolete)
Fix GElocal.it
Fix National Review
Fix Ruhr Nachrichten (amp)
@@ -271,7 +272,7 @@ Fix group Crain Communications
Add Ad Age & Automotive News (group Crain Communications)
Add MediaNews Group (local USA)
Add The Intercept
-Remove Slader (fix obsolete)
+Remove Slader (obsolete)
Fix group Mediahuis Nederland Regional
Fix Medium (timing)
Fix The Australian
@@ -349,7 +350,7 @@ Update custom sites (set useragent Bingbot)
* v2.2.6.0 (2021-06-20)
Add group Mediahuis Nederland Regional
-Remove The Northern Star (fix obsolete)
+Remove The Northern Star (obsolete)
Fix Atlantico.fr
Fix Boston Globe (no opt-in)
Fix Foreign Policy
diff --git a/contentScript.js b/contentScript.js
index 16b7990..0e91c6a 100755
--- a/contentScript.js
+++ b/contentScript.js
@@ -1131,33 +1131,41 @@ else if (matchDomain('lequipe.fr')) {
if (par_type) {
article.innerHTML = '';
let json_split = json.split('__type:' + par_type);
- if (json_split.length < 5) {
- par_type = json.split('content:"')[1].split('"},{__type:')[1].split(',')[0];
- json_split = json.split('__type:' + par_type);
- }
let article_dom;
let article_text = '';
let parser = new DOMParser();
- for (let par of json_split) {
- par = par.split('}')[0];
- if (par.includes(',content:')) {
- let content = par.split(',content:')[1].split('",')[0];
- let par_title = '';
- if (par.includes(',title:'))
- par_title = par.split(',title:')[1].split(',')[0].replace(/^\"|\"$/g, '');
- if (content) {
- par = content.replace('class=', '');
- if (par_title.length > 2)
- par = '' + par_title + '
' + content;
- par = par.replace(/\\u003C/g, '<').replace(/\\u003E/g, '>').replace(/\\u002F/g, '/').replace(/\\"/g, '"').replace(/^\"|\"$/g, '');
- article_text += '
' + par + '
'; + for (let par_main of json_split) { + if (par_main.includes(',content:')) { + if (par_main.split(',content:"').length > 2) { + if (par_main.startsWith(',title:')) + article_text += '' + par_main.split(',title:')[1].split(',')[0].replace(/^\"|\"$/g, '') + '
'; + par_type = json.split('content:')[1].split('"},{__type:')[1].split(',')[0]; + pars = par_main.split('__type:' + par_type); + } else { + pars = [par_main]; + } + for (let par of pars) { + par = par.split('}')[0]; + if (par.includes(',content:')) { + let content = par.split(',content:')[1].split('",')[0]; + let par_title = ''; + if (par.includes(',title:')) + par_title = par.split(',title:')[1].split(',')[0].replace(/^\"|\"$/g, ''); + if (content) { + par = content.replace('class=', ''); + if (par_title.length > 2) + par = '' + par_title + '' + par + '
'; + } + } } } } article_dom = parser.parseFromString('