Fix Lequipe.fr (json)
This commit is contained in:
parent
cb21bee6c6
commit
cf9d82fe25
@ -2,6 +2,7 @@
|
|||||||
Changelog Bypass Paywalls Clean - Chrome
|
Changelog Bypass Paywalls Clean - Chrome
|
||||||
|
|
||||||
Post-release
|
Post-release
|
||||||
|
Fix Lequipe.fr (json)
|
||||||
|
|
||||||
* v2.6.6.0 (2022-04-24)
|
* v2.6.6.0 (2022-04-24)
|
||||||
Add Automobilwoche
|
Add Automobilwoche
|
||||||
|
@ -1390,65 +1390,44 @@ else if (matchDomain('lequipe.fr')) {
|
|||||||
let json = json_script.textContent.split('articleObject:')[1].split(',articleType')[0];
|
let json = json_script.textContent.split('articleObject:')[1].split(',articleType')[0];
|
||||||
let url_nuxt = json_script.textContent.split('comment_count_url:"')[1].split('",')[0].replace(/\\u002F/g, '/');
|
let url_nuxt = json_script.textContent.split('comment_count_url:"')[1].split('",')[0].replace(/\\u002F/g, '/');
|
||||||
if (url_nuxt && !url_nuxt.includes(window.location.pathname))
|
if (url_nuxt && !url_nuxt.includes(window.location.pathname))
|
||||||
ext_api.runtime.sendMessage({request: 'refreshCurrentTab'});
|
window.setTimeout(function () {
|
||||||
let par_type = json.split('paragraphs:[')[1].split(',{__type:')[1].split(',')[0];
|
ext_api.runtime.sendMessage({request: 'refreshCurrentTab'});
|
||||||
if (par_type) {
|
}, 500);
|
||||||
|
json = json.replace(/keywords:\[([\w\,\$]+)\]/g, "keywords:\"\"").replace(/([{,])([a-zA-Z_]+\d?):/g, "$1\"$2\":").replace(/\":(\[)?([\w\$\.]+)([\]},])/g, "\":$1\"$2\"$3").replace(/},([\w]+),{/g, "},\"$1\",{");
|
||||||
|
json = JSON.parse(json);
|
||||||
|
if (json.items) {
|
||||||
|
let pars = json.items.filter(x => x.objet && x.objet.paragraphs)[0].objet.paragraphs;
|
||||||
article.innerHTML = '';
|
article.innerHTML = '';
|
||||||
let json_split = json.split('__type:' + par_type);
|
|
||||||
json_split.shift();
|
|
||||||
let article_dom;
|
let article_dom;
|
||||||
let article_text = '';
|
let article_text = '';
|
||||||
let parser = new DOMParser();
|
let parser = new DOMParser();
|
||||||
let par_main_title = '';
|
for (let par of pars) {
|
||||||
for (let par_main of json_split) {
|
if (par.title || par.content) {
|
||||||
if (par_main.includes(',content:')) {
|
if (par.title && par.title.length > 2)
|
||||||
let pars;
|
article_text += '<p><strong>' + par.title + '</strong></p>';
|
||||||
if (par_main.split(',content:"').filter(x => !x.startsWith('\\')).length > 2) {
|
if (par.content) {
|
||||||
if (par_main.startsWith(',title:')) {
|
let par_content = par.content.replace('class=', '').replace(/\\u003C/g, '<').replace(/\\u003E/g, '>').replace(/\\u002F/g, '/').replace(/\\"/g, '"').replace(/(^\"|\"$)/g, '').replace(/\\t/g, '');
|
||||||
par_main_title = par_main.split(',title:')[1].split(',')[0].replace(/(^\"|\"$)/g, '');
|
article_text += '<p>' + par_content + '</p>';
|
||||||
article_text += '<p><strong>' + par_main_title + '</strong></p>';
|
|
||||||
}
|
|
||||||
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) {
|
} else if (par.media && par.media.url && par.media.ratio) {
|
||||||
par = par.split('}')[0];
|
let ratio = par.media.ratio;
|
||||||
if (par.includes(',content:')) {
|
if (!parseInt(ratio))
|
||||||
let content = par.split(',content:"')[1].split('",')[0];
|
ratio = 1.5;
|
||||||
let par_title = '';
|
let url = par.media.url.replace(/\\u002F/g, '/').replace('{width}', '400').replace('{height}', parseInt(400 / ratio)).replace('{quality}', '75');
|
||||||
if (par.includes(',title:'))
|
article_text += '<p><img src="' + url + '" style="width:95%;"</img></p>';
|
||||||
par_title = par.split(',title:')[1].split(',')[0].replace(/(^\"|\"$)/g, '');
|
if (par.media.legende && par.media.legende.length > 2)
|
||||||
if (content) {
|
article_text += '<p><strong>' + par.media.legende + '</strong></p>';
|
||||||
par = content.replace('class=', '');
|
} else if (par.__type && !par.layout)
|
||||||
if (par_title.length > 2 && par_title !== par_main_title)
|
console.log(par);
|
||||||
par = '<strong>' + par_title + '</strong><br><br>' + content;
|
|
||||||
par = par.replace(/\\u003C/g, '<').replace(/\\u003E/g, '>').replace(/\\u002F/g, '/').replace(/\\"/g, '"').replace(/(^\"|\"$)/g, '').replace(/\\t/g, '');
|
|
||||||
article_text += '<p>' + par + '</p>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
par_main = par_main.split('}]')[0];
|
|
||||||
if (par_main.includes(',media:')) {
|
|
||||||
let media = par_main.split(',media:')[1].split('}}')[0] + '}';
|
|
||||||
if (media.includes('ratio:')) {
|
|
||||||
let ratio = media.split('ratio:')[1].split(',')[0].split('}')[0];
|
|
||||||
if (!parseInt(ratio))
|
|
||||||
ratio = 1.5;
|
|
||||||
let url = media.split('url:"')[1].split('"')[0].replace(/\\u002F/g, '/').replace('{width}', '400').replace('{height}', parseInt(400 / ratio)).replace('{quality}', '75');
|
|
||||||
if (url)
|
|
||||||
article_text += '<p><img src="' + url + '" style="width:95%;"</img></p>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
article_dom = parser.parseFromString('<div style="margin:20px; font-family:DINNextLTPro-Regular,sans-serif; font-size:18px;">' + DOMPurify.sanitize(article_text) + '</div>', 'text/html');
|
article_dom = parser.parseFromString('<div style="margin:20px; font-family:DINNextLTPro-Regular,sans-serif; font-size:18px;">' + DOMPurify.sanitize(article_text) + '</div>', 'text/html');
|
||||||
article.appendChild(article_dom.querySelector('div'));
|
article.appendChild(article_dom.querySelector('div'));
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
ext_api.runtime.sendMessage({request: 'refreshCurrentTab'});
|
window.setTimeout(function () {
|
||||||
}
|
ext_api.runtime.sendMessage({request: 'refreshCurrentTab'});
|
||||||
|
}, 500);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,5 +42,5 @@
|
|||||||
"webRequestBlocking",
|
"webRequestBlocking",
|
||||||
"<all_urls>"
|
"<all_urls>"
|
||||||
],
|
],
|
||||||
"version": "2.6.6.0"
|
"version": "2.6.6.1"
|
||||||
}
|
}
|
||||||
|
@ -661,5 +661,5 @@
|
|||||||
"*://*.wsj.net/*",
|
"*://*.wsj.net/*",
|
||||||
"*://webcache.googleusercontent.com/*"
|
"*://webcache.googleusercontent.com/*"
|
||||||
],
|
],
|
||||||
"version": "2.6.6.0"
|
"version": "2.6.6.1"
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user