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 + '

' + content; + par = par.replace(/\\u003C/g, '<').replace(/\\u003E/g, '>').replace(/\\u002F/g, '/').replace(/\\"/g, '"').replace(/^\"|\"$/g, ''); + article_text += '

' + par + '

'; + } + } } } } article_dom = parser.parseFromString('
' + DOMPurify.sanitize(article_text) + '
', 'text/html'); article.appendChild(article_dom.querySelector('div')); } - } + } } } } diff --git a/custom/manifest.json b/custom/manifest.json index edfe66c..59b9cc6 100644 --- a/custom/manifest.json +++ b/custom/manifest.json @@ -39,5 +39,5 @@ "webRequestBlocking", "" ], - "version": "2.5.6.0" + "version": "2.5.6.1" } diff --git a/manifest.json b/manifest.json index a606355..e7ac3e1 100755 --- a/manifest.json +++ b/manifest.json @@ -608,5 +608,5 @@ "*://*.wallkit.net/*", "*://*.wsj.net/*" ], - "version": "2.5.6.0" + "version": "2.5.6.1" } diff --git a/sites.js b/sites.js index 294cbcb..49ba1dc 100755 --- a/sites.js +++ b/sites.js @@ -647,7 +647,7 @@ var defaultSites = { allow_cookies: 1, block_regex: /(\.piano\.io\/|cdn\.cxense\.com\/|cdn\.ampproject\.org\/v\d\/amp-(access|analytics)-.+\.js)/ }, - "Grupo Vocento (Spain, regional daily)": { + "Grupo Vocento": { domain: "###_es_grupo_vocento", group: [ "diariosur.es", @@ -1626,7 +1626,7 @@ var defaultSites = { allow_cookies: 1, block_regex: /(\.tinypass\.com\/|\.telegraph\.co\.uk\/martech\/js\/|cdn\.ampproject\.org\/v\d\/amp-(access|(sticky-)?ad)-.+\.js)/ }, - "The Times": { + "The Times (UK)": { domain: "thetimes.co.uk", allow_cookies: 1, useragent: "googlebot" diff --git a/sites_updated.json b/sites_updated.json index ff02515..8c75d39 100644 --- a/sites_updated.json +++ b/sites_updated.json @@ -114,7 +114,7 @@ "block_regex": "(journey\\.vogue\\.com\\/build-.+\\.js|cdn\\.ampproject\\.org\\/v\\d\\/amp-(ad|subscriptions)-.+\\.js)", "useragent": "googlebot" }, - "Voguebusiness.com": { + "Vogue Business": { "allow_cookies": 1, "domain": "voguebusiness.com", "useragent": "googlebot"