Paywall Unblocker v2 updated

unblocks Madsack Paywall

  1. // ==UserScript==
  2. // @name Paywall Unblocker v2 updated
  3. // @name:de Paywall Unblocker v2 updated
  4. // @license MIT
  5. // @namespace http://tampermonkey.net/
  6. // @version 0.65
  7. // @match https://www.allgemeine-zeitung.de/*
  8. // @match https://www.dieharke.de/*
  9. // @match https://www.dnn.de/*
  10. // @match https://www.echo-online.de/*
  11. // @match https://www.goettinger-tageblatt.de/*
  12. // @match https://www.haz.de/*
  13. // @match https://www.hochheimer-zeitung.de/*
  14. // @match https://www.kn-online.de/*
  15. // @match https://www.ksta.de/*
  16. // @match https://www.ln-online.de/*
  17. // @match https://www.lvz.de/*
  18. // @match https://www.maz-online.de/*
  19. // @match https://www.ndz.de/*
  20. // @match https://www.neuepresse.de/*
  21. // @match https://www.nw.de/*
  22. // @match https://www.oberhessische-zeitung.de/*
  23. // @match https://www.op-marburg.de/*
  24. // @match https://www.ostsee-zeitung.de/*
  25. // @match https://www.paz-online.de/*
  26. // @match https://www.rnd.de/*
  27. // @match https://www.rundschau-online.de/*
  28. // @match https://www.saechsische.de/*
  29. // @match https://www.siegener-zeitung.de/*
  30. // @match https://www.sn-online.de/*
  31. // @match https://www.tah.de/*
  32. // @match https://www.waz-online.de/*
  33. // @match https://www.wiesbadener-kurier.de/*
  34. // @match https://www.wormser-zeitung.de/*
  35. // @grant GM_addStyle
  36. // @description unblocks Madsack Paywall
  37. // @description:de entfernt Madsack Paywall
  38. // @author hazuser99
  39. // @require https://code.jquery.com/jquery-3.7.1.min.js
  40. // ==/UserScript==
  41.  
  42. (function() {
  43. 'use strict';
  44. var url,site,html,parser,htmlDoc,articleText,jsonText,jsonObj,locationText;
  45. insert();
  46.  
  47. async function caesar(){
  48. var url,site,html,parser,htmlDoc,articleText,jsonText,jsonObj,locationText;
  49. switch (location.hostname) {
  50. case "www.allgemeine-zeitung.de":
  51. case "www.echo-online.de":
  52. case "www.hochheimer-zeitung.de":
  53. case "www.lauterbacher-anzeiger.de":
  54. // case "www.main-spitze.de":
  55. // case "www.mittelhessen.de":
  56. case "www.oberhessische-zeitung.de":
  57. case "www.wiesbadener-kurier.de":
  58. case "www.nw.de":
  59. case "www.wormser-zeitung.de":
  60. {
  61. GM.addStyle(".loadingBanner,.adSlot {display:none!important;}");
  62. breakVrmArticles();
  63. setInterval(() => {if (url != null && location.href != url){GM.addStyle("div.contentWrapper.app__content.--page {display:none!important;}"); url = location.href; location.reload();}},0);
  64. break;
  65. }
  66. case "www.cz.de":
  67. {
  68. if (document.querySelector("#erasmo")){
  69. GM.addStyle(".content-subscription-box,.newsletter-signup-wrapper {display:none;}");
  70. document.querySelector("article").classList.remove("news-read-not-allowed");
  71. site = await fetch(location.href);
  72. html = await site.text();
  73. parser = new DOMParser();
  74. htmlDoc = parser.parseFromString(html, "text/html");
  75. articleText = htmlDoc.querySelector(".field__items").innerHTML;
  76. document.querySelector(".field__items").innerHTML = articleText;
  77. }
  78. break;
  79. }
  80. case "www.dieharke.de":
  81. case "www.dnn.de":
  82. case "www.goettinger-tageblatt.de":
  83. case "www.haz.de":
  84. case "www.kn-online.de":
  85. case "www.ln-online.de":
  86. case "www.lvz.de":
  87. case "www.maz-online.de":
  88. case "www.saechsische.de":
  89. case "www.neuepresse.de":
  90. case "www.ndz.de":
  91. case "www.op-marburg.de":
  92. case "www.ostsee-zeitung.de":
  93. case "www.paz-online.de":
  94. case "www.rnd.de":
  95. case "www.siegener-zeitung.de":
  96. case "www.tah.de":
  97. case "www.sn-online.de":
  98. case "www.waz-online.de":
  99. {
  100. if(location.href.endsWith("?outputType=valid_amp")) {
  101. location.href = location.href.replace("?outputType=valid_amp","");
  102. }
  103. var paywall = document.querySelector('div.paywalledContent');
  104. if (paywall){
  105. console.log("paywall");
  106. GM.addStyle('[class^="ReadProgressstyled"],[class^="ArticleContentLoaderstyled__Gradient-"],[id^="piano-home-inline-haz"],[id^="piano-lightbox-article-"],article > svg {display:none;}');
  107. GM.addStyle('[class^="Adstyled__AdWrapper-sc"],[class^="Adstyled__AdWrapper-sc-"],article > svg {display:none;}');
  108. GM.addStyle('[class^="HeaderWithNavBarstyled"] {position:relative !important;}');
  109. GM.addStyle(".h2-pw {font-family: 'DIN Next LT Pro', Arial, Roboto, sans-serif; font-weight:700; letter-spacing:-0.25px; font-size:22px; padding-bottom:4px;}");
  110. $("div[class='OUTBRAIN'").remove();
  111. $("div[id^='mad_m_incontent-'").remove();
  112. paywall.classList.remove(paywall.classList.item(1));
  113. var articleParagraph = paywall.querySelector("div > p");
  114. jsonText = document.querySelector("#fusion-metadata").innerHTML.split(/;Fusion\.globalContent.*?=/)[1];
  115. jsonObj = JSON.parse(jsonText);
  116. var elements = jsonObj.elements.filter(i => i.type != "ad");
  117. var readAlsoIndex = elements.findIndex(i => i.text?.includes("Lesen Sie auch"));
  118. if (readAlsoIndex != -1)
  119. elements.splice(readAlsoIndex, 2);
  120. var appAdIndex = elements.findIndex(i => i.text?.match(/Laden Sie sich jetzt hier kostenfrei unsere .*-App.* herunter:/));
  121. if (appAdIndex != -1)
  122. elements.splice(appAdIndex, 3);
  123. appAdIndex = elements.findIndex(i => i.text?.match(/Laden Sie sich jetzt hier kostenfrei unsere .*-App.* herunter[^:]/));
  124. if (appAdIndex != -1)
  125. elements.splice(appAdIndex, 3);
  126. articleText = [{text: articleParagraph.innerHTML},...elements.slice(1)]
  127. .map(i => (i.type=="header"?`<h2 class="h2-pw ${articleParagraph.className}">`:`<p class="${articleParagraph.className}">`)
  128. + (i.text??"") + (i.type == "header"?"</h2>":"</p>")
  129. + (i.type == "image"?`<div><img alt="${i.imageInfo?.alt}" src="${i.imageInfo?.src}" width="100%"><div class=""><p class="ClTDP">${i.imageInfo?.caption}</p><p class="bIdZuO">${i.imageInfo?.credit}</p></div></div>`:"")
  130. + (i.type == "list"?"<ul>" + i.list?.items?.map(l => "<li>• " + l.text + "</li>").join("") + "</ul>":"")).join("");
  131. articleParagraph.parentElement.innerHTML = articleText;
  132.  
  133. //Css Fixing
  134. paywall.querySelectorAll('*').forEach($el => {
  135. $el.style.height = "auto";
  136. // $el.className='';
  137. // $el.style.fontSize = "17px";
  138. // $el.style.lineHeight = "26px";
  139. // $el.style.fontFamily = "Source Serif Pro, Palatino, Droid Serif, serif";
  140. });
  141. paywall.querySelectorAll('li').forEach($el => {
  142. $el.style.fontSize = "17px";
  143. $el.style.marginBottom = "0.5em";
  144. $el.style.fontFamily = "Calibri";
  145. });
  146. paywall.querySelectorAll('li>a').forEach($el => {
  147. $el.style.color = "green";
  148. $el.style.fontDecoration = "underline";
  149. });
  150. }
  151. break;
  152. }
  153. case "www.ksta.de":
  154. case "www.rundschau-online.de":
  155. {
  156. GM.addStyle(".tm-visible,.dm-slot {display:none!important;}");
  157. document.querySelector(".dm-mural.dm-paint").classList.remove("dm-mural","dm-paint");
  158. break;
  159. }
  160. }
  161. async function breakVrmArticles(){
  162. url = location.href
  163. GM.addStyle(".div.contentWrapper.app__content.--page {display:initial!important;}");
  164. if (document.querySelector(".articleHeader__top .badges")){
  165. GM.addStyle(".quoteWrapper {display:none;}");
  166. document.querySelector(".storyElementWrapper__paywall > div").style.display = "none";
  167. document.querySelector(".storyElementWrapper__paywallContainer").classList.remove("storyElementWrapper__paywallContainer");
  168. document.querySelector(".storyElementWrapper__paywall").classList.replace("storyElementWrapper__paywall","storyElementWrapper");
  169. document.querySelector(".storyElementWrapper__paywallWrapper").classList.replace("storyElementWrapper__paywallWrapper","storyElementWrapper");
  170. document.querySelector(".storyElementWrapper__paywallStoryline").classList.replace("storyElementWrapper__paywallStoryline","storyElementWrapper__Storyline");
  171. site = await fetch(location.href);
  172. html = await site.text();
  173. parser = new DOMParser();
  174. htmlDoc = parser.parseFromString(html, "text/html");
  175. jsonText = htmlDoc.querySelector("div~script").innerText.replace(/^window\.__INITIAL_STATE__=/,"").replace(/;\(function\(\).*/,"");
  176. console.log(jsonText);
  177. jsonObj = JSON.parse(jsonText);
  178. articleText = jsonObj.contentPage.data.context.storylineText;
  179.  
  180. var texts = articleText.split(/<\/p>/).map(i => i.slice(3));
  181. [...document.querySelectorAll(".storyElementWrapper__container > div > p:not(.multimediaIntro)")].forEach(i => {i.parentElement.parentElement.innerHTML = i.parentElement.parentElement.innerHTML.replace(/(storyElementWrapper__element)/g,"contentWrapper $1 --medium")});
  182. [...document.querySelectorAll(".toggleBox__content.--padding.--border")].forEach(i => {i.closest(".storyElementWrapper__container").innerHTML = i.closest(".storyElementWrapper__container").innerHTML.replace(/(style=")(background: ?linear-gradient)/g,"$1display:none;$2").replace(/(storyElementWrapper__element)/g,"contentWrapper $1 --small").replace(/(class="toggleBox__contentWrapper --medium")/g,"style=\"height:auto!important\" $1").replace(/(class="toggleBox__headline paragraph --blockIntro")/g,"style=\"display:none\" $1")});
  183.  
  184. var paragraphs = [...document.querySelectorAll(".storyElementWrapper__container > div > p:not(.multimediaIntro) > span"),...document.querySelectorAll(".toggleBox__content.--padding.--border .infoBox__storylineElement p.--small > span")];
  185. paragraphs.forEach((p,i) => {
  186. var cursor = 0;
  187. var source = p.innerHTML;
  188. if (i == 0 && source.indexOf(".") > 0 && source.indexOf(".") < 20){
  189. [locationText, source] = source.split(/\. (.*)/s).filter(i => i);
  190. }
  191. var splittedSource = source.split(/(<.*?>)/);
  192. var replaceText = texts[i];
  193. var replaceTexts = [];
  194. for (let splittedText of splittedSource){
  195. if (splittedText.length != 0 && splittedText.slice(0,1) != "<"){
  196. splittedText = replaceText.slice(cursor,cursor + splittedText.length);
  197. cursor += splittedText.length;
  198. }
  199. replaceTexts.push(splittedText);
  200. }
  201. replaceText = replaceTexts.join("");
  202. if (locationText != null && location.href.split("/")[3] == "lokales"){
  203. var locationLinkText = document.querySelector(".storyPage__sectionLink").innerText;
  204. if (locationText.length == locationLinkText.length){
  205. replaceText = `${locationLinkText}. ${replaceText}`;
  206. }
  207. }
  208. p.innerHTML = replaceText;
  209. });
  210. }
  211. };
  212. }
  213. async function run() {
  214. caesar();
  215. }
  216. async function removeADS() {
  217. console.log("removeADS");
  218. $("div[class^='Articlestyled__CenteredContentWrapper-sc'] svg").each(function() {
  219. $(this).remove();
  220. });
  221. $("div[class^='Articlestyled__ArticleBodyWrapper-sc'] svg").each(function() {
  222. // $(this).each(function() {
  223. $(this).remove();
  224. });
  225. // $("div[class^='Adstyled__AdWrapper-sc']").remove();
  226. }
  227.  
  228. function loopFunction(delay, f,callback){
  229. var loop = function(){
  230. f;
  231. callback();
  232. setTimeout(loop, delay);
  233. }; loop();
  234. };
  235.  
  236. function insert(){
  237. loopFunction(100, run(),function(){
  238. run();
  239. });
  240. loopFunction(100, run(),function(){
  241. removeADS();
  242. });
  243. }
  244. })();