// ==UserScript==
// @name Bypass Paywalls Clean - fr
// @version 4.2.5.0
// @description Bypass Paywalls of news sites
// @author magnolia1234
// @downloadURL https://gitflic.ru/project/magnolia1234/bypass-paywalls-clean-filters/blob/raw?file=userscript/bpc.fr.user.js
// @updateURL https://gitflic.ru/project/magnolia1234/bypass-paywalls-clean-filters/blob/raw?file=userscript/bpc.fr.user.js
// @homepageURL https://gitflic.ru/project/magnolia1234/bypass-paywalls-clean-filters
// @supportURL https://gitflic.ru/project/magnolia1234/bypass-paywalls-clean-filters
// @license MIT; https://gitflic.ru/project/magnolia1234/bypass-paywalls-clean-filters/blob/raw?file=LICENSE
// @noframes
// @match *://*.fr/*
// @match *://*.aoc.media/*
// @match *://*.arcinfo.ch/*
// @match *://*.bienpublic.com/*
// @match *://*.businessam.be/*
// @match *://*.connaissancedesarts.com/*
// @match *://*.courrierinternational.com/*
// @match *://*.dhnet.be/*
// @match *://*.femmesdaujourdhui.be/*
// @match *://*.flair.be/fr/*
// @match *://*.jeuneafrique.com/*
// @match *://*.journaldunet.com/*
// @match *://*.la-croix.com/*
// @match *://*.lacote.ch/*
// @match *://*.lalibre.be/*
// @match *://*.lavenir.net/*
// @match *://*.lecho.be/*
// @match *://*.ledauphine.com/*
// @match *://*.ledevoir.com/*
// @match *://*.legrandcontinent.eu/*
// @match *://*.lejsl.com/*
// @match *://*.lenouvelliste.ch/*
// @match *://*.lerevenu.com/*
// @match *://*.lesinrocks.com/*
// @match *://*.lesoir.be/*
// @match *://*.letemps.ch/*
// @match *://*.levif.be/*
// @match *://*.loeildelaphotographie.com/*
// @match *://*.marianne.net/*
// @match *://*.monacomatin.mc/*
// @match *://*.moustique.be/*
// @match *://*.parismatch.com/*
// @match *://*.philonomist.com/fr/*
// @match *://*.pourleco.com/*
// @match *://*.science-et-vie.com/*
// @match *://*.sudinfo.be/*
// @match *://*.valeursactuelles.com/*
// @connect archive.fo
// @connect archive.is
// @connect archive.li
// @connect archive.md
// @connect archive.ph
// @connect archive.vn
// @connect apps.lemonde.fr
// @exclude *://*.poool.fr/*
// @exclude *://*.weborama.fr/*
// @grant GM.xmlHttpRequest
// @require https://gitflic.ru/project/magnolia1234/bypass-paywalls-clean-filters/blob/raw?file=userscript/bpc_func.js
// ==/UserScript==
(function() {
//'use strict';
window.setTimeout(function () {
var be_groupe_ipm_domains = ['dhnet.be', 'lalibre.be', 'lavenir.net', 'moustique.be'];
var be_roularta_domains = ['femmesdaujourdhui.be', 'flair.be', 'levif.be'];
var fr_be_groupe_rossel_domains = ['aisnenouvelle.fr', 'courrier-picard.fr', 'lardennais.fr', 'lavoixdunord.fr', 'lemessager.fr', 'lesoir.be', 'lest-eclair.fr', 'liberation-champagne.fr', 'lunion.fr', 'nordlittoral.fr', 'paris-normandie.fr', 'sudinfo.be'];
var fr_gcf_custom_domains = ['larep.fr', 'leberry.fr', 'lechorepublicain.fr', 'lejdc.fr', 'lepopulaire.fr', 'leveil.fr', 'lyonne.fr'];
var fr_groupe_ebra_domains = ['bienpublic.com', 'dna.fr', 'estrepublicain.fr', 'lalsace.fr', 'ledauphine.com', 'lejsl.com', 'leprogres.fr', 'republicain-lorrain.fr', 'vosgesmatin.fr'];
var fr_groupe_la_depeche_domains = ['centrepresseaveyron.fr', 'journaldemillau.fr', 'ladepeche.fr', 'lindependant.fr', 'midilibre.fr', 'nrpyrenees.fr', 'petitbleu.fr', 'rugbyrama.fr'];
var fr_groupe_la_manche_libre_custom_domains = ['echoancenis.fr', 'echoduberry.fr', 'hautanjou.fr', 'larenaissancehebdo.fr', 'lecourriercauchois.fr', 'lecourrierdelamayenne.fr'];
var fr_groupe_nice_matin_domains = ['monacomatin.mc', 'nicematin.com', 'varmatin.com'];
if (matchDomain('alternatives-economiques.fr')) {
window.setTimeout(function () {
let paywall = document.querySelector('#temp-paywall');
removeDOMElement(paywall);
let data_ae_poool = document.querySelector('div[data-ae-poool]');
if (data_ae_poool)
data_ae_poool.removeAttribute('style');
}, 1000); // Delay (in milliseconds)
}
else if (matchDomain('aoc.media')) {
func_post = function () {
let article = document.querySelector('section.bottom-article');
if (article)
article.style = 'margin-bottom: 25px;';
}
getJsonUrl('section.article-payant', '', 'div.premium-article');
}
else if (matchDomain(['arcinfo.ch', 'lacote.ch', 'lenouvelliste.ch'])) {// Groupe ESH Médias
window.setTimeout(function () {
let paywall = document.querySelector('section#paywall-articles');
if (paywall) {
removeDOMElement(paywall);
let url_id = window.location.pathname.match(/\d+$/).pop();
let html = document.documentElement.outerHTML;
let json;
if (html.includes('window.__NUXT__=')) {
json = html.split('window.__NUXT__=')[1].split('')[0].trim().replace(/blocs:\[\{.*?\}\],/g, '');
if (url_id && !json.includes('{"' + url_id + '":'))
refreshCurrentTab();
}
let article = document.querySelector('div.html-content');
let no_intro = false;
if (!article) {
article = document.querySelector('div.container-mobile-full');
no_intro = true;
}
if (article && json) {
let content = '';
if (json.includes('text_1="'))
content = json.split('text_1="').pop().split('";')[0];
else {
let parts = json.split('html:"');
parts.splice(0, 1);
for (let part of parts)
content += part.split('",has_pre_content')[0];
}
if (content) {
content = content.replace(/\\u003C/g, '<').replace(/\\u003E/g, '>').replace(/\\u002F/g, '/').replace(/\\"/g, '"').replace(/\\r\\n/g, '');
let parser = new DOMParser();
let content_new = parser.parseFromString('
$)/g) || []).length !== 1) {
let elem_type = 'div';
if (par.title) {
par.content = '
' + par.title + '
' + par.content;
} else if (par.note) {
if (par.note.label && par.note.rating) {
let par_img = par.note.image || par.note.picture;
let img = (par_img && par_img.url) ? '
.replace('{height}', 200).replace('{quality}', '75') + ')
' : '';
par.content = '
' + par.note.label + ': ' + par.note.rating + '
' + img + par.content;
}
}
let doc = parser.parseFromString('
' + par.content + '
', 'text/html');
elem = doc.querySelector(elem_type);
}
} else if (par.title) {
elem = document.createElement('h2');
elem.innerText = par.title;
} else if (par.media) {
if (par.media.url && par.media.ratio) {
let ratio = par.media.ratio;
if (!parseInt(ratio))
ratio = 1.5;
let url = par.media.url.replace(/\\u002F/g, '/').replace('{width}', '400').replace('{height}', parseInt(400 / ratio)).replace('{quality}', '75');
let caption = par.media.legende && par.media.legende.length > 2 ? par.media.legende : '';
elem = makeFigure(url, caption, {}, {'style': 'font-weight: bold;'});
} else if (par.media.__type === 'video' && par.media.id) {
let url = par.media.image.url.replace('{width}', '400').replace('{height}', 400).replace('{quality}', '75');
elem = makeFigure(url, par.media.legend);
let video_link = document.createElement('a');
video_link.href = video_link.innerText = 'https://geo.dailymotion.com/player.html?video=' + par.media.id;
video_link.style = 'text-decoration: underline;';
video_link.target = '_blank';
elem.appendChild(video_link);
}
} else if (par.__type === 'article_paragraph_playing_field') {
if (par.data) {
let url = par.data;
fetch(url)
.then(response => {
if (response.ok) {
response.json().then(json => {
if (json.arbitre && json.titulaires) {
let ids = [json.arbitre].concat(json.titulaires);
if (json.banc)
for (let elem of json.banc)
ids = ids.concat([elem.entraineur], elem.remplacants);
let notes = document.querySelectorAll('span.EditorRatingsField__note');
for (let note of notes) {
let name_dom = note.parentNode.querySelector('span[class$="--name"]');
if (name_dom) {
let name = (name_dom.innerText.includes(':') ? name_dom.innerText.split(':')[1] : name_dom.innerText).trim();
let json_note = ids.find(x => x.nom === name);
if (json_note)
note.innerText = json_note.note;
}
}
}
})
}
})
}
} else if (!['article_paragraph_pub'].includes(par.__type))
console.log(par);
if (elem)
article.appendChild(elem);
}
} catch (err) {
console.log(err);
}
})
}
}).catch(x => header_nofix(article, '', 'BPC > no fix (source file)'))
}
}
let ads = 'div.AmPlaceholder, div.Modal[data-modal="amsBlock"]';
hideDOMStyle(ads);
let noscroll = document.querySelector('html');
if (noscroll)
noscroll.style.overflow = 'auto';
}
else if (matchDomain('lerevenu.com')) {
let ads = 'div.wrapperAd';
hideDOMStyle(ads);
}
else if (matchDomain(['lesechos.fr', 'historia.fr'])) {
if (window.location.pathname.startsWith('/amp/')) {
ampToHtml();
} else {
window.setTimeout(function () {
let paywall = document.querySelector('div#paywall, div#registerWall');
if (paywall) {
removeDOMElement(paywall);
let filter = /window\.__REACT_QUERY_STATE__\s?=\s?/;
let json_script = getSourceJsonScript(filter);
if (json_script) {
try {
let json = JSON.parse(json_script.text.split(filter)[1].split('};')[0] + '}');
let data_article = json.queries.filter(x => x.state.data.stripes)[0].state;
let url = window.location.href;
let url_loaded = data_article.data.path;
if (url_loaded && (!url_loaded.slice(-7).match(/\d+/) || !url.includes(url_loaded.slice(-7))))
refreshCurrentTab();
else {
let json_text = data_article.data.stripes[0].mainContent[0].data.description;
let article = document.querySelector('div.post-paywall');
if (article) {
let contentNode = document.createElement('div');
let parser = new DOMParser();
let doc = parser.parseFromString('
' + json_text + '
', 'text/html');
let article_new = doc.querySelector('div');
let videos = article_new.querySelectorAll('iframe[allow*="fullscreen"][allowfullscreen]');
for (let elem of videos) {
elem.removeAttribute('allowfullscreen');
if (mobile)
elem.style.width = '100%';
}
if (article.parentNode && article_new) {
article.parentNode.replaceChild(article_new, article);
let article_lastnode = document.querySelector('.post-paywall > :last-child');
if (article_lastnode) {
article_lastnode.setAttribute('style', 'height: auto !important; overflow: hidden !important; max-height: none !important;');
}
}
}
let styleElem = document.head.appendChild(document.createElement('style'));
styleElem.innerText = ".post-paywall::after {height: auto !important;}";
}
} catch (err) {
console.log(err);
}
}
}
let ads = 'div.sc-1u9r8h-0';
hideDOMStyle(ads);
}, 500);
}
}
else if (matchDomain('lesinrocks.com')) {
if (window.location.search.match(/(\?|&)amp/)) {
let size_defined = document.querySelector('amp-script.i-amphtml-layout-size-defined');
if (size_defined)
size_defined.style = 'overflow:visible !important;';
let overlays = document.querySelectorAll('section.learn_more, div.sidebar, div.menu-footer, div.tooltip_bib, footer.content-info');
removeDOMElement(...overlays);
}
}
else if (matchDomain('letelegramme.fr')) {
let paywall = document.querySelectorAll('div.tlg-paywalled');
for (let elem of paywall)
elem.classList.remove('tlg-paywalled');
let ads = 'div[id^="pub_"]';
hideDOMStyle(ads);
}
else if (matchDomain('letemps.ch')) {
let url = window.location.href;
getArchive(url, 'div.post-subscribe', '', 'div#article-body-wrapper');
let fade = document.querySelector('div.post__content--faded');
if (fade)
fade.classList.remove('post__content--faded');
let top_ad = document.querySelector('div.topad');
removeDOMElement(top_ad);
}
else if (matchDomain(be_roularta_domains)) {
let paywall = document.querySelector('div[id*="wall-modal"]');
if (paywall) {
removeDOMElement(paywall);
let html = document.querySelector('html[class]');
if (html)
html.removeAttribute('class');
function roularta_noscroll(node) {
node.removeAttribute('style');
node.removeAttribute('class');
}
waitDOMAttribute('html', 'html', 'class', roularta_noscroll, true);
let intro = document.querySelectorAll('div.article-body > p, div.article-body > style');
removeDOMElement(...intro);
let locked = document.querySelector('body.locked');
if (locked)
locked.classList.remove('locked');
}
if (!window.navigator.userAgent.toLowerCase().includes('chrome') && window.location.href.match(/\/(\w+-){2,}/)) {
let lazy_images = document.querySelectorAll('img[src^="data:image/"][data-lazy-src]');
for (let elem of lazy_images) {
elem.src = elem.getAttribute('data-lazy-src');
}
}
let ads = 'div.rmgAd, div.c-header__ad';
hideDOMStyle(ads);
}
else if (matchDomain('lexpress.fr')) {
let ads = 'div[class^="block_pub"], div[class^="bottom-bar"], div.teads__block, div.ban-bottom, div[class^="placeholder--ban-atf"]';
hideDOMStyle(ads);
}
else if (matchDomain('liberation.fr')) {
let paywall = document.querySelector('div.article-body-paywall');
if (paywall) {
removeDOMElement(paywall);
let article = document.querySelector('article[data-datawall-status]') || document.querySelector('div[class^="default__Main-sc-"] div:empty:not([class], [style])');
if (article) {
let url_src = 'https://arc.api.liberation.fr/content/v4/?website=liberation&website_url=' + encodeURIComponent(window.location.pathname);
let x_api_key = 'a7X29mBvQeP1Ld98CgF2rK5uTzWY4h';
fetch(url_src, {headers: {"x-api-key": x_api_key}})
.then(response => {
if (response.ok) {
response.json().then(json => {
if (json && json.content_elements) {
let pars = json.content_elements;
if (pars.length)
article.innerHTML = '';
let parser = new DOMParser();
for (let par of pars) {
let elem = document.createElement('p');
let sub_elem;
if (['header', 'raw_html', 'text'].includes(par.type)) {
if (par.content) {
let doc = parser.parseFromString('
' + par.content + '
', 'text/html');
sub_elem = doc.querySelector('div');
if (par.type === 'header')
sub_elem.style = 'font-weight: bold; font-size: 1.85rem;';
}
} else if (par.type === 'correction') {
if (par.text) {
sub_elem = document.createElement('span');
elem.innerText = par.text;
}
} else if (par.type === 'image') {
if (par.url) {
sub_elem = document.createElement('img');
sub_elem.src = par.url;
}
} else if (par.type === 'custom_embed') {
if (par.embed && par.embed.config) {
let config = par.embed.config;
sub_elem = document.createElement('div');
sub_elem.style = 'border: 1px solid black;';
if (config.title) {
let sub_item = document.createElement('p');
sub_item.innerText = config.title;
sub_item.style = 'font-weight: bold; margin: 20px;';
sub_elem.appendChild(sub_item);
}
if (config.content) {
let sub_item = document.createElement('p');
sub_item.innerText = config.content;
sub_item.style = 'margin: 20px;';
sub_elem.appendChild(sub_item);
}
} else
console.log(par);
} else if (par.type === 'oembed_response') {
if (par.raw_oembed && par.raw_oembed.html) {
if (!par.subtype === 'twitter') {
let doc = parser.parseFromString('
' + par.raw_oembed.html + '
', 'text/html');
sub_elem = doc.querySelector('div');
} else if (par.raw_oembed.url) {
sub_elem = document.createElement('a');
sub_elem.href = sub_elem.innerText = par.raw_oembed.url;
sub_elem.target = '_blank';
}
}
} else if (par.type === 'link_list') {
if (par.items) {
sub_elem = document.createElement('p');
sub_elem.appendChild(document.createElement('hr'));
sub_elem.appendChild(document.createTextNode('Lire aussi'));
sub_elem.appendChild(document.createElement('br'));
for (let item of par.items) {
if (item.content && item.url) {
let item_link = document.createElement('a');
item_link.href = item.url;
item_link.innerText = item.content;
sub_elem.appendChild(item_link);
sub_elem.appendChild(document.createElement('br'));
}
}
sub_elem.appendChild(document.createElement('hr'));
}
} else if (!['quote'].includes(par.type)) {
console.log(par);
}
if (sub_elem) {
elem.appendChild(sub_elem);
article.appendChild(elem);
}
}
}
})
}
}).catch(x => header_nofix(article, '', 'BPC > no fix (source file)'))
}
}
let ads = 'div[class^="StickyAd"], div[class^="default__OutbrainWrapper"]';
hideDOMStyle(ads);
}
else if (matchDomain('loeildelaphotographie.com')) {
let paywall = document.querySelector('.paywall');
if (paywall) {
paywall.removeAttribute('class');
}
let premium_pic_boxes = document.querySelectorAll('.premium-pic-box');
let banners = document.querySelectorAll('.membership-promo-container, .login_form_litle');
removeDOMElement(...premium_pic_boxes, ...banners);
let blurred_images = document.querySelectorAll('img[style*="blur"]');
for (let blurred_image of blurred_images)
blurred_image.removeAttribute('style');
}
else if (matchDomain('lopinion.fr')) {
let url = window.location.href;
getArchive(url, 'div.paywall-premium', '', 'div.mainBody', '', 'div[style*=";line-height:1.8;"] div[style*=";line-height:1.8;"]');
let ads = 'div.ResponsiveAd';
hideDOMStyle(ads);
}
else if (matchDomain('marianne.net')) {
let paywall = document.querySelector('div.paywall');
if (paywall) {
removeDOMElement(paywall);
let article = document.querySelector('div > div.js-poool-wrapper');
if (article) {
let limit_low = 50;
let limit_high = 400;
function show_data(article, body) {
let parser = new DOMParser();
let doc = parser.parseFromString('
' + body + '
', 'text/html');
let article_new = doc.querySelector('div');
let lazy_images = article_new.querySelectorAll('img.lazyload[data-src]:not([src])');
for (let elem of lazy_images) {
elem.src = elem.getAttribute('data-src');
elem.classList.remove('lazyload');
}
article.innerHTML = '';
article.parentNode.replaceChild(article_new, article);
}
function fetch_data(limit, offset = 0) {
let url_src = 'https://mobile.marianne.net/premium?limit=' + limit + '&offset=' + offset;
fetch(url_src)
.then(response => {
if (response.ok) {
response.json().then(json => {
try {
let src_articles = json.feed_auto;
if (src_articles) {
let src_article = src_articles.filter(x => x.urlWeb === url)[0];
let ls_update = true;
if (src_article)
show_data(article, src_article.body);
else if (limit === limit_low) {
ls_update = false;
fetch_data(limit_high);
} else
header_nofix(article, '', 'BPC > no fix (source file)');
if (ls_update) {
let now_date = (new Date()).toISOString().split('T')[0];
if (!ls_date || limit > limit_low || now_date > ls_date)
ls_json_articles = {};
for (let art of src_articles)
ls_json_articles[art.urlWeb] = art.body;
localStorage.setItem('###_json_date', now_date);
localStorage.setItem('###_json', JSON.stringify(ls_json_articles));
}
}
} catch (err) {
console.log(err);
}
})
}
}).catch(x => header_nofix(article, '', 'BPC > no fix (source file)'))
}
let url = window.location.href.split(/[#\?]/)[0];
let meta_date = document.querySelector('head > meta[property="article:published_time"][content]');
let art_date = '';
if (meta_date)
art_date = meta_date.content.split('T')[0];
let ls_date = localStorage.getItem('###_json_date') || '';
let ls_json_articles = {};
if (ls_date) {
let ls_articles = localStorage.getItem('###_json');
ls_json_articles = JSON.parse(ls_articles);
if (ls_date <= art_date)
fetch_data(limit_low);
else {
let art_data = ls_json_articles[url];
if (art_data)
show_data(article, art_data);
else if (Object.keys(ls_json_articles).length <= limit_low)
fetch_data(limit_high);
else
header_nofix(article, '', 'BPC > no fix (source file)')
}
} else {
fetch_data(limit_low);
}
}
}
let ads = 'div[class*="--placeholder"]';
hideDOMStyle(ads);
}
else if (matchDomain('ouest-france.fr')) {
if (matchDomain('www.ouest-france.fr')) {
function ouest_france_main() {
window.cmsfetch.push({
url: window.cms_bypass_rpc_url,
params: {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
id: 'platform/bypass-payant/get',
jsonrpc: '2.0',
method: 'getToken',
params: {
publicitaire: !0,
id_contenu: window.dataLayer[0].mdId
}
})
},
fn: function (e) {
let data = JSON.parse(e);
let newURL = new URL(window.location.href);
newURL.searchParams.append('token', data.result.token);
window.location.href = newURL.toString();
}
});
}
if (!window.location.search.includes('token=')) {
let paywall = document.querySelector('div.mur');
if (paywall) {
removeDOMElement();
insert_script(ouest_france_main);
}
} else {
document.querySelectorAll('iframe:not([src])[data-embed-src]').forEach(e => e.src = e.getAttribute('data-embed-src'));
}
} else {
function ouest_france_sub() {
if (window.location.pathname.includes('/video-')) {
let video = document.querySelector('article figure');
if (video) {
let og_video_dom = document.querySelector('head > meta[property="og:video"][content]');
if (og_video_dom) {
let video_new = document.createElement('video');
video_new.src = og_video_dom.content;
video_new.style = 'width: 100%;';
video_new.setAttribute('controls', '');
video.parentNode.replaceChild(video_new, video);
}
}
} else {
let title_dom = document.querySelector('head > meta[name="twitter:title"][content]');
if (title_dom) {
let title = encodeURIComponent(title_dom.content);
let app_id = window.sessionStorage.getItem('###_app_id');
fetch('https://' + app_id + '-dsn.algolia.net/1/indexes/*/queries', {
method: "POST",
headers: {
"Content-Type": "application/json",
"x-algolia-api-key": window.bp_algolia_articles,
"x-algolia-application-id": app_id.toUpperCase()
},
body: JSON.stringify({
requests: [{
indexName: "articles",
params: 'query=' + title
}
]
})
})
.then(response => {
if (response.ok) {
response.json().then(json => {
let results = json.results[0].hits;
let article = results.find((result) => result.articleId == window.dataLayer[0].mdId);
if (article) {
let body = document.querySelector('div#article-detail > div.su-article');
if (body) {
body.parentNode.classList.remove('cache');
let article_text = article.texte;
let pars = body.querySelectorAll('p, h2');
for (let par of pars) {
let par_text = par.innerText.replace(/\u00a0/g, ' '); //
if (article_text.startsWith(par_text)) {
article_text = article_text.replace(par_text, '').trim();
} else if (par.tagName === 'P' && par_text.endsWith('...')) {
par.remove();
break;
}
}
let par_new = document.createElement('p');
par_new.innerText = article_text;
body.appendChild(par_new);
if (article.photos && article.photos.length > 1) {
let header_img = document.querySelector('article figure img[src]');
if (header_img && header_img.src.includes('/pictures/')) {
let img_base = header_img.src.split('/pictures/')[0] + '/pictures/';
let img_first = true;
for (let img of article.photos) {
if (!img_first) {
let figure = document.createElement('figure');
figure.style = 'margin: 20px 0px;';
let img_new = document.createElement('img');
img_new.src = img_base + img.id;
let caption = document.createElement('figcaption');
caption.innerText = img.legende + ' | ' + img.credits;
figure.append(img_new, caption);
body.appendChild(figure);
} else
img_first = false;
}
}
}
if (article.hasVideo)
console.log('hasVideo');
}
}
})
}
}).catch(err => console.log(err));
}
}
}
let paywall = document.querySelector('div.mur');
if (paywall) {
removeDOMElement(paywall);
window.sessionStorage.setItem('###_app_id', 'c8kp7jv01t');
insert_script(ouest_france_sub);
}
}
let ads = 'div.pub, div.feed-taboola';
hideDOMStyle(ads);
let banner = document.querySelector('div#pub_megabanner');
removeDOMElement(banner);
}
else if (matchDomain('philonomist.com')) {
let paywall = document.querySelector('div.content-bandeau');
if (paywall) {
removeDOMElement(paywall);
let json_script = getArticleJsonScript();
if (json_script) {
let json = JSON.parse(json_script.text);
if (json) {
let json_text = parseHtmlEntities(findKeyJson(json, ['articleBody'])).replace(/\s{2,}/g, '\r\n\r\n');
let article = document.querySelector('div.main-body');
if (json_text && article) {
let par_last = article.querySelector('div > p:last-child');
if (par_last) {
let par_last_str = par_last.innerText.substring(0, 50);
if (json_text.replace(/<[^<]*>/g, '').includes(par_last_str)) {
par_last.innerText = json_text.substring(json_text.indexOf(par_last_str));
} else {
article.innerHTML = ' ';
let article_new = document.createElement('p');
article_new.innerText = json_text;
article.appendChild(article_new);
}
}
}
}
}
}
}
else if (matchDomain('pourleco.com')) {
let paywall = document.querySelector('div[data-pleco-poool^="paywall"]');
if (paywall) {
let intro = document.querySelector('div[data-pleco-transition="fade"]');
removeDOMElement(paywall, intro);
let article = document.querySelector('div[class*="article-"][style]');
if (article)
article.removeAttribute('style');
}
}
else if (matchDomain('reforme.net')) {
let article_sel = 'div.elementor-widget-theme-post-content';
getJsonUrl(article_sel + ' section', '', article_sel);
let banner = 'div.free-access-banner';
hideDOMStyle(banner);
}
else if (matchDomain('science-et-vie.com')) {
if (window.location.hostname.startsWith('amp.')) {
let pars = document.querySelectorAll('.qiota_reserve > p, .qiota_reserve > h2');
let pars_text = [];
for (let par of pars) {
if (pars_text.includes(par.innerText))
removeDOMElement(par);
else
pars_text.push(par.innerText);
}
let sizer = document.querySelector('div.article-content > amp-script > i-amphtml-sizer');
removeDOMElement(sizer);
let replaced_content = document.querySelector('div.i-amphtml-replaced-content');
if (replaced_content)
replaced_content.removeAttribute('class');
}
}
else if (matchDomain(['sudouest.fr', 'charentelibre.fr', 'larepubliquedespyrenees.fr'])) {
let paywall = document.querySelectorAll('.visible-not-premium');
if (paywall.length) {
removeDOMElement(...paywall);
let visible_premium = document.querySelectorAll('div.visible-premium');
for (let elem of visible_premium)
elem.classList.remove('visible-premium');
}
let footer_premium = '.footer-premium';
let ads = 'div.pub, div.ph-easy-subscription';
hideDOMStyle(footer_premium + ', ' + ads);
}
else if (matchDomain('telerama.fr')) {
let paywall = document.querySelector('section.paywall');
if (paywall) {
removeDOMElement(paywall);
let article_sel = 'article.article__page-content';
let article = document.querySelector(article_sel);
if (article) {
let url_src = 'https://apps.telerama.fr/tlr/v1/premium-android-tablet/element?id=' + encodeURIComponent(window.location.pathname);
let json_key = 'templates.raw_content.content';
getExtFetch(url_src, json_key, {}, main_telerama);
function main_telerama(url, data) {
try {
if (data) {
let parser = new DOMParser();
let doc = parser.parseFromString(data, 'text/html');
let article_new = doc.querySelector(article_sel);
if (article_new && article.parentNode) {
article_new.querySelectorAll('a[href^="tlrm://element?id="]').forEach(e => e.href = decodeURIComponent(e.href.split('tlrm://element?id=')[1]));
article_new.querySelectorAll('figure > img[data-src]:not([src])').forEach(e => e.src = e.getAttribute('data-src'));
article.parentNode.replaceChild(article_new, article);
}
}
} catch (err) {
console.log(err);
}
}
}
}
let ads = 'div.dfp-slot';
hideDOMStyle(ads);
}
else if (matchDomain('valeursactuelles.com')) {
let paywall = document.querySelector('div.qiota');
if (paywall) {
removeDOMElement(paywall);
let qiota_hidden = document.querySelector('div.qiota_reserve');
if (qiota_hidden)
qiota_hidden.removeAttribute('class');
}
let banners = 'div.subscription-banner, div.stick-sidebar';
hideDOMStyle(banners);
}
else if (matchDomain('lamontagne.fr') || matchDomain(fr_gcf_custom_domains)) { // Groupe Centre France
let paywall = document.querySelector('meta[name="premium"][content="true"]');
if (paywall) {
removeDOMElement(paywall);
let article = document.querySelector('div#content section > div.flex-col');
if (article) {
let div_empty = article.querySelector('div[class^="min-h"]:empty');
removeDOMElement(div_empty);
let url = window.location.href;
fetch(url)
.then(response => {
if (response.ok) {
response.text().then(html => {
if (html.includes('\\"contentJson\\":')) {
let html_json = html.split('\\"contentJson\\":')[1].split(']},\\"')[0].replace(/\\"/g, '"').replace(/\\\\"/g, '\\"') + ']}';
try {
let json = JSON.parse(html_json);
if (json && json.content) {
let cf_paywall = json.content.find(x => x.type === 'cf-paywall');
if (cf_paywall) {
let pars = cf_paywall.content;
for (let par of pars) {
function handle_par(par) {
let elem = document.createElement('div');
if (['paragraph', 'heading', 'cf-line-heading', 'cf-quote'].includes(par.type)) {
if (par.content) {
if (par.type === 'heading')
elem.style = 'font-weight: bold;';
else if (par.type === 'cf-quote')
elem.style = 'font-style: italic;';
for (let item of par.content) {
let sub_elem;
if (item.text) {
sub_elem = document.createElement('span');
let sub_elem_style = '';
if (item.marks) {
for (let mark of item.marks) {
if (mark.type === 'link') {
if (mark.attrs && mark.attrs.href) {
sub_elem = document.createElement('a');
sub_elem.href = mark.attrs.href;
sub_elem_style = 'text-decoration:underline;';
}
} else if (mark.type === 'bold')
sub_elem_style += 'font-weight: bold;';
else if (mark.type === 'italic')
sub_elem_style += 'font-style: italic;';
if (sub_elem_style)
sub_elem.style = sub_elem_style;
}
}
sub_elem.innerText = item.text;
if (par.type === 'cf-quote') {
if (par.attrs && par.attrs.author)
sub_elem.innerText += ' - ' + par.attrs.author + (par.attrs.source ? ' ' + par.attrs.source : '');
}
} else if (item.type === 'hardBreak') {
sub_elem = document.createElement('br');
} else
console.log(item);
if (sub_elem)
elem.appendChild(sub_elem);
}
}
} else if (par.type === 'cf-image') {
if (par.attrs && par.attrs.src) {
elem = document.createElement('img');
elem.src = par.attrs.src;
}
} else if (par.type === 'cf-embed') {
if (par.attrs && par.attrs.url) {
elem = document.createElement('iframe');
elem.src = par.attrs.url.replace(/^\/\//, 'https://');
if (par.attrs.width)
elem.width = par.attrs.width;
if (par.attrs.height)
elem.height = par.attrs.height;
}
} else if (par.type === 'cf-read-also') {
if (par.attrs && par.attrs.text && par.attrs.url) {
elem = document.createElement('a');
elem.innerText = 'À lire aussi: ' + par.attrs.text;
elem.href = par.attrs.url;
elem.style = 'text-decoration:underline;';
}
} else {
console.log(par);
}
if (elem)
article.appendChild(elem);
}
if (par.type === 'cf-aside' && par.content) {
for (let sub_par of par.content)
handle_par(sub_par);
} else
handle_par(par);
}
}
}
if (html.includes(',\\"textToSpeech\\":{')) {
let tts_url = html.split(',\\"textToSpeech\\":{')[1].split(',\\"url\\":\\"')[1].split('\\",\\"')[0];
if (tts_url) {
let audio_div = document.createElement('div');
audio_div.innerText = "Écouter l'article";
audio_div.style = 'margin-bottom: 20px; font-weight: bold;';
let audio = document.createElement('audio');
audio.src = tts_url;
audio.style = 'width: 100%';
audio.setAttribute('controls', '');
audio_div.appendChild(audio);
article.before(audio_div);
}
}
} catch (err) {
console.log(err);
}
}
})
}
}).catch(err => console.log(err))
}
}
let ads = 'div.ad-slot, div[class="w-[100vw]"], div.transition-all';
hideDOMStyle(ads);
}
ads_hide();
leaky_paywall_unhide();
}, 1000);
// General Functions
// import (see @require)
})();