// ==UserScript==
// @name Bypass Paywalls Clean - de/at/ch
// @version 4.2.3.6
// @description Bypass Paywalls of news sites
// @author magnolia1234
// @downloadURL https://gitflic.ru/project/magnolia1234/bypass-paywalls-clean-filters/blob/raw?file=userscript/bpc.de.user.js
// @updateURL https://gitflic.ru/project/magnolia1234/bypass-paywalls-clean-filters/blob/raw?file=userscript/bpc.de.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 *://*.de/*
// @match *://*.beobachter.ch/*
// @match *://*.blick.ch/*
// @match *://*.faz.net/*
// @match *://*.handelsblatt.com/*
// @match *://*.handelszeitung.ch/*
// @match *://*.kurier.at/*
// @match *://*.nzz.ch/*
// @match *://*.profil.at/*
// @match *://*.schweizermonat.ch/*
// @match *://*.themarket.ch/*
// @match *://*.vn.at/*
// @match *://*.vol.at/*
// @match *://*.wochenblatt.com/*
// @connect archive.fo
// @connect archive.is
// @connect archive.li
// @connect archive.md
// @connect archive.ph
// @connect archive.vn
// @connect fnetcore-api-prod.azurewebsites.net
// @connect funkemedien.de
// @grant GM.xmlHttpRequest
// @require https://gitflic.ru/project/magnolia1234/bypass-paywalls-clean-filters/blob/raw?file=userscript/bpc_func.js
// ==/UserScript==
(function() {
//'use strict';
if (matchDomain('automobilwoche.de')) {
function automobilwoche_main() {
if (window.Fusion) {
window.Fusion.globalContent._id = 0;
window.Fusion.globalContent.content_restrictions = {};
}
}
window.setTimeout(function () {
insert_script(automobilwoche_main);
}, 100);
}
window.setTimeout(function () {
var de_funke_medien_domains = ['abendblatt.de', 'braunschweiger-zeitung.de', 'harzkurier.de', 'ikz-online.de', 'morgenpost.de', 'nrz.de', 'otz.de', 'thueringer-allgemeine.de', 'tlz.de', 'waz.de', 'wp.de', 'wr.de'];
var de_ippen_media_domains = ['fr.de', 'merkur.de', 'ovb-online.de'];
var de_lv_domains = ['profi.de', 'wochenblatt.com'];
var de_madsack_domains = ['haz.de', 'kn-online.de', 'ln-online.de', 'lvz.de', 'maz-online.de', 'neuepresse.de', 'ostsee-zeitung.de', 'rnd.de', 'saechsische.de'];
var de_motor_presse_domains = ['aerokurier.de', 'auto-motor-und-sport.de', 'flugrevue.de', 'motorradonline.de', 'womenshealth.de'];
var de_rp_medien_domains = ['ga.de', 'rp-online.de', 'saarbruecker-zeitung.de', 'volksfreund.de'];
var de_smn_domains = ['schwarzwaelder-bote.de', 'stuttgarter-nachrichten.de', 'stuttgarter-zeitung.de'];
var de_smn_custom_domains = ['cannstatter-zeitung.de', 'esslinger-zeitung.de', 'frankenpost.de', 'insuedthueringen.de', 'krzbb.de', 'kurier.de', 'np-coburg.de'];
var de_vrm_domains = ['allgemeine-zeitung.de', 'echo-online.de', 'wiesbadener-kurier.de'];
var de_vrm_custom_domains = ['buerstaedter-zeitung.de', 'hochheimer-zeitung.de', 'lampertheimer-zeitung.de', 'lauterbacher-anzeiger.de', 'main-spitze.de', 'mittelhessen.de', 'oberhessische-zeitung.de', 'wormser-zeitung.de'];
if (matchDomain('aachener-zeitung.de')) {
let url = window.location.href;
getArchive(url, 'div[data-testid="paywall-position-popover"]', '', 'article');
let shade = document.querySelector('div.paywalled-article');
if (shade)
shade.classList.remove('paywalled-article');
let noscroll = document.querySelectorAll('html[class], body[class]');
for (let elem of noscroll)
elem.removeAttribute('class');
let ads = 'section[data-theme-sponsored-content]';
hideDOMStyle(ads);
}
else if (matchDomain('aerztezeitung.de')) {
let paywall = document.querySelector('div.AZLoginModule');
if (paywall) {
removeDOMElement(paywall);
let json_script = getArticleJsonScript();
if (json_script) {
let json = JSON.parse(json_script.text);
if (json) {
let json_text = json.articleBody;
let content = document.querySelector('p.intro');
if (json_text && content) {
let article_new = document.createElement('p');
article_new.innerText = json_text;
content.after(article_new);
}
}
}
}
}
else if (matchDomain('automobilwoche.de')) {
let banners = 'div#piano-paywall-container';
hideDOMStyle(banners);
}
else if (matchDomain(['beobachter.ch', 'handelszeitung.ch'])) {
window.setTimeout(function () {
let paywall = document.querySelector('div#piano-inlined');
if (paywall) {
removeDOMElement(paywall);
let fade = document.querySelector('div.article-body > div.paywall-wrapper-with-print-info');
removeDOMElement(paywall, fade);
let json_script = document.querySelector('script#hydrationdata');
if (json_script) {
try {
let json = JSON.parse(json_script.text);
if (json) {
let url_id = json_script.text.includes('"gcid":"') ? json_script.text.split('"gcid":"')[1].split('"')[0] : '';
if (url_id && !window.location.pathname.endsWith(url_id))
refreshCurrentTab();
let pars = json.state;
let paragraphs = document.querySelectorAll('div.paragraph');
let article = paragraphs[0];
if (article) {
article.setAttribute('class', 'paragraph text-paragraph');
for (let paragraph of paragraphs)
paragraph.innerHTML = '';
let parser = new DOMParser();
let img_first = true;
let img_use = false;
let img_caption;
for (let par in pars) {
let par_elem = pars[par];
let elem = document.createElement('div');
elem.style = 'font-size: 1.7rem; margin: 25px;';
let sub_elem;
if (par_elem.__typename === 'TextParagraph' && par_elem.text) {
let content_new = parser.parseFromString('
') ? 'div' : 'p';
let content_new = parser.parseFromString('<' + elem_type + '>' + parseHtmlEntities(par.content.html) + '' + elem_type + '>', 'text/html');
let iframe = content_new.querySelector('iframe');
if (iframe) {
iframe.style = 'width: 100%; margin-bottom: 32px;';
if (!iframe.height)
iframe.height = '400px';
}
elem = content_new.querySelector(elem_type);
}
} else if (par.component === 'ercms') {
if (par.content && par.content.url) {
elem = document.createElement('div');
let iframe = document.createElement('iframe');
iframe.src = par.content.url;
iframe.style = 'width: 100%; height: 400px; margin-bottom: 32px;';
elem.appendChild(iframe);
}
} else if (par.component === 'subheading') {
if (par.content && par.content.text) {
elem.innerText = par.content.text;
elem.style = 'font-weight: bold;';
}
} else if (par.component === 'image') {
if (par.image) {
let caption = par.caption ? par.caption.html + ' (Foto: ' + par.imageSource + ')' : '';
let sub_elem = makeFigure(par.image.url, caption);
elem.appendChild(sub_elem);
}
} else if (!(['articleHeader', 'articleTeaserM', 'newsletterEmbed'].includes(par.component) || par.component.startsWith('iqadtile')))
console.log(par);
if (elem.hasChildNodes())
article.appendChild(elem);
}
}
} catch (err) {
console.log(err);
}
}
}
}
}
let ads = 'er-ad-slot, div.iqdcontainer';
hideDOMStyle(ads);
}
else if (matchDomain('suedkurier.de')) {
func_post = function () {
let article = document.querySelector(article_sel);
if (article) {
let pars = article.querySelectorAll('section > div > div[style^="box-sizing:"]');
if (pars && pars.length < 3)
header_nofix(article_sel, '', 'BPC > no archive-fix');
}
}
let url = window.location.href;
let article_sel = 'main > article';
getArchive(url, 'aside.article-paywall', '', article_sel);
}
else if (matchDomain('t3n.de')) {
let paywall = document.querySelector('div.c-paywall__wrapper');
if (paywall) {
removeDOMElement(paywall);
let json_script = getArticleJsonScript();
if (json_script) {
let json = JSON.parse(json_script.text);
if (json) {
let json_text = json.articleBody;
if (json_text.includes('[embed]'))
json_text = json_text.replace(/\[embed\]([^\[]+)\[\/embed\]/g, '$1\n');
json_text = json_text.replace(/\[[^\]]+\]/g, '');
let article = document.querySelector('div.paywall-blur > p');
if (json_text && article) {
article.innerText = parseHtmlEntities(json_text);
article.parentNode.removeAttribute('class');
}
}
}
}
}
else if (matchDomain('tagesspiegel.de')) {
let paywall_sel = 'div#paywall';
let url = window.location.href;
if (matchDomain('www.tagesspiegel.de')) {
func_post = function () {
for (let elem of videos) {
let iframe = document.createElement('iframe');
iframe.src = elem.getAttribute('old-src');
iframe.style = 'width: 100%; height: 400px;';
elem.parentNode.replaceChild(iframe, elem);
}
let opinionary = document.querySelector('div > div#opinary-automation-placeholder');
if (opinionary)
hideDOMElement(opinionary.parentNode);
if (mobile) {
let lazy_images = document.querySelectorAll('figure img[loading="lazy"][style]');
for (let elem of lazy_images)
elem.style = 'width: 95%;';
}
}
getArchive(url, paywall_sel, '', 'div#story-elements');
} else if (matchDomain('interaktiv.tagesspiegel.de')) {
let paywall = document.querySelector(paywall_sel);
if (paywall) {
removeDOMElement(paywall);
let article = document.querySelector('div.tslr-article > p');
if (article)
article.firstChild.before(archiveLink(url));
}
}
let ads = 'div.iqdcontainer';
hideDOMStyle(ads);
}
else if (matchDomain('vn.at')) {
if (window.location.href.match(/\.vn\.at\/.+\/\d{4}\//)) {
let paywall = document.querySelector('div.paywalled-content');
if (paywall) {
let par = paywall.querySelector('p');
if (!par) {
refreshCurrentTab();
} else {
let lazy_images = document.querySelectorAll('img[src^="data:image/"][lazy-src]');
for (let elem of lazy_images) {
elem.src = elem.getAttribute('lazy-src');
}
}
} else
refreshCurrentTab();
}
}
else if (matchDomain('vol.at')) {
if (!window.location.pathname.match(/\/amp\/?$/)) {
window.setTimeout(function () {
let paywall = document.querySelector('div.vodl-region-article__premium-content');
if (paywall) {
paywall.removeAttribute('class');
if (!paywall.hasChildNodes()) {
let json_script = document.querySelector('script#externalPostDataNode');
if (json_script) {
try {
let json = JSON.parse(json_script.text);
let json_text = json.content.data.post.content;
let parser = new DOMParser();
let doc = parser.parseFromString('
' + json_text + '
', 'text/html');
let article_new = doc.querySelector('div');
let hidden_images = article_new.querySelectorAll('img[src^="/"][srcset]');
let json_domain = json.content.data.post.thumbnail.src.match(/https:\/\/(www\.)?\w+\.at/)[0];
for (let elem of hidden_images) {
elem.src = elem.src.replace('https://www.vol.at', json_domain);
elem.removeAttribute('srcset');
}
let hidden_comments = document.querySelector('div[class*="backdrop-blur"]');
if (hidden_comments)
hidden_comments.removeAttribute('class');
let article = document.querySelector('div.article-body');
if (article) {
article.innerHTML = '';
article.appendChild(article_new);
}
} catch (err) {
console.log(err);
}
}
}
}
}, 500);
let ads = 'div[id^="rm-adslot-"], div[id^="piano_rec"]';
hideDOMStyle(ads);
} else
ampToHtml();
}
else if (matchDomain('weltkunst.de')) {
let paywall = document.querySelector('section.paywall');
if (paywall) {
removeDOMElement(paywall);
let json_url_dom = document.querySelector('head > link[rel="alternate"][type="application/json"][href]');
if (json_url_dom) {
let json_url = json_url_dom.href;
fetch(json_url)
.then(response => {
if (response.ok) {
response.json().then(json => {
let json_text = json.content.rendered;
let content = document.querySelector('div.article div.text');
if (json_text) {
if (content) {
let parser = new DOMParser();
let doc = parser.parseFromString('
' + json_text + '
', 'text/html');
let content_new = doc.querySelector('div');
content.innerHTML = '';
content.appendChild(content_new);
}
} else
header_nofix(content);
});
}
});
}
}
let par_initial = document.querySelector('p.initial');
removeDOMElement(par_initial);
}
else if (matchDomain('welt.de')) {
func_post = function () {
if (mobile) {
let headers = document.querySelectorAll('main header, main header ~ div');
for (let elem of headers)
elem.removeAttribute('style');
let main_divs = document.querySelectorAll('main div[style] > div > div[id]');
for (let elem of main_divs) {
if (elem.querySelector('img'))
elem.parentNode.parentNode.removeAttribute('style');
}
let lazy_images = document.querySelectorAll('main img[loading="lazy"][style]');
for (let elem of lazy_images)
elem.style = 'width: 95%;';
}
header_nofix('main header', 'img[alt^="WELTplus"][loading]', 'BPC > no archive-fix');
let ads = pageContains('span', 'Anzeige');
removeDOMElement(...ads);
}
let url = window.location.href;
getArchive(url, 'div.contains_walled_content, div.c-article-paywall', '', 'main header + div');
let ads = 'div[data-component="Outbrain"], div[class*="c-ad"]';
hideDOMStyle(ads);
}
else if (matchDomain('weser-kurier.de')) {
let ads = 'div.ad-wrapper, div.anyad, div.msn-ads';
hideDOMStyle(ads);
}
else if (matchDomain('wiwo.de')) {
window.setTimeout(function () {
let paywall = document.querySelector('app-paywall');
if (paywall) {
removeDOMElement(paywall);
let article = document.querySelector('app-blind-text');
if (article) {
let url = window.location.href;
article.before(googleSearchToolLink(url));
let json_script = getArticleJsonScript();
if (json_script) {
let json = JSON.parse(json_script.text);
if (json) {
let json_text = json.find(x => x.articleBody).articleBody;
let article_new = document.createElement('div');
article_new.innerText = json_text.replace(/[\r\n]/g, '\r\n\r\n');
article_new.style = 'margin: 20px;';
article.parentNode.replaceChild(article_new, article);
}
}
}
}
}, 2000);
let ads = 'div.iqadtile';
hideDOMStyle(ads);
}
else if (matchDomain('zeit.de')) {
let header_sel = 'article > header';
let header = document.querySelector(header_sel);
func_post = function () {
if (header) {
let header_new = document.querySelector(header_sel);
if (header_new)
header_new.parentNode.replaceChild(header, header_new);
}
let comments_link = document.querySelector('div[style*="align-items"] a[href$="#comments"]');
if (comments_link)
comments_link.href = '#comments';
document.querySelectorAll('div[style*="padding-bottom:"]:has(figure), div[style*="grid-template-columns:"]:has(figure)').forEach(e => e.removeAttribute('style'));
let gst_link = false;
let figures = document.querySelectorAll('figure:has(img[loading="lazy"][style])');
for (let figure of figures) {
let lazy_image = figure.querySelector('img');
if (lazy_image.src.startsWith('data:image/')) {
let json_script = figure.querySelector('script[type="application/ld+json"]:not(:empty)');
if (json_script && json_script.text.match(/"url":\s?"/)) {
let img_url = json_script.text.split(/"url":\s?"/)[1].split('",')[0];
if (!img_url.includes('.zeit.de/newsletter/')) {
lazy_image.src = img_url;
lazy_image.style = 'width: 95%;';
figure.removeAttribute('style');
}
} else if (!gst_link && !figure.querySelector('figcaption[style*="display:none;"]')) {
gst_link = true;
header.append(googleSearchToolLink(url));
header_nofix('div#bpc_archive', '', 'BPC > no images (see GST-link)');
}
} else
lazy_image.style = 'width: 95%;';
}
let videos = document.querySelectorAll('div > div[allowfullscreen][old-src]');
for (let elem of videos) {
let iframe = document.createElement('iframe');
iframe.src = elem.getAttribute('old-src');
iframe.style = 'width: 100%; height: 400px;';
elem.parentNode.replaceChild(iframe, elem);
}
let charts = document.querySelectorAll('div > div[id^="datawrapper-chart-"][old-src]');
for (let elem of charts) {
let iframe = document.createElement('iframe');
iframe.src = elem.getAttribute('old-src');
iframe.style = 'width: 100%; height: 400px; border: none;';
elem.parentNode.replaceChild(iframe, elem);
}
if (mobile) {
let span_empty = document.querySelectorAll('span:empty');
removeDOMElement(...span_empty);
}
let ads = 'div[style*=";min-height:"]:has( > div[id^="iqadtile"])';
hideDOMStyle(ads, 2);
}
let url = window.location.href.split(/[#\?]/)[0];
if (document.querySelector('head > link[rel="next"]'))
url += '/komplettansicht';
getArchive(url, 'aside#paywall', '', 'main', '', 'main', 'article > div');
let ads = 'div[id^="iqadtile"], .iqdcontainer';
hideDOMStyle(ads);
}
else if (matchDomain(de_funke_medien_domains)) {
let paywall = document.querySelector('div#paywall-container');
if (paywall) {
removeDOMElement(paywall);
let spark_script = document.querySelector('script#__SPARK__');
if (spark_script) {
let match = spark_script.text.match(/PUBLICATION:\s?'([\w-]+)',/);
if (match) {
func_post = function () {
document.querySelectorAll('div[data-carousel-id-slider]').forEach(x => x.removeAttribute('class'));
let embed_templates = document.querySelectorAll('div[data-embed-id] > template[data-embedbox-id-embed-template]');
for (let elem of embed_templates) {
let parser = new DOMParser();
let doc = parser.parseFromString('
' + elem.innerHTML + '
', 'text/html');
let blockquote = doc.querySelector('div');
elem.parentNode.before(blockquote);
removeDOMElement(elem.parentNode);
}
let charts = document.querySelectorAll('aside > div[id^="datawrapper-vis-"]');
for (let elem of charts) {
let img = elem.querySelector('noscript > img[src]');
if (img) {
elem.parentNode.before(img);
removeDOMElement(elem.parentNode);
}
}
}
let spark_domain = match[1];
let url_src = 'https://app-webview.sparknews.funkemedien.de/' + spark_domain + window.location.pathname;
fetch_headers = {"Authorization": "Basic YXBpOkNTeGxxRG1YM2xCTmRsS1l6allRcWZqTnFZMkhQVUVm"};
replaceDomElementExt(url_src, true, false, 'div.article-body', 'BPC > no fix (source file)');
}
}
}
let ads = 'aside.ad-slot-wrapper';
hideDOMStyle(ads);
}
else if (matchDomain(de_lv_domains)) {
let paywall = document.querySelector('div[id^="paymentprocess-"]');
if (paywall) {
let intro = document.querySelector('div.m-paywall__textFadeOut');
removeDOMElement(paywall, intro);
let div_hidden = document.querySelector('div.paywall-full-content[style]');
if (div_hidden) {
div_hidden.removeAttribute('class');
div_hidden.removeAttribute('style');
}
}
let ads = 'div.adZone';
hideDOMStyle(ads);
}
else if (matchDomain(de_motor_presse_domains)) {
let ads = 'div#ads-container, div.va-sponsored, div.mps_markAd';
hideDOMStyle(ads);
}
else if (matchDomain(de_rp_medien_domains)) {
func_post = function () {
header_nofix('article', 'div#park-paywall', 'BPC > no archive-fix');
let videos = 'glomex-player';
hideDOMStyle(videos, 5);
}
let url = window.location.href;
getArchive(url, 'div.park-paywall-content', '', 'article');
let ads = 'div.portal-slot';
hideDOMStyle(ads);
}
else if (matchDomain(de_madsack_domains) || document.querySelector('head > link[href*=".rndtech.de/"]')) {
if (!window.location.search.includes('outputType=valid_amp')) {
let ads = 'div[class^="Adstyled__AdWrapper"]';
hideDOMStyle(ads);
} else {
ampToHtml();
}
}
else if (matchDomain(de_smn_domains) || matchDomain(de_smn_custom_domains)) {
if (matchDomain(de_smn_domains)) {
let restricted = document.querySelector('div.restricted-area');
if (restricted)
restricted.classList.remove('restricted-area');
} else {
func_post = function () {
if (mobile) {
document.querySelectorAll('figure > img[loading="lazy"][style]').forEach(e => e.style = 'width: 95%;');
}
}
let url = window.location.href;
getArchive(url, 'div.mod-paywall, div.upscore-paywall-placeholder', '', 'article, div#article-container');
}
let ads = 'div.mod-paywall, div.Billboard, div[id*="board"], div.ad, div[id^="traffective-ad-"], div.glomex';
hideDOMStyle(ads);
}
else if (matchDomain(de_ippen_media_domains) || document.querySelector('header a[href^="https://www.ippen.media"]')) {
let ads = 'div[class^="id-TBeepSlot-"], div[data-id-advertdfpconf]';
hideDOMStyle(ads);
}
else if (matchDomain(de_vrm_domains) || matchDomain(de_vrm_custom_domains)) {
func_post = function () {
let article = document.querySelector(article_sel);
if (article) {
article.querySelectorAll('div > div[role="button"]').forEach(e => removeDOMElement(e.parentNode));
if (mobile) {
let pictures = document.querySelectorAll('picture > img[style]');
for (let elem of pictures) {
elem.style = 'width: 95%; margin: 10px;';
elem.parentNode.removeAttribute('style');
}
}
}
}
let article_sel = 'article section';
let url = window.location.href;
window.setTimeout(function () {
getArchive(url, 'div.--blurredContent', {rm_attrib: 'class'}, article_sel);
}, 1000);
let ads = 'div.adSlot, div.loadingBanner';
hideDOMStyle(ads);
}
ads_hide();
leaky_paywall_unhide();
}, 1000);
// General Functions
// import (see @require)
function breakText_headers(str) {
str = breakText(str, true);
// exceptions: names with alternating lower/uppercase (no general fix)
let str_rep_arr = ['AstraZeneca', 'BaFin', 'BerlHG', 'BfArM', 'BilMoG', 'BioNTech', 'ChatGPT', 'DiGA', 'EuGH', 'FinTechRat', 'GlaxoSmithKline', 'IfSG', 'medRxiv', 'mmHg', 'OpenAI', 'PlosOne', 'StVO', 'TikTok'];
let str_rep_split;
let str_rep_src;
for (let str_rep of str_rep_arr) {
str_rep_split = str_rep.split(/([a-z]+)(?=[A-Z](?=[A-Za-z]+))/);
str_rep_src = str_rep_split.reduce(function (accumulator, currentValue) {
return accumulator + currentValue + ((currentValue !== currentValue.toUpperCase()) ? '\n\n' : '');
});
if (str_rep_src.endsWith('\n\n'))
str_rep_src = str_rep_src.slice(0, -2);
str = str.replace(new RegExp(str_rep_src, "g"), str_rep);
}
str = str.replace(/De\n\n([A-Z])/g, "De$1");
str = str.replace(/La\n\n([A-Z])/g, "La$1");
str = str.replace(/Le\n\n([A-Z])/g, "Le$1");
str = str.replace(/Mc\n\n([A-Z])/g, "Mc$1");
return str;
}
})();