/ contentScript.js
contentScript.js
1 //"use strict"; 2 var ext_api = (typeof browser === 'object') ? browser : chrome; 3 var mobile = window.navigator.userAgent.toLowerCase().includes('mobile'); 4 var domain; 5 var csDone; 6 var csDoneOnce; 7 var dompurify_loaded = (typeof DOMPurify === 'function'); 8 9 var ar_grupo_clarin_domains = ['clarin.com', 'lavoz.com.ar', 'losandes.com.ar']; 10 var be_groupe_ipm_domains = ['dhnet.be', 'lalibre.be', 'lavenir.net']; 11 var be_roularta_domains = ['artsenkrant.com', 'femmesdaujourdhui.be', 'flair.be', 'knack.be', 'kw.be', 'levif.be', 'libelle.be']; 12 var ca_gcm_domains = ['lesoleil.com'].concat(['latribune.ca', 'lavoixdelest.ca', 'ledroit.com', 'ledroitfranco.com', 'lenouvelliste.ca', 'lequotidien.com']); 13 var ca_torstar_domains = ['niagarafallsreview.ca', 'stcatharinesstandard.ca', 'thepeterboroughexaminer.com', 'therecord.com', 'thespec.com', 'thestar.com', 'wellandtribune.ca']; 14 var de_funke_medien_domains = ['abendblatt.de', 'braunschweiger-zeitung.de', 'morgenpost.de', 'nrz.de', 'otz.de', 'thueringer-allgemeine.de', 'tlz.de', 'waz.de', 'wp.de', 'wr.de']; 15 var de_lv_domains = ['profi.de', 'topagrar.at', 'topagrar.com', 'wochenblatt.com']; 16 var de_madsack_domains = ['haz.de', 'kn-online.de', 'ln-online.de', 'lvz.de', 'maz-online.de', 'neuepresse.de', 'ostsee-zeitung.de', 'rnd.de']; 17 var de_mhs_custom_domains = ['cannstatter-zeitung.de', 'esslinger-zeitung.de', 'frankenpost.de', 'insuedthueringen.de', 'krzbb.de', 'kurier.de', 'np-coburg.de', 'verlagshaus-jaumann.de']; 18 var de_vrm_domains = ['allgemeine-zeitung.de', 'echo-online.de', 'wiesbadener-kurier.de']; 19 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']; 20 var de_westfalen_medien_domains = ['muensterschezeitung.de', 'westfalen-blatt.de', 'wn.de']; 21 var es_epiberica_domains = ['diariodemallorca.es', 'eldia.es', 'epe.es', 'farodevigo.es', 'informacion.es', 'laprovincia.es', 'levante-emv.com', 'lne.es', 'mallorcazeitung.es']; 22 var es_epiberica_custom_domains = ['diaridegirona.cat', 'diariocordoba.com', 'diariodeibiza.es', 'elperiodicodearagon.com', 'elperiodicoextremadura.com', 'elperiodicomediterraneo.com', 'emporda.info', 'laopinioncoruna.es', 'laopiniondemalaga.es', 'laopiniondemurcia.es', 'laopiniondezamora.es', 'regio7.cat']; 23 var es_grupo_vocento_domains = ['abc.es', 'diariosur.es', 'diariovasco.com', 'elcomercio.es', 'elcorreo.com', 'eldiariomontanes.es', 'elnortedecastilla.es', 'hoy.es', 'ideal.es', 'larioja.com', 'lasprovincias.es', 'laverdad.es', 'lavozdigital.es']; 24 var es_unidad_domains = ['elmundo.es', 'expansion.com', 'marca.com']; 25 var fr_be_groupe_rossel = ['aisnenouvelle.fr', 'courrier-picard.fr', 'lardennais.fr', 'lavoixdunord.fr', 'lesoir.be', 'lest-eclair.fr', 'liberation-champagne.fr', 'lunion.fr', 'nordlittoral.fr', 'paris-normandie.fr', 'sudinfo.be']; 26 var fr_groupe_ebra_domains = ['bienpublic.com', 'dna.fr', 'estrepublicain.fr', 'lalsace.fr', 'ledauphine.com', 'lejsl.com', 'leprogres.fr', 'republicain-lorrain.fr', 'vosgesmatin.fr']; 27 var fr_groupe_la_depeche_domains = ['centrepresseaveyron.fr', 'ladepeche.fr', 'lindependant.fr', 'midilibre.fr', 'nrpyrenees.fr', 'petitbleu.fr', 'rugbyrama.fr']; 28 var fr_groupe_nice_matin_domains = ['monacomatin.mc', 'nicematin.com', 'varmatin.com']; 29 var it_ilmessaggero_domains = ['corriereadriatico.it', 'ilgazzettino.it', 'ilmattino.it', 'ilmessaggero.it', 'quotidianodipuglia.it']; 30 var it_gedi_domains = ['italian.tech', 'lescienze.it', 'repubblica.it']; 31 var it_quotidiano_domains = ['ilgiorno.it', 'ilrestodelcarlino.it', 'iltelegrafolivorno.it', 'lanazione.it', 'quotidiano.net']; 32 var medium_custom_domains = ['betterprogramming.pub', 'towardsdatascience.com']; 33 var nl_mediahuis_region_domains = ['gooieneemlander.nl', 'haarlemsdagblad.nl', 'ijmuidercourant.nl', 'leidschdagblad.nl', 'noordhollandsdagblad.nl']; 34 var nl_dpg_adr_domains = ['ad.nl', 'bd.nl', 'bndestem.nl', 'destentor.nl', 'ed.nl', 'gelderlander.nl', 'pzc.nl', 'tubantia.nl']; 35 var nl_dpg_media_domains = ['demorgen.be', 'flair.nl', 'humo.be', 'libelle.nl', 'margriet.nl', 'parool.nl', 'trouw.nl', 'volkskrant.nl']; 36 var no_nhst_media_domains = ['europower-energi.no', 'fiskeribladet.no', 'intrafish.com', 'intrafish.no', 'rechargenews.com', 'tradewindsnews.com', 'upstreamonline.com']; 37 var pe_grupo_elcomercio_domains = ['diariocorreo.pe', 'elcomercio.pe', 'gestion.pe']; 38 var timesofindia_domains = ['timesofindia.com', 'timesofindia.indiatimes.com']; 39 var uk_nat_world_domains = ['scotsman.com', 'yorkshirepost.co.uk']; 40 var usa_adv_local_domains = ['al.com', 'cleveland.com', 'lehighvalleylive.com', 'masslive.com', 'mlive.com', 'nj.com', 'oregonlive.com', 'pennlive.com', 'silive.com', 'syracuse.com']; 41 var usa_arizent_custom_domains = ['accountingtoday.com', 'benefitnews.com', 'bondbuyer.com', 'dig-in.com', 'financial-planning.com', 'nationalmortgagenews.com']; 42 var usa_conde_nast_domains = ['architecturaldigest.com', 'bonappetit.com', 'epicurious.com', 'gq.com' , 'newyorker.com', 'vanityfair.com', 'vogue.com', 'wired.com']; 43 var usa_craincomm_domains = ['adage.com', 'autonews.com', 'chicagobusiness.com', 'crainscleveland.com', 'crainsdetroit.com', 'crainsnewyork.com', 'modernhealthcare.com']; 44 var usa_gannett_domains = ['azcentral.com', 'cincinnati.com', 'commercialappeal.com', 'courier-journal.com', 'democratandchronicle.com', 'detroitnews.com', 'freep.com', 'indystar.com', 'jsonline.com', 'knoxnews.com', 'news-press.com', 'northjersey.com', 'oklahoman.com', 'statesman.com', 'tennessean.com']; 45 var usa_genomeweb_domains = ['360dx.com', 'genomeweb.com', 'precisiononcologynews.com']; 46 var usa_hearst_comm_domains = ['expressnews.com', 'houstonchronicle.com', 'sfchronicle.com']; 47 var usa_lee_ent_domains = ['buffalonews.com', 'journalnow.com', 'omaha.com', 'richmond.com', 'tucson.com', 'tulsaworld.com']; 48 var usa_mcc_domains = ['bnd.com', 'charlotteobserver.com', 'fresnobee.com', 'kansas.com', 'kansascity.com', 'kentucky.com', 'mcclatchydc.com', 'miamiherald.com', 'newsobserver.com', 'sacbee.com', 'star-telegram.com', 'thestate.com', 'tri-cityherald.com']; 49 var usa_mng_domains = ['denverpost.com', 'eastbaytimes.com', 'mercurynews.com', 'ocregister.com', 'pe.com', 'twincities.com']; 50 var usa_outside_mag_domains = ["backpacker.com", "betamtb.com", "betternutrition.com", "cleaneatingmag.com", "climbing.com", "cyclingtips.com", "gymclimber.com", "outsideonline.com", "oxygenmag.com", "pelotonmagazine.com", "podiumrunner.com", "rockandice.com", "skimag.com", "trailrunnermag.com", "triathlete.com", "vegetariantimes.com", "velonews.com", "womensrunning.com", "yogajournal.com"]; 51 var usa_tribune_domains = ['baltimoresun.com', 'chicagotribune.com', 'courant.com', 'dailypress.com', 'mcall.com', 'nydailynews.com', 'orlandosentinel.com', 'pilotonline.com', 'sun-sentinel.com']; 52 53 // clean local storage of sites (with an exemption for hold-list) 54 var arr_localstorage_hold = ['augsburger-allgemeine.de', 'barrons.com', 'business-standard.com', 'businessinsider.com', 'businessoffashion.com', 'businesspost.ie', 'challenges.fr', 'charliehebdo.fr', 'cmjornal.pt', 'corriere.it', 'corrieredellosport.it', 'cyclingtips.com', 'dvhn.nl', 'economictimes.com', 'eldiario.es', 'elespanol.com', 'elle.fr', 'elpais.com', 'elperiodico.com', 'enotes.com', 'estadao.com.br', 'forbes.com', 'fortune.com', 'freiepresse.de', 'gauchazh.clicrbs.com.br', 'globo.com', 'ilfoglio.it', 'inc42.com', 'indianexpress.com', 'ksta.de', 'kurier.at', 'lanouvellerepublique.fr', 'latimes.com', 'lc.nl', 'lesechos.fr', 'livemint.com', 'mid-day.com', 'mundodeportivo.com', 'nationalreview.com', 'nrc.nl', 'nw.de', 'nwzonline.de', 'nytimes.com', 'nzherald.co.nz', 'record.pt', 'ruhrnachrichten.de', 'rundschau-online.de', 'sandiegouniontribune.com', 'scmp.com', 'seekingalpha.com', 'telegraph.co.uk', 'tes.com', 'theatlantic.com', 'thebulletin.org', 'thecritic.co.uk', 'thetimes.co.uk', 'uol.com.br', 'wsj.com'].concat(be_roularta_domains, ca_gcm_domains, de_funke_medien_domains, de_lv_domains, de_vrm_domains, de_vrm_custom_domains, de_westfalen_medien_domains, es_epiberica_domains, es_epiberica_custom_domains, es_grupo_vocento_domains, es_unidad_domains, fr_groupe_ebra_domains, fr_groupe_la_depeche_domains, fr_groupe_nice_matin_domains, it_gedi_domains, it_quotidiano_domains, ca_gcm_domains, nl_dpg_media_domains, no_nhst_media_domains, timesofindia_domains, usa_hearst_comm_domains, usa_mcc_domains); 55 if (!matchDomain(arr_localstorage_hold)) { 56 window.localStorage.clear(); 57 } 58 59 function runOnMessage(bg2csData, dompurify_loaded) { 60 // custom/updated sites: load text from json 61 if (bg2csData.ld_json && dompurify_loaded) { 62 if (bg2csData.ld_json.includes('|')) { 63 window.setTimeout(function () { 64 let ld_json_split = bg2csData.ld_json.split('|'); 65 let paywall_sel = ld_json_split[0]; 66 let article_sel = ld_json_split[1]; 67 let paywall = document.querySelectorAll(paywall_sel); 68 let article = document.querySelector(article_sel); 69 let article_append = ld_json_split[2];// optional 70 if (paywall.length && article) { 71 removeDOMElement(...paywall); 72 let json_script = getArticleJsonScript(); 73 if (json_script) { 74 try { 75 let json = JSON.parse(json_script.text.replace(/[\r\n]/g, '').replace(/(\\r)?\\n/g, '<br>')); 76 let json_key, json_text; 77 if (Array.isArray(json)) { 78 json = json.filter(x => json_key = Object.keys(x).find(key => key.match(/^articlebody$/i))) || json.filter(x => json_key = Object.keys(x).find(key => key.match(/^text$/i))); 79 if (json_key) 80 json_text = parseHtmlEntities(json[0][json_key]); 81 } else { 82 json_key = Object.keys(json).find(key => key.match(/^articlebody$/i)) || Object.keys(json).find(key => key.match(/^text$/i)); 83 json_text = parseHtmlEntities(json[json_key]); 84 } 85 if (json_text && article.parentNode) { 86 let parser = new DOMParser(); 87 let doc = parser.parseFromString('<div style="margin: 25px 0px">' + DOMPurify.sanitize(json_text) + '</div>', 'text/html'); 88 let article_new = doc.querySelector('div'); 89 if (article_append || !article.parentNode) { 90 article.innerHTML = ''; 91 article.appendChild(article_new); 92 } else 93 article.parentNode.replaceChild(article_new, article); 94 } 95 } catch (err) { 96 console.log(err); 97 } 98 } 99 } 100 }, 1000); 101 } 102 } 103 104 if (bg2csData.ld_json_next && dompurify_loaded) { 105 if (bg2csData.ld_json_next.includes('|')) { 106 window.setTimeout(function () { 107 let ld_json_next_split = bg2csData.ld_json_next.split('|'); 108 let paywall_sel = ld_json_next_split[0]; 109 let article_sel = ld_json_next_split[1]; 110 let paywall = document.querySelectorAll(paywall_sel); 111 let article = document.querySelector(article_sel); 112 let article_append = ld_json_next_split[2];// optional 113 if (paywall.length && article) { 114 removeDOMElement(...paywall); 115 let json_script = document.querySelector('script#__NEXT_DATA__'); 116 let json = JSON.parse(json_script.text); 117 if (json) { 118 let url_next = findKeyJson(json, ['slug']); 119 if (url_next && !window.location.pathname.endsWith(url_next)) 120 refreshCurrentTab(); 121 let json_text = parseHtmlEntities(findKeyJson(json, ['body', 'content', 'description'], 500)); 122 if (json_text && article.parentNode) { 123 let parser = new DOMParser(); 124 let doc = parser.parseFromString('<div>' + DOMPurify.sanitize(json_text) + '</div>', 'text/html'); 125 let article_new = doc.querySelector('div'); 126 if (article_append || !article.parentNode) { 127 article.innerHTML = ''; 128 article.appendChild(article_new); 129 } else 130 article.parentNode.replaceChild(article_new, article); 131 } 132 } 133 } 134 }, 1000); 135 } 136 } 137 138 // custom/updated sites: load text from Google webcache 139 if (bg2csData.ld_google_webcache && dompurify_loaded) { 140 if (bg2csData.ld_google_webcache.includes('|')) { 141 window.setTimeout(function () { 142 let url = window.location.href; 143 let ld_google_webcache_split = bg2csData.ld_google_webcache.split('|'); 144 let paywall_sel = ld_google_webcache_split[0]; 145 let article_sel = ld_google_webcache_split[1]; 146 let paywall = document.querySelectorAll(paywall_sel); 147 if (paywall.length) { 148 removeDOMElement(...paywall); 149 let url_cache = 'https://webcache.googleusercontent.com/search?q=cache:' + url.split('?')[0]; 150 replaceDomElementExt(url_cache, true, false, article_sel); 151 } 152 }, 1000); 153 } 154 } 155 156 // custom/updated sites: add link to article 157 if (bg2csData.add_ext_link) { 158 if (bg2csData.add_ext_link.css && bg2csData.add_ext_link.css.includes('|') && bg2csData.add_ext_link.type) { 159 window.setTimeout(function () { 160 let url = window.location.href.split(/[#\?]/)[0]; 161 if (matchUrlDomain('zeit.de', url)) { 162 if (document.querySelector('link[rel="next"]')) 163 url += '/komplettansicht'; 164 } 165 let add_ext_link_split = bg2csData.add_ext_link.css.split('|'); 166 let paywall_sel = add_ext_link_split[0]; 167 let article_sel = add_ext_link_split[1]; 168 let paywall = document.querySelectorAll(paywall_sel); 169 if (paywall.length) { 170 removeDOMElement(...paywall); 171 let article = document.querySelector(article_sel); 172 if (article) { 173 switch (bg2csData.add_ext_link.type) { 174 case 'archive.is': 175 article.firstChild.before(archiveLink(url)); 176 break; 177 case '12ft.io': 178 article.firstChild.before(ext_12ftLink(url)); 179 break; 180 case 'google_webcache': 181 article.firstChild.before(googleWebcacheLink(url)); 182 break; 183 } 184 } 185 } 186 }, 1000); 187 } 188 } 189 190 // check for opt-in confirmation (from background.js) 191 if (bg2csData.optin_setcookie) { 192 false; 193 } 194 195 // custom/updated sites: try to unhide text on amp-page 196 if (bg2csData.amp_unhide) { 197 window.setTimeout(function () { 198 let amp_page_hide = document.querySelector('script[src*="/amp-access-"], script[src*="/amp-subscriptions-"]'); 199 if (amp_page_hide) { 200 amp_unhide_subscr_section(); 201 amp_unhide_access_hide(); 202 amp_iframes_replace(); 203 } 204 }, 100); 205 } 206 207 // custom/updated sites: amp-redirect 208 if (bg2csData.amp_redirect) { 209 window.setTimeout(function () { 210 let amp_script = document.querySelector('script[src^="https://cdn.ampproject.org/"]'); 211 let amphtml = document.querySelector('link[rel="amphtml"]'); 212 let amp_page = amp_script && !amphtml; 213 if (!amp_page) { 214 let paywall = true; 215 if (bg2csData.amp_redirect.paywall) 216 paywall = document.querySelector(bg2csData.amp_redirect.paywall); 217 if (paywall && amphtml) { 218 removeDOMElement(paywall); 219 window.location.href = amphtml.href; 220 } 221 } 222 }, 500); 223 } 224 225 function cs_code_elems(elems) { 226 for (let elem of elems) { 227 let elem_dom = document.querySelectorAll(elem.cond); 228 for (let item of elem_dom) { 229 if (elem.rm_elem) 230 removeDOMElement(item); 231 if (elem.rm_class) { 232 let rm_class = elem.rm_class.split(',').map(x => x.trim()); 233 item.classList.remove(...rm_class); 234 } 235 if (elem.rm_attrib) { 236 let rm_attribs = elem.rm_attrib.split('|'); 237 for (let rm_attrib of rm_attribs) 238 item.removeAttribute(rm_attrib); 239 } 240 if (elem.set_attrib && elem.set_attrib.includes('|')) { 241 let attrib = elem.set_attrib.split('|')[0]; 242 let value = elem.set_attrib.split('|')[1]; 243 item.setAttribute(attrib, value); 244 } 245 if (elem.elems) 246 cs_code_elems(elem.elems); 247 } 248 } 249 } 250 251 // updated sites: cs_code 252 if (bg2csData.cs_code) { 253 window.setTimeout(function () { 254 cs_code_elems(bg2csData.cs_code); 255 }, 1000); 256 } 257 258 }// runOnMessage 259 260 var msg_once; 261 if (ext_api.runtime) { 262 ext_api.runtime.onMessage.addListener( 263 function (request, sender) { 264 if (request.msg === 'bg2cs' && !msg_once) { 265 msg_once = true; 266 runOnMessage(request.data, dompurify_loaded); 267 } 268 }) 269 } 270 271 window.addEventListener('message', function (event) { 272 if (event.data) { 273 if (event.data.type === 'from_page') { 274 if (matchDomain('businesspost.ie')) { 275 let data = event.data.data; 276 let article = document.querySelector('div.article-body-section'); 277 if (data && article && dompurify_loaded && !msg_once) { 278 msg_once = true; 279 let parser = new DOMParser(); 280 let doc = parser.parseFromString('<div>' + DOMPurify.sanitize(data) + '</div>', 'text/html'); 281 let article_new = doc.querySelector('div'); 282 if (article_new) { 283 article.innerHTML = ''; 284 article.appendChild(article_new); 285 } 286 } 287 } 288 } 289 } 290 }, false); 291 292 if (!(csDone || csDoneOnce)) { 293 294 var msg_once_ses; 295 if (ext_api.runtime) { 296 ext_api.runtime.onMessage.addListener( 297 function (request, sender) { 298 if (request.msg === 'showExtSrc' && !msg_once_ses) { 299 msg_once_ses = true; 300 replaceDomElementExtSrc(request.data.url, request.data.html, true, false, request.data.selector, request.data.text_fail, request.data.selector_source); 301 } 302 }) 303 } 304 305 // Content workarounds/domain 306 307 if (matchDomain('medium.com') || matchDomain(medium_custom_domains) || document.querySelector('script[src*=".medium.com/"]')) { 308 let url = window.location.href; 309 let paywall = document.querySelector('article.meteredContent'); 310 if (paywall) { 311 paywall.removeAttribute('class'); 312 paywall.firstChild.before(googleWebcacheLink(url)); 313 } 314 window.setTimeout(function () { 315 let banner = pageContains('div > div > p', /author made this story available to/); 316 if (banner.length) 317 removeDOMElement(banner[0].parentNode.parentNode); 318 }, 1000); 319 } 320 321 else if (window.location.hostname.match(/\.(com|net)\.au$/)) {//australia 322 323 if (matchDomain('crikey.com.au')) { 324 let paywall = document.querySelector('div.locked-content'); 325 if (paywall && dompurify_loaded) { 326 removeDOMElement(paywall); 327 let json_url_dom = document.querySelector('link[rel="alternate"][type="application/json"][href]'); 328 let json_url = json_url_dom.href; 329 fetch(json_url) 330 .then(response => { 331 if (response.ok) { 332 response.json().then(json => { 333 let json_text = json.content.rendered; 334 let content = document.querySelector('div.article-body > div.paywall'); 335 if (json_text && content) { 336 let parser = new DOMParser(); 337 let doc = parser.parseFromString('<div>' + DOMPurify.sanitize(json_text) + '</div>', 'text/html'); 338 let content_new = doc.querySelector('div'); 339 content.parentNode.replaceChild(content_new, content); 340 } 341 }); 342 } 343 }); 344 let fade = document.querySelector('article.article-locked'); 345 if (fade) 346 fade.classList.remove('article-locked'); 347 } 348 } 349 350 else if (matchDomain('macrobusiness.com.au')) { 351 let paywall = pageContains('div > p', 'The full text of this article is available'); 352 if (paywall[0] && dompurify_loaded) { 353 let fade = document.querySelector('div.bg-gradient-to-t'); 354 removeDOMElement(paywall[0].parentNode, fade); 355 let json_script = document.querySelector('script#__NUXT_DATA__'); 356 if (json_script) { 357 try { 358 let json = JSON.parse(json_script.text); 359 let json_text = json.filter(x => typeof x === 'string' && x.match(/(<|\\u003C)p>/))[0]; 360 let parser = new DOMParser(); 361 let doc = parser.parseFromString('<div>' + DOMPurify.sanitize(json_text) + '</div>', 'text/html'); 362 let content_new = doc.querySelector('div') 363 let article = document.querySelector('div.content'); 364 if (article) { 365 article.innerHTML = ''; 366 article.appendChild(content_new); 367 } 368 } catch (err) { 369 console.log(err); 370 } 371 } 372 } 373 } 374 375 else if (matchDomain('thesaturdaypaper.com.au')) { 376 let hide_end = document.querySelector('div.hide-end'); 377 if (hide_end) { 378 refreshCurrentTab(); 379 csDoneOnce = true; 380 } 381 let paywall = document.querySelector('div.paywall-hard-always-show'); 382 removeDOMElement(paywall); 383 } 384 385 else if (matchDomain(['brisbanetimes.com.au', 'smh.com.au', 'theage.com.au', 'watoday.com.au'])) { 386 if (!window.location.hostname.startsWith('amp.')) { 387 let paywall = document.querySelector('meta[content^="FOR SUBSCRIBERS"], #paywall_prompt'); 388 let amphtml = document.querySelector('link[rel="amphtml"]'); 389 if (paywall && amphtml) { 390 removeDOMElement(paywall); 391 window.location.href = amphtml.href; 392 } 393 } else { 394 amp_unhide_subscr_section(); 395 } 396 } 397 398 else { 399 // Australian Community Media newspapers 400 let au_comm_media_domains = ['bendigoadvertiser.com.au', 'bordermail.com.au', 'canberratimes.com.au', 'centralwesterndaily.com.au', 'dailyadvertiser.com.au', 'dailyliberal.com.au', 'examiner.com.au', 'illawarramercury.com.au', 'newcastleherald.com.au', 'northerndailyleader.com.au', 'standard.net.au', 'theadvocate.com.au', 'thecourier.com.au', 'westernadvocate.com.au']; 401 let au_comm_media_link = document.querySelector('a[href^="https://austcommunitymedia.my.site.com/"]'); 402 if (matchDomain(au_comm_media_domains) || au_comm_media_link) { 403 let mask = document.querySelector('div[class^="gradient-mask-"]'); 404 if (mask) { 405 mask.removeAttribute('class'); 406 let div_hidden = document.querySelectorAll('div.flex-col div.hidden'); 407 for (let elem of div_hidden) 408 elem.classList.remove('hidden'); 409 } else { 410 let subscribe_truncate = document.querySelector('.subscribe-truncate'); 411 if (subscribe_truncate) 412 subscribe_truncate.classList.remove('subscribe-truncate'); 413 let subscriber_hiders = document.querySelectorAll('.subscriber-hider'); 414 for (let subscriber_hider of subscriber_hiders) 415 subscriber_hider.classList.remove('subscriber-hider'); 416 } 417 let blocker = document.querySelector('div.blocker'); 418 let overlays = document.querySelectorAll('div.transition-all, div[id^="headlessui-dialog"]'); 419 let noscroll = document.querySelectorAll('html[style], body[style]'); 420 for (let elem of noscroll) 421 elem.removeAttribute('style'); 422 let story_generic_iframe = document.querySelector('.story-generic__iframe'); 423 let ads = document.querySelectorAll('.ad-placeholder, .sticky, [id*="-container"], #hindsight-ads-iframe'); 424 removeDOMElement(story_generic_iframe, blocker, ...overlays, ...ads); 425 } else if (window.location.hostname.endsWith('.com.au')) { 426 // Australia News Corp 427 let au_news_corp_domains = ['adelaidenow.com.au', 'cairnspost.com.au', 'codesports.com.au', 'couriermail.com.au', 'dailytelegraph.com.au', 'geelongadvertiser.com.au', 'goldcoastbulletin.com.au', 'heraldsun.com.au', 'ntnews.com.au', 'theaustralian.com.au', 'thechronicle.com.au', 'themercury.com.au', 'townsvillebulletin.com.au', 'weeklytimesnow.com.au']; 428 if (matchDomain(au_news_corp_domains)) { 429 if (window.location.hostname.startsWith('amp.') || window.location.search.match(/[&\?]amp/)) { 430 let figure_stretch = document.querySelectorAll('figure.stretch'); 431 for (let elem of figure_stretch) 432 elem.classList.remove('stretch'); 433 let amp_ads_sel = 'amp-ad, amp-embed, [id^="ad-mrec-"], [class*="ad-container"]'; 434 let comments; 435 if (window.location.hostname.startsWith('amp.')) { 436 amp_unhide_subscr_section(amp_ads_sel, true, true, '.newscdn.com.au'); 437 comments = document.querySelector('#story-comments, .comments-wrapper'); 438 } else if (window.location.search.match(/(\?|&)amp/)) { 439 amp_unhide_subscr_section(amp_ads_sel, true, true, '.newscdn.com.au'); 440 comments = document.querySelector('#comments-load, .comments-module'); 441 let amp_iframe_sizers = document.querySelectorAll('amp-iframe > i-amphtml-sizer'); 442 removeDOMElement(...amp_iframe_sizers) 443 } 444 removeDOMElement(comments); 445 } else { 446 if (matchDomain('codesports.com.au')) { 447 let lazy_images = document.querySelectorAll('img.lazyload[data-src]:not([src])'); 448 for (let elem of lazy_images) { 449 elem.src = elem.getAttribute('data-src'); 450 elem.classList.remove('lazyload'); 451 } 452 } 453 let ads = document.querySelectorAll('.header_ads-container, .ad-block, .ad-container'); 454 removeDOMElement(...ads); 455 } 456 } else { 457 // Australian Seven West Media 458 if (matchDomain('thewest.com.au') || document.querySelector('li > a[href*=".sevenwestmedia.com.au"]')) { 459 window.setTimeout(function () { 460 let breach_screen = document.querySelector('div.paywall div[data-testid*="BreachScreen"], div[class*="StyledBreachWallContent"]'); 461 if (breach_screen) { 462 let scripts = document.querySelectorAll('script:not([src]):not([type])'); 463 let json_script; 464 for (let script of scripts) { 465 if (script.text.includes('window.PAGE_DATA =')) { 466 json_script = script; 467 break; 468 } 469 } 470 if (json_script) { 471 let json_text = json_script.text.split('window.PAGE_DATA =')[1].split('</script')[0]; 472 json_text = json_text.replace(/:undefined([,}])/g, ':"undefined"$1'); 473 try { 474 let json_article = JSON.parse(json_text); 475 let json_pub; 476 for (let key in json_article) { 477 let json_resolution = json_article[key].data.result.resolution; 478 if (json_resolution && json_resolution.publication) { 479 json_pub = json_resolution.publication; 480 break; 481 } 482 } 483 let json_content = []; 484 let url_loaded; 485 if (json_pub) { 486 json_content = json_pub.content.blocks; 487 url_loaded = json_pub._self; 488 } else 489 window.location.reload(true); 490 //let json_video = json_pub.mainVideo; 491 let url = window.location.href; 492 if (!url_loaded || !url.includes(url_loaded.slice(-10))) 493 window.location.reload(true); 494 let par_elem, par_sub1, par_sub2; 495 let par_dom = document.createElement('div'); 496 let tweet_id = 1; 497 for (let par of json_content) { 498 par_elem = ''; 499 if (par.kind === 'text') { 500 par_elem = document.createElement('p'); 501 par_elem.innerText = par.text; 502 } else if (par.kind === 'subhead') { 503 par_elem = document.createElement('h2'); 504 par_elem.innerText = par.text; 505 } else if (par.kind === 'pull-quote') { 506 par_elem = document.createElement('i'); 507 par_elem.innerText = (par.attribution ? par.attribution + ': ' : '') + par.text; 508 } else if (par.kind === 'embed') { 509 if (par.reference.includes('https://omny.fm/') || par.reference.includes('https://docdro.id/')) { 510 par_elem = document.createElement('embed'); 511 par_elem.src = par.reference; 512 par_elem.style = 'height:500px; width:100%'; 513 par_elem.frameborder = '0'; 514 } else { 515 par_elem = document.createElement('a'); 516 par_elem.href = par.reference; 517 par_elem.innerText = par.reference.split('?')[0]; 518 console.log('embed: ' + par.reference); 519 } 520 } else if (par.kind === 'unordered-list') { 521 if (par.items) { 522 par_elem = document.createElement('ul'); 523 for (let item of par.items) 524 if (item.text) { 525 par_sub1 = document.createElement('li'); 526 if (item.intentions[0] && item.intentions[0].href) { 527 par_sub2 = document.createElement('a'); 528 par_sub2.href = item.intentions[0].href; 529 } else { 530 par_sub2 = document.createElement('span'); 531 } 532 par_sub2.innerText = item.text; 533 par_sub1.appendChild(par_sub2); 534 par_elem.appendChild(par_sub1); 535 } 536 } 537 } else if (par.kind === 'inline') { 538 if (par.asset.kind === 'image') { 539 par_elem = document.createElement('figure'); 540 par_sub1 = document.createElement('img'); 541 par_sub1.src = par.asset.original.reference; 542 par_sub1.style = 'width:100%'; 543 par_elem.appendChild(par_sub1); 544 if (par.asset.captionText) { 545 par_sub2 = document.createElement('figcaption'); 546 par_sub2.innerText = par.asset.captionText + ' ' + (par.asset.copyrightByline ? par.asset.copyrightByline : '') + 547 ((par.asset.copyrightCredit && par.asset.captionText !== par.asset.copyrightByline) ? '/' + par.asset.copyrightCredit : ''); 548 par_elem.appendChild(par_sub2); 549 } 550 } 551 } else if (par.kind === 'inline-related') { 552 par_elem = document.createElement('p'); 553 if (par.publications) { 554 for (let elem of par.publications) { 555 let par_link = document.createElement('a'); 556 par_link.href = elem._self; 557 par_link.innerText = elem.heading; 558 par_elem.appendChild(par_link); 559 par_elem.appendChild(document.createElement('br')); 560 } 561 } 562 } else { 563 par_elem = document.createElement('p'); 564 par_elem.innerText = par.text; 565 console.log(par.kind); 566 } 567 if (par_elem) 568 par_dom.appendChild(par_elem); 569 } 570 let content = document.querySelector('div[class*="StyledArticleContent"]'); 571 if (content) { 572 content.innerHTML = ''; 573 content.appendChild(par_dom); 574 } else { 575 par_dom.setAttribute('style', 'margin: 20px;'); 576 breach_screen.before(par_dom); 577 } 578 } catch (err) { 579 console.log(err); 580 } 581 } 582 removeDOMElement(breach_screen); 583 } 584 }, 2000); 585 let header_advert = document.querySelector('.headerAdvertisement'); 586 hideDOMElement(header_advert); 587 } 588 } 589 } 590 else 591 csDone = true; 592 } 593 594 } else if (window.location.hostname.match(/\.(de|at|ch)$/) || matchDomain(['faz.net', 'topagrar.com', 'wochenblatt.com'])) {//germany/austria/switzerland - ch 595 596 if (matchDomain('aerztezeitung.de')) { 597 let paywall = document.querySelector('div.AZLoginModule'); 598 if (paywall) { 599 removeDOMElement(paywall); 600 let json_script = getArticleJsonScript(); 601 if (json_script) { 602 let json = JSON.parse(json_script.text); 603 if (json) { 604 let json_text = json.articleBody; 605 let content = document.querySelector('p.intro'); 606 if (json_text && content) { 607 let article_new = document.createElement('p'); 608 article_new.innerText = json_text; 609 content.after(article_new); 610 } 611 } 612 } 613 } 614 } 615 616 else if (matchDomain(['arcinfo.ch', 'lacote.ch', 'lenouvelliste.ch'])) {// Groupe ESH Médias 617 let paywall = document.querySelector('section#paywall-articles'); 618 if (paywall && dompurify_loaded) { 619 removeDOMElement(paywall); 620 let url_id = window.location.pathname.match(/\d+$/).pop(); 621 let html = document.documentElement.outerHTML; 622 let og_url = document.querySelector('meta[name="og:url"][content]'); 623 if (og_url && !og_url.content.endsWith(url_id)) 624 window.location.reload(true); 625 let json; 626 if (html.includes('window.__NUXT__=')) 627 json = html.split('window.__NUXT__=')[1].split('</script>')[0].trim().replace(/blocs:\[\{.*?\}\],/g, ''); 628 let article = document.querySelector('div.html-content'); 629 let no_intro = false; 630 if (!article) { 631 article = document.querySelector('div.container-mobile-full'); 632 no_intro = true; 633 } 634 if (article && json) { 635 let content = ''; 636 if (json.includes('text_1="')) 637 content = json.split('text_1="').pop().split('";')[0]; 638 else { 639 let parts = json.split('html:"'); 640 parts.splice(0, 1); 641 for (let part of parts) 642 content += part.split('",has_pre_content')[0]; 643 } 644 if (content) { 645 content = content.replace(/\\u003C/g, '<').replace(/\\u003E/g, '>').replace(/\\u002F/g, '/').replace(/\\"/g, '"').replace(/\\r\\n/g, ''); 646 let parser = new DOMParser(); 647 let content_new = parser.parseFromString('<div class="html-content">' + DOMPurify.sanitize(content) + '</div>', 'text/html'); 648 let article_top; 649 if (!no_intro) { 650 article_top = article.parentNode.parentNode; 651 removeDOMElement(article.parentNode); 652 } else 653 article_top = article; 654 article_top.appendChild(content_new.querySelector('div')); 655 } else { 656 window.location.reload(true); 657 } 658 } 659 } 660 } 661 662 else if (matchDomain('augsburger-allgemeine.de')) { 663 let url = window.location.href; 664 if (!url.includes('-amp.html')) { 665 let paywall = document.querySelector('div.aa-visible-logged-out'); 666 if (paywall) { 667 removeDOMElement(paywall); 668 window.location.href = url.replace('.html', '-amp.html'); 669 } 670 } else { 671 amp_unhide_subscr_section(); 672 } 673 } 674 675 else if (matchDomain(['beobachter.ch', 'handelszeitung.ch'])) { 676 let paywall = document.querySelector('div#piano-inlined'); 677 if (paywall && dompurify_loaded) { 678 removeDOMElement(paywall); 679 let json_script = document.querySelector('script#hydrationdata'); 680 if (json_script) { 681 try { 682 let json = JSON.parse(json_script.text); 683 if (json) { 684 let url_id = json_script.text.includes('"gcid":"') ? json_script.text.split('"gcid":"')[1].split('","nid"')[0] : ''; 685 if (url_id && !window.location.pathname.endsWith(url_id)) 686 refreshCurrentTab(); 687 let pars = json.state; 688 let paragraphs = document.querySelectorAll('div.paragraph'); 689 let article = paragraphs[0]; 690 if (article) { 691 article.setAttribute('class', 'paragraph text-paragraph'); 692 for (let paragraph of paragraphs) 693 paragraph.innerHTML = ''; 694 let parser = new DOMParser(); 695 for (let par in pars) { 696 let content = pars[par].text; 697 if (content) { 698 let content_new = parser.parseFromString('<div style="font-size: 1.7rem; margin: 50px;">' + DOMPurify.sanitize(content) + '</div>', 'text/html'); 699 let article_new = content_new.querySelector('div'); ; 700 article.appendChild(article_new); 701 } 702 } 703 } 704 } 705 } catch (err) { 706 console.log(err); 707 } 708 } 709 } 710 let ads = document.querySelectorAll('div.ad-wrapper'); 711 hideDOMElement(...ads); 712 } 713 714 else if (matchDomain('berliner-zeitung.de')) { 715 window.setTimeout(function () { 716 let ads = document.querySelectorAll('[id^="traffective-ad"], [class^="ad-slot_wrapper"], [class^="outbrain_container"]'); 717 hideDOMElement(...ads); 718 }, 1000); 719 } 720 721 else if (matchDomain('boersen-zeitung.de')) { 722 let url = window.location.href; 723 let paywall = document.querySelector('storefront-element[child-id="paywall"]'); 724 if (paywall) { 725 removeDOMElement(paywall); 726 replaceDomElementExt(url, false, false, 'article'); 727 } 728 } 729 730 else if (matchDomain('cicero.de')) { 731 let url = window.location.href; 732 if (!window.location.search.match(/(\?|&)amp/)) { 733 let paywall = document.querySelector('.plenigo-paywall'); 734 if (paywall) { 735 removeDOMElement(paywall); 736 let url_amp = url.split('?')[0] + '?amp'; 737 replaceDomElementExt(url_amp, false, false, '.field-name-field-cc-body'); 738 } 739 } else { 740 let teasered_content = document.querySelector('.teasered-content'); 741 if (teasered_content) 742 teasered_content.classList.remove('teasered-content'); 743 let teasered_content_fader = document.querySelector('.teasered-content-fader'); 744 let btn_read_more = document.querySelector('.btn--read-more'); 745 let amp_ads = document.querySelectorAll('amp-ad'); 746 removeDOMElement(teasered_content_fader, btn_read_more, ...amp_ads); 747 } 748 let urban_ad_sign = document.querySelectorAll('.urban-ad-sign'); 749 removeDOMElement(...urban_ad_sign); 750 } 751 752 else if (matchDomain('faz.net')) { 753 if (matchDomain('zeitung.faz.net')) { 754 let paywall_z = document.querySelector('.c-red-carpet'); 755 if (paywall_z) { 756 removeDOMElement(paywall_z); 757 let og_url = document.querySelector('meta[property="og:url"][content]'); 758 if (og_url) 759 window.location.href = og_url.content; 760 } 761 let sticky_advt = document.querySelector('.sticky-advt'); 762 removeDOMElement(sticky_advt); 763 } else { 764 let paywall = document.querySelector('#paywall-form-container-outer, .atc-ContainerPaywall'); 765 if (paywall) { 766 removeDOMElement(paywall); 767 let url = new URL(window.location.href); 768 let mUrl = new URL(url.pathname, 'https://m.faz.net/'); 769 try { 770 fetch(mUrl) 771 .then(response => { 772 if (response.ok) { 773 response.text().then(html => { 774 let parser = new DOMParser(); 775 let doc = parser.parseFromString(html, 'text/html'); 776 let json = doc.querySelector('script[id="schemaOrgJson"]'); 777 if (json) { 778 let json_text = json.text.replace(/(\r|\n)/g, ''); 779 let split1 = json_text.split('"ArticleBody": "'); 780 let split2 = split1[1].split('","author":'); 781 if (split2[0].includes('"')) 782 json_text = split1[0] + '"ArticleBody": "' + split2[0].replace(/(\\)?"/g, "'") + '","author":' + split2[1]; 783 try { 784 json_text = JSON.parse(json_text).ArticleBody; 785 } catch (err) { 786 console.log(err); 787 return; 788 } 789 if (!json_text) 790 return; 791 let article_text = document.querySelector('.art_txt.paywall,.atc-Text.js-atc-Text'); 792 article_text.innerText = ''; 793 json_text = breakText(json_text); 794 json_text.split("\n\n").forEach( 795 (p_text) => { 796 let elem; 797 if (p_text.length < 80) { 798 elem = document.createElement("h2"); 799 elem.setAttribute('class', 'atc-SubHeadline'); 800 } else { 801 elem = document.createElement("p"); 802 elem.setAttribute('class', 'atc-TextParagraph'); 803 }; 804 elem.innerText = p_text; 805 article_text.appendChild(elem); 806 }); 807 } 808 }) 809 } 810 }); 811 } catch (err) { 812 console.log(err); 813 } 814 } 815 let lay_paysocial = document.querySelector('div.lay-PaySocial'); 816 let ads = document.querySelectorAll('div.iqadtile_wrapper'); 817 removeDOMElement(lay_paysocial, ...ads); 818 } 819 } 820 821 else if (matchDomain('freiepresse.de')) { 822 let url = window.location.href; 823 let article_teaser = document.querySelector('div.article-teaser'); 824 if (article_teaser && url.match(/(\-artikel)(\d){6,}/)) { 825 window.setTimeout(function () { 826 window.location.href = url.replace('-artikel', '-amp'); 827 }, 500); 828 } else if (url.match(/(\-amp)(\d){6,}/)) { 829 let amp_ads = document.querySelectorAll('amp-fx-flying-carpet, amp-ad, amp-embed'); 830 let pw_layer = document.querySelector('.pw-layer'); 831 removeDOMElement(...amp_ads, pw_layer); 832 } 833 } 834 835 else if (matchDomain('jacobin.de')) { 836 let paywall = pageContains('h3.m-auto', 'Dieser Artikel ist nur mit Abo zugänglich.'); 837 if (paywall.length) { 838 let slash = document.querySelector('div.slash'); 839 removeDOMElement(paywall[0].parentNode, slash); 840 let json_script = document.querySelector('script#__NEXT_DATA__'); 841 if (json_script) { 842 try { 843 let json = JSON.parse(json_script.text); 844 if (json && json.props.pageProps.sections && json.props.pageProps.sections[1].content) { 845 let url_next = json.query.slug; 846 if (url_next && !window.location.pathname.includes(url_next)) 847 refreshCurrentTab(); 848 let pars = json.props.pageProps.sections[1].content; 849 let first_par = document.querySelector('body > div#__next p.bodyText'); 850 if (first_par) { 851 let par_class = first_par.getAttribute('class'); 852 let article = first_par.parentNode; 853 if (article) { 854 let add_par = false; 855 for (let par of pars) { 856 if (!add_par) { 857 if (par.type === 'paywall') 858 add_par = true; 859 } else { 860 if (par.text) { 861 let elem_type = 'p'; 862 let elem_class = par_class; 863 let elem_style; 864 if (['paragraph', 'quote'].includes(par.type)) { 865 if (par.type === 'quote') 866 elem_style = 'font-size: 36px; font-weight: bold;'; 867 } else if (par.type === 'header') { 868 elem_type = 'h2'; 869 elem_class = 'content-element font-headline h2 my-1em'; 870 } 871 let content = par.text.replace(/ /g, ''); 872 let parser = new DOMParser(); 873 let content_new = parser.parseFromString('<' + elem_type + ' class="' + elem_class + (elem_style ? '" style="' + elem_style : '') + '">' + DOMPurify.sanitize(content) + '</' + elem_type + 'p>', 'text/html'); 874 article.appendChild(content_new.querySelector(elem_type)); 875 } else 876 console.log(par); 877 } 878 } 879 } 880 } 881 } 882 } catch (err) { 883 console.log(err); 884 } 885 } 886 } 887 } 888 889 else if (matchDomain('krautreporter.de')) { 890 let paywall = document.querySelector('.js-article-paywall'); 891 if (paywall) { 892 removeDOMElement(paywall); 893 window.setTimeout(function () { 894 let paywall_divider = document.querySelector('.js-paywall-divider'); 895 let steady_checkout = document.querySelector('#steady-checkout'); 896 removeDOMElement(paywall_divider, steady_checkout); 897 let blurred = document.querySelectorAll('.blurred'); 898 for (let elem of blurred) 899 elem.classList.remove('blurred', 'json-ld-paywall-marker', 'hidden@print'); 900 }, 500); 901 } 902 } 903 904 else if (matchDomain(['ksta.de', 'rundschau-online.de'])) { 905 let paywall = document.querySelector('div[data-tm-placeholder]'); 906 if (paywall) { 907 removeDOMElement(paywall); 908 let span_hidden = document.querySelector('div.dm-paint'); 909 if (span_hidden) 910 span_hidden.removeAttribute('class'); 911 } else { 912 let paywall_new = document.querySelector('div.paywalled-content'); 913 if (paywall_new) 914 paywall_new.removeAttribute('class'); 915 let wrapper = document.querySelector('div.dm-paywall-wrapper'); 916 removeDOMElement(wrapper); 917 } 918 let banners = document.querySelectorAll('div.dm-slot, div[id^="taboola-feed"]'); 919 removeDOMElement(...banners); 920 } 921 922 else if (matchDomain('kurier.at')) { 923 let paywall = document.querySelector('div.plusContent'); 924 if (paywall) { 925 paywall.classList.remove('plusContent'); 926 window.setTimeout(function () { 927 let elem_hidden = paywall.querySelectorAll('.ng-star-inserted[style="display: none;"]'); 928 for (let elem of elem_hidden) 929 elem.removeAttribute('style'); 930 }, 2000); 931 } 932 let banners = document.querySelectorAll('div#view-offer, app-paywall, adfullbanner, outbrain'); 933 removeDOMElement(...banners); 934 } 935 936 else if (matchDomain(['noz.de', 'shz.de', 'svz.de'])) { 937 if (window.location.pathname.endsWith('/amp')) { 938 amp_unhide_access_hide('="NOT data.reduced"', '="data.reduced"', 'amp-ad, amp-embed, .ads-wrapper, #flying-carpet-wrapper'); 939 } else { 940 let ads = document.querySelectorAll('div.nozmhn_ad'); 941 hideDOMElement(...ads); 942 } 943 } 944 945 else if (matchDomain('nw.de')) { 946 if (!window.location.pathname.endsWith('.amp.html')) { 947 let paywall = document.querySelector('div[data-tracking-visible^="paywall-"]'); 948 let amphtml = document.querySelector('link[rel="amphtml"]'); 949 if (paywall && amphtml) { 950 removeDOMElement(paywall); 951 window.location.href = amphtml.href; 952 } 953 } else { 954 amp_unhide_access_hide('="loggedIn AND hasAbo"', '', 'amp-ad, amp-embed, .banner'); 955 } 956 } 957 958 else if (matchDomain('nwzonline.de')) { 959 let paywall = document.querySelector('div.offerlist-wrapper'); 960 if (paywall) { 961 removeDOMElement(paywall); 962 let json_script = getArticleJsonScript(); 963 if (json_script) { 964 let json = JSON.parse(json_script.text); 965 if (json) { 966 let json_text = breakText(parseHtmlEntities(json.articleBody)); 967 let content = document.querySelector('div.article-body'); 968 if (json_text && content) { 969 content.innerHTML = ''; 970 let article_new = document.createElement('p'); 971 article_new.innerText = json_text; 972 content.appendChild(article_new); 973 } 974 } 975 } 976 } 977 } 978 979 else if (matchDomain('nzz.ch')) { 980 if (!window.location.href.includes('/amp/')) { 981 let ads = document.querySelectorAll('div.resor'); 982 hideDOMElement(...ads); 983 } else { 984 let amp_ads = document.querySelectorAll('amp-ad'); 985 removeDOMElement(...amp_ads); 986 } 987 } 988 989 else if (matchDomain('philomag.de')) { 990 let paywall = document.querySelector('div[id^="block-paywall"]'); 991 if (paywall) { 992 removeDOMElement(paywall); 993 let json_script = getArticleJsonScript(); 994 if (json_script) { 995 let json = JSON.parse(json_script.text); 996 if (json) { 997 let json_text = json.articlebody.replace(/%paywall%/g, '').replace(/(\\r)?\\n/g, '<br><br>'); 998 let content = document.querySelector('div.content-center > div.description'); 999 if (json_text && content) { 1000 content.innerHTML = ''; 1001 let article_new = document.createElement('p'); 1002 article_new.innerText = json_text; 1003 content.appendChild(article_new); 1004 } 1005 } 1006 } 1007 } 1008 } 1009 1010 else if (matchDomain('schwaebische.de')) { 1011 let url = window.location.href; 1012 let paywall = document.querySelector('div.sve-paywall-wrapper'); 1013 if (paywall) { 1014 removeDOMElement(paywall); 1015 csDoneOnce = true; 1016 let url_cache = 'https://webcache.googleusercontent.com/search?q=cache:' + url.split('?')[0]; 1017 replaceDomElementExt(url_cache, true, false, 'div.article_body'); 1018 let body = document.querySelector('body'); 1019 if (body) 1020 body.removeAttribute('style'); 1021 waitDOMAttribute('body', 'body', 'style', node => node.removeAttribute('style'), true); 1022 } 1023 window.setTimeout(function () { 1024 let ads = document.querySelectorAll('div.fp-ad-placeholder'); 1025 hideDOMElement(...ads); 1026 }, 1000); 1027 } 1028 1029 else if (matchDomain('spiegel.de')) { 1030 let url = window.location.href; 1031 let paywall = document.querySelector('div[data-area="paywall"]'); 1032 if (paywall) { 1033 removeDOMElement(paywall); 1034 let article = document.querySelector('div[data-area="body"]'); 1035 if (article) 1036 article.firstChild.before(archiveLink(url)); 1037 } 1038 } 1039 1040 else if (matchDomain(['stuttgarter-nachrichten.de', 'stuttgarter-zeitung.de', 'schwarzwaelder-bote.de']) || matchDomain(de_mhs_custom_domains)) { 1041 let banner = document.querySelector('div.mod-paywall'); 1042 removeDOMElement(banner); 1043 } 1044 1045 else if (matchDomain('zeit.de')) { 1046 let url = window.location.href; 1047 let paywall = document.querySelector('aside#paywall'); 1048 if (paywall) { 1049 removeDOMElement(paywall); 1050 let article = document.querySelector('div.article-body'); 1051 if (article) 1052 article.firstChild.before(archiveLink(url)); 1053 let fade = document.querySelector('div.paragraph--faded'); 1054 if (fade) 1055 fade.classList.remove('paragraph--faded'); 1056 } 1057 } 1058 1059 else if (matchDomain(de_lv_domains)) { 1060 let paywall_topagrar = document.querySelector('div > div.paywall-package'); 1061 let paywall_other = document.querySelector('div[id^="paymentprocess-"]'); 1062 if (paywall_topagrar || paywall_other) { 1063 if (paywall_topagrar) 1064 removeDOMElement(paywall_topagrar.parentNode); 1065 else { 1066 let intro = document.querySelector('div.m-paywall__textFadeOut'); 1067 removeDOMElement(paywall_other, intro); 1068 } 1069 let div_hidden = document.querySelector('div.paywall-full-content[style]'); 1070 if (div_hidden) { 1071 div_hidden.removeAttribute('class'); 1072 div_hidden.removeAttribute('style'); 1073 } 1074 } 1075 let banners = document.querySelectorAll('.adZone'); 1076 removeDOMElement(...banners); 1077 } 1078 1079 else if (matchDomain(de_westfalen_medien_domains)) { 1080 let url = window.location.href; 1081 if (url.includes('/amp/')) { 1082 amp_unhide_subscr_section('amp-ad, amp-embed, section[class^="fp-ad"]'); 1083 } else { 1084 let paywall = document.querySelector('.fp-article-paywall'); 1085 let amphtml = document.querySelector('link[rel="amphtml"]'); 1086 if (paywall) { 1087 removeDOMElement(paywall); 1088 if (amphtml) 1089 window.location.href = amphtml.href; 1090 } 1091 } 1092 } 1093 1094 else if (matchDomain(de_funke_medien_domains) || document.querySelector('a[href="https://www.funkemedien.de/"]')) { 1095 if (window.location.search.startsWith('?service=amp')) 1096 amp_unhide_access_hide('="NOT p.showRegWall AND NOT p.showPayWall"', '', 'amp-ad, amp-embed, amp-fx-flying-carpet'); 1097 else 1098 sessionStorage.setItem('deobfuscate', 'true'); 1099 } 1100 1101 else if (matchDomain(de_madsack_domains) || document.querySelector('link[href*=".rndtech.de/"]')) { 1102 // plus code in contentScript_once_var.js (timing) 1103 if (!window.location.search.startsWith('?outputType=valid_amp')) { 1104 let ads = document.querySelectorAll('div[class^="Adstyled__AdWrapper"]'); 1105 hideDOMElement(...ads); 1106 } else { 1107 ampToHtml(); 1108 } 1109 } 1110 1111 else if (matchDomain('ruhrnachrichten.de') || document.querySelector('div.mgw-integration > a.mgw__link')) { 1112 let paywall = document.querySelector('body.is_plus_article'); 1113 if (paywall && dompurify_loaded) { 1114 paywall.classList.remove('is_plus_article'); 1115 let json_url_dom = document.querySelector('link[rel="alternate"][type="application/json"][href]'); 1116 let json_url = json_url_dom.href; 1117 fetch(json_url) 1118 .then(response => { 1119 if (response.ok) { 1120 response.json().then(json => { 1121 let json_text = json.content.rendered; 1122 let content = document.querySelector('article'); 1123 if (json_text && content) { 1124 let parser = new DOMParser(); 1125 let doc = parser.parseFromString('<div>' + DOMPurify.sanitize(json_text, {ADD_TAGS: ['iframe']}) + '</div>', 'text/html'); 1126 let content_new = doc.querySelector('div'); 1127 content.appendChild(content_new); 1128 } 1129 }); 1130 } 1131 }); 1132 } 1133 let ads = document.querySelector('div.OUTBRAIN'); 1134 removeDOMElement(ads); 1135 if (!matchDomain('ruhrnachrichten.de')) { 1136 window.setTimeout(function () { 1137 let push = document.querySelector('div.cleverpush-bell'); 1138 removeDOMElement(push); 1139 }, 1000); 1140 } 1141 } 1142 1143 else if (matchDomain(de_vrm_domains) || matchDomain(de_vrm_custom_domains)) { 1144 let ads = document.querySelectorAll('div.adSlot'); 1145 hideDOMElement(...ads); 1146 } 1147 1148 else if (document.querySelector('script[src^="https://assets.static-chmedia.ch/"]')) {// nzz.ch regional/CH Media 1149 let infobox_body = document.querySelector('div.infobox__body'); 1150 if (infobox_body) 1151 infobox_body.removeAttribute('class'); 1152 let paywall = document.querySelector('div.dynamic-regwall'); 1153 removeDOMElement(paywall); 1154 } 1155 1156 else 1157 csDone = true; 1158 1159 } else if (window.location.hostname.match(/\.(dk|fi|se)$/)) {//denmark/finland/sweden 1160 1161 if (matchDomain('etc.se')) { 1162 let paywall = document.querySelector('div.paywalled'); 1163 if (paywall) { 1164 paywall.removeAttribute('class'); 1165 let gradient = document.querySelector('div.bg-gradient-white'); 1166 if (gradient) 1167 gradient.removeAttribute('class'); 1168 let footer = document.querySelector('footer'); 1169 removeDOMElement(footer.parentNode); 1170 } 1171 let ads = document.querySelectorAll('div[class$="-ad"]'); 1172 removeDOMElement(...ads); 1173 let video_iframes = document.querySelectorAll('div.embed-block > iframe[width][height]'); 1174 for (let elem of video_iframes) { 1175 if (elem.width > 1000) { 1176 let ratio = elem.width / 640; 1177 if (window.navigator.userAgent.toLowerCase().includes('mobile')) 1178 ratio = elem.width / 320; 1179 elem.width = elem.width / ratio; 1180 elem.height = elem.height / ratio; 1181 } 1182 } 1183 } 1184 1185 else if (matchDomain('nyteknik.se')) { 1186 let locked_article = document.querySelector('div.locked-article'); 1187 if (locked_article) 1188 locked_article.classList.remove('locked-article'); 1189 window.setTimeout(function () { 1190 let hidden_images = document.querySelectorAll('img[src=""][data-proxy-image]'); 1191 for (let hidden_image of hidden_images) 1192 hidden_image.setAttribute('src', hidden_image.getAttribute('data-proxy-image').replace('_320', '_640')); 1193 }, 2000); 1194 } 1195 1196 else if (matchDomain('suomensotilas.fi')) { 1197 let obscured = document.querySelector('div.epfl-pw-obscured'); 1198 if (obscured) 1199 obscured.classList.remove('epfl-pw-obscured'); 1200 } 1201 1202 else 1203 csDone = true; 1204 1205 } else if (window.location.hostname.match(/\.(es|pt|cat)$/) || matchDomain(['diariocordoba.com', 'diariovasco.com', 'elconfidencial.com', 'elcorreo.com', 'elespanol.com', 'elpais.com', 'elperiodico.com', 'elperiodicodearagon.com', 'elperiodicoextremadura.com', 'elperiodicomediterraneo.com', 'emporda.info', 'expansion.com', 'larioja.com', 'lavanguardia.com', 'levante-emv.com', 'marca.com', 'mundodeportivo.com', 'politicaexterior.com'])) {//spain/portugal 1206 1207 if (matchDomain(['ara.cat', 'arabalears.cat'])) { 1208 let url = window.location.href; 1209 if (!window.location.pathname.endsWith('.amp.html')) { 1210 let paywall = document.querySelector('div.paywall'); 1211 let amphtml = document.querySelector('link[rel="amphtml"]'); 1212 if (paywall && amphtml) { 1213 removeDOMElement(paywall); 1214 window.location.href = amphtml.href; 1215 } 1216 } 1217 } 1218 1219 else if (matchDomain(['cmjornal.pt', 'record.pt', 'sabado.pt'])) { 1220 let paywall = document.querySelector('.bloqueio_exclusivos, .container_assinatura, .bloco_bloqueio'); 1221 let amphtml = document.querySelector('link[rel="amphtml"]'); 1222 let url = window.location.href; 1223 if (!url.includes('/amp/')) { 1224 if (paywall && amphtml) { 1225 removeDOMElement(paywall); 1226 window.location.href = amphtml.href; 1227 } 1228 } else { 1229 amp_unhide_access_hide('="subscriber"', '="NOT subscriber"', 'amp-ad, amp-embed, amp-consent, .detalheAds, .exclusivos_bar'); 1230 let amp_links = document.querySelectorAll('a[href^="https://www-cmjornal-pt.cdn.ampproject.org/c/s/"]'); 1231 for (let amp_link of amp_links) 1232 amp_link.href = amp_link.href.replace('www-cmjornal-pt.cdn.ampproject.org/c/s/', ''); 1233 } 1234 } 1235 1236 else if (matchDomain('elconfidencial.com')) { 1237 let premium = document.querySelector('div.newsType__content--closed'); 1238 if (premium) 1239 premium.classList.remove('newsType__content--closed'); 1240 let ads = document.querySelectorAll('div[id^="mega_"], div[id^="roba_"]'); 1241 removeDOMElement(...ads); 1242 } 1243 1244 else if (matchDomain('eldiario.es')) { 1245 if (window.location.pathname.endsWith('.amp.html')) { 1246 amp_unhide_access_hide('^="access"'); 1247 } else { 1248 let ads = document.querySelectorAll('.edi-advertising, .header-ad'); 1249 removeDOMElement(...ads); 1250 } 1251 } 1252 1253 else if (matchDomain('elespanol.com')) { 1254 if (window.location.pathname.endsWith('.amp.html')) { 1255 amp_unhide_subscr_section('amp-ad, amp-embed'); 1256 } else { 1257 let paywall = document.querySelector('div.full-suscriptor-container'); 1258 let adverts = document.querySelectorAll('[id*="superior"], [class*="adv"]'); 1259 removeDOMElement(paywall, ...adverts); 1260 } 1261 } 1262 1263 else if (matchDomain(es_unidad_domains)) { 1264 let premium = document.querySelector('.ue-c-article__premium'); 1265 let url = window.location.href; 1266 if (!window.location.hostname.match(/^amp(-[a-z]{2})?\./)) { 1267 if (premium) { 1268 removeDOMElement(premium); 1269 window.location.href = url.replace('/www.', '/amp.'); 1270 } 1271 } else { 1272 amp_unhide_access_hide('="authorized=true"', '="authorized!=true"'); 1273 amp_unhide_subscr_section('.advertising, amp-embed, amp-ad'); 1274 } 1275 } 1276 1277 else if (matchDomain('elpais.com')) { 1278 let login_register = document.querySelector('.login_register'); 1279 if (window.location.pathname.endsWith('.amp.html') || window.location.search.match(/(\?|&)outputType=amp/)) { 1280 amp_unhide_access_hide('="vip"], [amp-access="success"', '="NOT vip"], [amp-access="NOT success"'); 1281 removeDOMElement(login_register); 1282 } else { 1283 let counter = document.querySelector('#counterLayerDiv'); 1284 removeDOMElement(counter); 1285 let amphtml = document.querySelector('link[rel="amphtml"]'); 1286 if (login_register && amphtml) { 1287 removeDOMElement(login_register, video); 1288 window.location.href = amphtml.href; 1289 } 1290 } 1291 let paywall_offer = document.querySelector('.paywallOffer'); 1292 let ctn_closed_article = document.querySelector('#ctn_closed_article, #ctn_freemium_article, #ctn_premium_article'); 1293 removeDOMElement(paywall_offer, ctn_closed_article); 1294 } 1295 1296 else if (matchDomain('elperiodico.com')) { 1297 let url = window.location.href; 1298 if (!url.includes('amp.elperiodico.com')) { 1299 let div_hidden = document.querySelector('div.closed'); 1300 if (div_hidden) 1301 div_hidden.classList.remove('closed'); 1302 else { 1303 let paywall = document.querySelector('.ep-masPeriodico-info-login'); 1304 removeDOMElement(paywall); 1305 if (paywall) 1306 window.location.href = url.replace('www.', 'amp.'); 1307 } 1308 } else { 1309 let not_logged = document.querySelector('.ep-masPeriodico-info-login'); 1310 if (not_logged) { 1311 removeDOMElement(not_logged); 1312 amp_unhide_access_hide('^="logged"', '^="NOT logged"'); 1313 } 1314 window.setTimeout(function () { 1315 let amp_img = document.querySelectorAll('amp-img > img'); 1316 for (let elem of amp_img) { 1317 if (elem.src) 1318 elem.src = elem.src.replace('amp.elperiodico.com/clip/', 'estaticos-cdn.elperiodico.com/clip/'); 1319 } 1320 }, 3000); 1321 } 1322 } 1323 1324 else if (matchDomain(es_grupo_vocento_domains)) { 1325 let paywall = document.querySelector('.voc-paywall, .container-wall-exclusive, .cierre-suscripcion:not([style*="display: none;"])'); 1326 if (!window.location.pathname.endsWith('_amp.html')) { 1327 let amphtml = document.querySelector('link[rel="amphtml"]'); 1328 if (!amphtml && !matchDomain(['eldiariomontanes.es'])) 1329 amphtml = {href: window.location.pathname.replace('.html', '_amp.html')}; 1330 if (paywall && amphtml) { 1331 removeDOMElement(paywall); 1332 window.location.href = amphtml.href; 1333 } else { 1334 let banners = document.querySelectorAll('.voc-advertising, div.ev-em-modal, span.mega-superior, .v-adv'); 1335 removeDOMElement(...banners); 1336 } 1337 } else { 1338 amp_unhide_access_hide('="result=\'ALLOW_ACCESS\'"', '="result!=\'ALLOW_ACCESS\'"', 'amp-ad, amp-embed, .v-adv'); 1339 removeDOMElement(paywall); 1340 let body_top = document.querySelector('body#top'); 1341 if (body_top) 1342 body_top.removeAttribute('id'); 1343 } 1344 } 1345 1346 else if (matchDomain(es_epiberica_domains) || matchDomain(es_epiberica_custom_domains)) { 1347 if (window.location.href.includes('.amp.html')) { 1348 let truncated = document.querySelector('div.article-body--truncated'); 1349 if (truncated) 1350 truncated.classList.remove('article-body--truncated'); 1351 amp_unhide_access_hide('="NOT access"], [amp-access="FALSE"', '="access"'); 1352 } else if (window.location.hostname === 'amp.epe.es') { 1353 amp_unhide_access_hide('="loggedIn"', '="NOT loggedIn"', 'amp-ad, amp-embed, amp-next-page'); 1354 } else { 1355 let ads = document.querySelectorAll('div.commercial-up-full__wrapper, div.sidebar--sticky__space, div[data-bbnx-id*="cxense"]'); 1356 removeDOMElement(...ads); 1357 } 1358 } 1359 1360 else if (matchDomain(['lavanguardia.com', 'mundodeportivo.com'])) { 1361 let ads = document.querySelectorAll('span.content-ad, span.hidden-ad, span.ad-unit, div.ad-div'); 1362 hideDOMElement(...ads); 1363 } 1364 1365 else if (matchDomain('observador.pt')) { 1366 if (!window.location.pathname.endsWith('/amp/')) { 1367 let paywall = document.querySelector('.premium-article'); 1368 let amphtml = document.querySelector('link[rel="amphtml"]'); 1369 if (paywall && amphtml) { 1370 paywall.classList.remove('premium-article'); 1371 window.location.href = amphtml.href; 1372 } 1373 } else { 1374 amp_unhide_subscr_section('amp-ad, amp-consent, section > .modal'); 1375 } 1376 } 1377 1378 else if (matchDomain('politicaexterior.com')) { 1379 let paywall = document.querySelector('div[class^="paywall-"]'); 1380 if (paywall) { 1381 let article = document.querySelector('div.entry-content-text'); 1382 let json = document.querySelector('script[type="application/ld+json"]:not([class])'); 1383 if (json) { 1384 let json_text = JSON.parse(json.text).description.replace(/&nbsp;/g, ''); 1385 let article_new = document.createElement('div'); 1386 article_new.setAttribute('class', 'entry-content-text'); 1387 article_new.innerText = '\r\n' + json_text; 1388 article.parentNode.replaceChild(article_new, article); 1389 } 1390 removeDOMElement(paywall); 1391 } 1392 } 1393 1394 else 1395 csDone = true; 1396 1397 } else if ((window.location.hostname.endsWith('.fr') && !matchDomain(['lemagit.fr'])) || matchDomain(['bienpublic.com', 'connaissancedesarts.com', 'journaldunet.com', 'la-croix.com', 'ledauphine.com', 'legrandcontinent.eu', 'lejsl.com', 'lesinrocks.com', 'lesoir.be', 'loeildelaphotographie.com', 'marianne.net', 'nouvelobs.com', 'parismatch.com', 'science-et-vie.com', 'sudinfo.be'].concat(fr_groupe_nice_matin_domains))) {//france 1398 1399 if (matchDomain('alternatives-economiques.fr')) { 1400 window.setTimeout(function () { 1401 let paywall = document.querySelector('#temp-paywall'); 1402 removeDOMElement(paywall); 1403 let data_ae_poool = document.querySelector('div[data-ae-poool]'); 1404 if (data_ae_poool) 1405 data_ae_poool.removeAttribute('style'); 1406 }, 500); 1407 } 1408 1409 else if (matchDomain('atlantico.fr')) { 1410 let paywall = document.querySelector('div.markup[class*="Paywall"]'); 1411 if (paywall) 1412 paywall.setAttribute('class', 'markup'); 1413 } 1414 1415 else if (matchDomain('autoplus.fr')) { 1416 let ads = document.querySelectorAll('div.placeholder-pub_dfp'); 1417 removeDOMElement(...ads); 1418 } 1419 1420 else if (matchDomain(['challenges.fr', 'sciencesetavenir.fr'])) { 1421 if (window.location.pathname.endsWith('.amp')) { 1422 amp_unhide_access_hide('="paywall.access OR cha.access"', '="NOT (paywall.access OR cha.access)"'); 1423 } else { 1424 let amorce = document.querySelector('div.amorce.manual'); 1425 hideDOMElement(amorce); 1426 let content = document.querySelectorAll('.user-paying-content'); 1427 for (let elem of content) { 1428 elem.classList.remove('user-paying-content'); 1429 elem.removeAttribute('hidden'); 1430 } 1431 let paywall = document.querySelector('.temp-paywall'); 1432 removeDOMElement(paywall); 1433 let ads = document.querySelectorAll('div[class^="pub-container"], div[id^="moneytag-"]'); 1434 hideDOMElement(...ads); 1435 } 1436 } 1437 1438 else if (matchDomain('charliehebdo.fr')) { 1439 window.setTimeout(function () { 1440 let paywalled_content = document.querySelector('div.ch-paywalled-content'); 1441 if (paywalled_content) 1442 paywalled_content.removeAttribute('style'); 1443 let poool_widget = document.querySelector('div#poool-widget'); 1444 removeDOMElement(poool_widget); 1445 }, 500); 1446 } 1447 1448 else if (matchDomain('connaissancedesarts.com')) { 1449 let ads = document.querySelectorAll('div.ad-container'); 1450 removeDOMElement(...ads); 1451 } 1452 1453 else if (matchDomain('elle.fr')) { 1454 if (window.location.hostname.startsWith('amp.')) { 1455 amp_unhide_access_hide('="poool.access OR cmi_premium.access"'); 1456 } else { 1457 let hidden_images = document.querySelectorAll('img[src^="data:image/"][data-src]'); 1458 for (let hidden_image of hidden_images) 1459 hidden_image.setAttribute('src', hidden_image.getAttribute('data-src')); 1460 let subscription_bar = document.querySelector('.tc-subscription-bar'); 1461 removeDOMElement(subscription_bar); 1462 } 1463 } 1464 1465 else if (matchDomain(fr_be_groupe_rossel)) { 1466 if (matchDomain('sudinfo.be')) { 1467 let paywall = document.querySelector('div.r-blurred'); 1468 if (paywall) { 1469 let paywall_header = document.querySelector('.r-paywall--header'); 1470 let intro = document.querySelector('div.r-not-blurred'); 1471 removeDOMElement(paywall, paywall_header, intro); 1472 let json_script = getArticleJsonScript(); 1473 if (json_script) { 1474 let json = JSON.parse(json_script.text); 1475 if (json) { 1476 let json_text = json.articleBody.replace(/ /g, '').replace(/\[.*\]/, ''); 1477 let content = document.querySelector('article'); 1478 if (json_text && content) { 1479 let par = document.createElement('p'); 1480 par.innerText = '\r\n' + json_text; 1481 content.appendChild(par); 1482 } 1483 } 1484 } 1485 } 1486 } 1487 let ads = document.querySelectorAll('div[id^="article_"], r-pub, div#rossel-leader-top'); 1488 hideDOMElement(...ads); 1489 } 1490 1491 else if (matchDomain(fr_groupe_ebra_domains)) { 1492 if (!window.location.pathname.startsWith('/amp/')) { 1493 let paywall = document.querySelector('div.preview'); 1494 let amphtml = document.querySelector('link[rel="amphtml"]'); 1495 if (paywall && amphtml) { 1496 removeDOMElement(paywall); 1497 window.location.href = amphtml.href; 1498 } 1499 } else { 1500 amp_unhide_access_hide('="access"', '="NOT access"', 'amp-ad, amp-embed'); 1501 } 1502 } 1503 1504 else if (matchDomain(fr_groupe_la_depeche_domains)) { 1505 if (window.location.pathname.startsWith('/amp/')) { 1506 amp_unhide_subscr_section('amp-ad, amp-embed'); 1507 } else { 1508 let paywall = document.querySelector('div.paywall'); 1509 let amphtml = document.querySelector('link[rel="amphtml"]'); 1510 if (paywall) { 1511 removeDOMElement(paywall); 1512 if (amphtml) 1513 window.location.href = amphtml.href; 1514 else { 1515 let json_script = getArticleJsonScript(); 1516 if (json_script) { 1517 let json = JSON.parse(json_script.text); 1518 if (json) { 1519 let json_text = parseHtmlEntities(json.articleBody); 1520 let content = document.querySelector('div.article-full__body-content'); 1521 if (json_text && content) { 1522 content.innerHTML = ''; 1523 let article_new = document.createElement('p'); 1524 article_new.innerText = json_text; 1525 content.appendChild(article_new); 1526 content.removeAttribute('style'); 1527 content.removeAttribute('data-state'); 1528 } 1529 } 1530 } 1531 } 1532 } 1533 } 1534 } 1535 1536 else if (matchDomain(fr_groupe_nice_matin_domains)) { 1537 if (window.location.pathname.startsWith('/amp/')) { 1538 amp_unhide_access_hide('="access"', '="NOT access"', 'amp-ad, amp-embed'); 1539 } else { 1540 let paywall = document.querySelector('div#article-teaser'); 1541 if (paywall) 1542 paywall.removeAttribute('id'); 1543 } 1544 let ads = document.querySelectorAll('div[class^="ad-slot-"]'); 1545 hideDOMElement(...ads); 1546 } 1547 1548 else if (matchDomain('franc-tireur.fr')) { 1549 let paywall = document.querySelector('.paywall'); 1550 removeDOMElement(paywall); 1551 } 1552 1553 else if (matchDomain('humanite.fr')) { 1554 if (window.location.search.startsWith('?amp')) { 1555 let qiota_script = document.querySelector('amp-script[src^="https://www.qiota.com/"]'); 1556 if (qiota_script) { 1557 let amphtml_fill_content = qiota_script.querySelector('div.i-amphtml-fill-content'); 1558 if (amphtml_fill_content) 1559 amphtml_fill_content.removeAttribute('class'); 1560 let i_amphtml_sizer = qiota_script.querySelector('i-amphtml-sizer'); 1561 removeDOMElement(i_amphtml_sizer); 1562 } 1563 } else { 1564 let banner = document.querySelector('div.qiota'); 1565 removeDOMElement(banner); 1566 } 1567 } 1568 1569 else if (matchDomain('journaldunet.com')) { 1570 let reg_wall = document.querySelector('.reg_wall'); 1571 removeDOMElement(reg_wall); 1572 let entry_reg_wall = document.querySelector('.entry_reg_wall'); 1573 if (entry_reg_wall) { 1574 entry_reg_wall.removeAttribute('style'); 1575 } 1576 } 1577 1578 else if (matchDomain('la-croix.com')) { 1579 let url = window.location.href; 1580 if (!url.includes('la-croix.com/amp/')) { 1581 let ads = document.querySelectorAll('div[class^="ads-wrapper-"]'); 1582 removeDOMElement(...ads); 1583 } else { 1584 let paywall_block = document.querySelector('#paywall_block'); 1585 let amp_ads = document.querySelectorAll('amp-ad, amp-embed'); 1586 removeDOMElement(paywall_block, ...amp_ads); 1587 } 1588 } 1589 1590 else if (matchDomain('lanouvellerepublique.fr')) { 1591 let alert_didacticiel = document.querySelector('div.alert-didacticiel'); 1592 let loading = document.querySelectorAll('span.loading'); 1593 removeDOMElement(alert_didacticiel, ...loading); 1594 } 1595 1596 else if (matchDomain('lecourrierdesstrateges.fr')) { 1597 window.setTimeout(function () { 1598 let paywall = document.querySelector('div.jpw-truncate-btn'); 1599 if (paywall && dompurify_loaded) { 1600 removeDOMElement(paywall); 1601 let json_script = getArticleJsonScript(); 1602 if (json_script) { 1603 let json = JSON.parse(json_script.text); 1604 if (json) { 1605 let json_text = json.articleBody; 1606 let content = document.querySelector('div.content-inner'); 1607 if (json_text && content) { 1608 let parser = new DOMParser(); 1609 let doc = parser.parseFromString('<div>' + DOMPurify.sanitize(json_text) + '</div>', 'text/html'); 1610 let content_new = doc.querySelector('div'); 1611 content.parentNode.replaceChild(content_new, content); 1612 let hidden_images = document.querySelectorAll('img[src][srcset]'); 1613 for (let elem of hidden_images) 1614 elem.removeAttribute('srcset'); 1615 let entry_content = document.querySelector('div.entry-content[style]'); 1616 if (entry_content) 1617 entry_content.removeAttribute('style'); 1618 } 1619 } 1620 } 1621 } 1622 }, 500); 1623 } 1624 1625 else if (matchDomain('legrandcontinent.eu')) { 1626 let paywall = document.querySelector('body.paywall, body.pw, body.softwall'); 1627 if (paywall) 1628 paywall.classList.remove('paywall', 'pw', 'softwall'); 1629 let banners = document.querySelectorAll('div#fix-pw, div.disposableBanner'); 1630 removeDOMElement(...banners); 1631 } 1632 1633 else if (matchDomain(['lejdd.fr', 'parismatch.com', 'public.fr'])) { 1634 let poool_banners = document.querySelectorAll('#poool-container, #poool-widget-content, #poool-widget'); 1635 let forbidden = document.querySelector('.forbidden'); 1636 let ads = document.querySelectorAll('div[class^="lmn-"]'); 1637 removeDOMElement(...poool_banners, forbidden, ...ads); 1638 let bottom_hide = document.querySelector('.cnt[data-poool-mode="hide"]'); 1639 if (bottom_hide) { 1640 bottom_hide.removeAttribute('data-poool-mode'); 1641 bottom_hide.removeAttribute('style'); 1642 } 1643 } 1644 1645 else if (matchDomain('leparisien.fr')) { 1646 let paywall = document.querySelector('div.paywall'); 1647 if (window.location.pathname.startsWith('/amp/')) { 1648 if (paywall) { 1649 let paywall_sticky = document.querySelector('div.paywall-sticky'); 1650 removeDOMElement(paywall, paywall_sticky); 1651 let section_hidden = document.querySelectorAll('section[hidden]'); 1652 for (let elem of section_hidden) 1653 elem.removeAttribute('hidden'); 1654 let mask = document.querySelector('.amp-premium-first-content'); 1655 if (mask) 1656 mask.classList.remove('amp-premium-first-content'); 1657 } 1658 } else { 1659 let amphtml = document.querySelector('link[rel="amphtml"]'); 1660 if (paywall && amphtml) { 1661 removeDOMElement(paywall); 1662 window.location.href = amphtml.href; 1663 } 1664 } 1665 } 1666 1667 else if (matchDomain('lesechos.fr')) { 1668 if (window.location.pathname.startsWith('/amp/')) { 1669 ampToHtml(); 1670 } else { 1671 window.setTimeout(function () { 1672 let abo_banner = document.querySelector('div[class*="pgxf3b-2"]'); 1673 let ad_blocks = document.querySelectorAll('[class*="jzxvkd"]'); 1674 hideDOMElement(...ad_blocks); 1675 if (abo_banner && dompurify_loaded) { 1676 removeDOMElement(abo_banner); 1677 let url = window.location.href; 1678 let html = document.documentElement.outerHTML; 1679 try { 1680 let split1 = html.split(/window\.__REACT_QUERY_STATE__\s?=/)[1]; 1681 let state = split1.split('</script>')[0].trim().replace(/;$/, ''); 1682 let data = JSON.parse(state); 1683 let data_article = data.queries[1].state; 1684 let url_loaded = data_article.data.path; 1685 if (url_loaded && (!url_loaded.slice(-7).match(/\d+/) || !url.includes(url_loaded.slice(-7)))) 1686 refreshCurrentTab(); 1687 else { 1688 let article = data_article.data.stripes[0].mainContent[0].data.description.replace(/allowfullscreen='(true)?'/g, ''); 1689 let paywallNode = document.querySelector('.post-paywall'); 1690 if (paywallNode) { 1691 let contentNode = document.createElement('div'); 1692 let parser = new DOMParser(); 1693 let article_html = parser.parseFromString('<div>' + DOMPurify.sanitize(article) + '</div>', 'text/html'); 1694 let article_par = article_html.querySelector('div'); 1695 if (article_par) { 1696 contentNode.appendChild(article_par); 1697 contentNode.className = paywallNode.className; 1698 paywallNode.before(contentNode); 1699 removeDOMElement(paywallNode); 1700 let paywallLastChildNode = document.querySelector('.post-paywall > :last-child'); 1701 if (paywallLastChildNode) { 1702 paywallLastChildNode.setAttribute('style', 'height: auto !important; overflow: hidden !important; max-height: none !important;'); 1703 } 1704 } 1705 } 1706 let styleElem = document.head.appendChild(document.createElement('style')); 1707 styleElem.innerHTML = ".post-paywall::after {height: auto !important;}"; 1708 } 1709 } catch (err) { 1710 console.log(err); 1711 } 1712 } 1713 }, 500); 1714 } 1715 } 1716 1717 else if (matchDomain('lesinrocks.com')) { 1718 if (window.location.search.match(/(\?|&)amp/)) { 1719 let size_defined = document.querySelector('amp-script.i-amphtml-layout-size-defined'); 1720 if (size_defined) 1721 size_defined.style = 'overflow:visible !important;'; 1722 let overlays = document.querySelectorAll('section.learn_more, div.sidebar, div.menu-footer, div.tooltip_bib, footer.content-info'); 1723 removeDOMElement(...overlays); 1724 } 1725 } 1726 1727 else if (matchDomain('letelegramme.fr')) { 1728 let paywall = document.querySelectorAll('div.tlg-paywalled'); 1729 for (let elem of paywall) 1730 elem.classList.remove('tlg-paywalled'); 1731 let ads = document.querySelectorAll('div[id^="pub_"]'); 1732 hideDOMElement(...ads); 1733 } 1734 1735 else if (matchDomain('lexpress.fr')) { 1736 let ads = document.querySelectorAll('div[class^="block_pub"], div.bottom-bar-full, div.tead, div.ban-bottom, div.placeholder--ban-atf'); 1737 hideDOMElement(...ads); 1738 } 1739 1740 else if (matchDomain('loeildelaphotographie.com')) { 1741 let paywall = document.querySelector('.paywall'); 1742 if (paywall) { 1743 paywall.removeAttribute('class'); 1744 } 1745 let premium_pic_boxes = document.querySelectorAll('.premium-pic-box'); 1746 let banners = document.querySelectorAll('.membership-promo-container, .login_form_litle'); 1747 removeDOMElement(...premium_pic_boxes, ...banners); 1748 let blurred_images = document.querySelectorAll('img[style*="blur"]'); 1749 for (let blurred_image of blurred_images) 1750 blurred_image.removeAttribute('style'); 1751 } 1752 1753 else if (matchDomain('marianne.net')) { 1754 let paywall = document.querySelector('div.paywall'); 1755 if (paywall && dompurify_loaded) { 1756 let article_source = document.querySelector('div.article-body[data-content-src]'); 1757 if (article_source) { 1758 let article_text = decode_utf8(atob(article_source.getAttribute('data-content-src'))); 1759 let parser = new DOMParser(); 1760 let html = parser.parseFromString('<div>' + DOMPurify.sanitize(article_text) + '</div>', 'text/html'); 1761 let article = html.querySelector('div'); 1762 article_source.innerHTML = ''; 1763 article_source.appendChild(article); 1764 article_source.removeAttribute('data-content-src'); 1765 } 1766 removeDOMElement(paywall); 1767 } 1768 } 1769 1770 else if (matchDomain('nouvelobs.com')) { 1771 let paywall = document.querySelector('.paywall'); 1772 removeDOMElement(paywall); 1773 let fade = document.querySelector('div.paywall--gradient-top'); 1774 if (fade) 1775 fade.classList.remove('paywall--gradient-top'); 1776 } 1777 1778 else if (matchDomain('science-et-vie.com')) { 1779 if (window.location.hostname.startsWith('amp.')) { 1780 let pars = document.querySelectorAll('.qiota_reserve > p, .qiota_reserve > h2'); 1781 let pars_text = []; 1782 for (let par of pars) { 1783 if (pars_text.includes(par.innerText)) 1784 removeDOMElement(par); 1785 else 1786 pars_text.push(par.innerText); 1787 } 1788 let sizer = document.querySelector('div.article-content > amp-script > i-amphtml-sizer'); 1789 removeDOMElement(sizer); 1790 let replaced_content = document.querySelector('div.i-amphtml-replaced-content'); 1791 if (replaced_content) 1792 replaced_content.removeAttribute('class'); 1793 } 1794 } 1795 1796 else if (matchDomain(['sudouest.fr', 'charentelibre.fr', 'larepubliquedespyrenees.fr'])) { 1797 let paywall = document.querySelectorAll('.visible-not-premium'); 1798 if (paywall.length) { 1799 removeDOMElement(...paywall); 1800 let visible_premium = document.querySelectorAll('div.visible-premium'); 1801 for (let elem of visible_premium) 1802 elem.classList.remove('visible-premium'); 1803 } 1804 window.setTimeout(function () { 1805 let footer_premium = document.querySelector('.footer-premium'); 1806 let ads = document.querySelectorAll('div.pub, div.ph-easy-subscription'); 1807 hideDOMElement(footer_premium, ...ads); 1808 }, 500); 1809 } 1810 1811 else if (matchDomain('lamontagne.fr') || document.querySelector('ul.list-inline > li > a[href="https://www.centrefrance.com/"]')) {// Groupe Centre France 1812 let paywall = document.querySelector('div#poool-widget'); 1813 if (paywall) { 1814 removeDOMElement(paywall); 1815 let json_script = getArticleJsonScript(); 1816 if (json_script) { 1817 let json = JSON.parse(json_script.text); 1818 if (json) { 1819 let json_text = json.articleBody; 1820 let content = document.querySelector('div.entry-content'); 1821 if (json_text && content) { 1822 content.innerHTML = ''; 1823 let article_new = document.createElement('p'); 1824 article_new.innerText = json_text; 1825 content.appendChild(article_new); 1826 } 1827 } 1828 } 1829 } 1830 } 1831 1832 else 1833 csDone = true; 1834 1835 } else if (window.location.hostname.endsWith('.it') || matchDomain(['eastwest.eu', 'italian.tech', 'limesonline.com', 'quotidiano.net'])) {//italy 1836 1837 if (matchDomain('corriere.it')) { 1838 if (window.location.pathname.endsWith('_amp.html')) { 1839 amp_unhide_subscr_section('amp-ad, amp-embed'); 1840 } else { 1841 if (window.location.pathname.includes('_preview.shtml') && !window.location.pathname.startsWith('/podcast/')) { 1842 window.setTimeout(function () { 1843 window.location.href = window.location.pathname.replace('_preview.shtml', '.shtml'); 1844 }, 500); 1845 } 1846 } 1847 } 1848 1849 else if (matchDomain('corrieredellosport.it')) { 1850 if (!window.location.pathname.startsWith('/amp/')) { 1851 let paywall = document.querySelector('div[class^="MainTextTruncated_paragraph__"]'); 1852 let amphtml = document.querySelector('link[rel="amphtml"]'); 1853 if (paywall && amphtml) { 1854 removeDOMElement(paywall); 1855 window.location.href = amphtml.href; 1856 } 1857 let ads = document.querySelectorAll('div[class^="AdUnit_placeholder"]'); 1858 removeDOMElement(...ads); 1859 } else { 1860 let ads = document.querySelectorAll('amp-ad, amp-embed'); 1861 removeDOMElement(...ads); 1862 } 1863 } 1864 1865 else if (matchDomain('eastwest.eu')) { 1866 let paywall = document.querySelector('.paywall'); 1867 if (paywall) { 1868 paywall.removeAttribute('style'); 1869 paywall.classList.remove('paywall'); 1870 let intro = document.querySelectorAll('div#testo_articolo > p, div#testo_articolo > h3'); 1871 let offerta = document.querySelectorAll('div.offerta_abbonamenti'); 1872 removeDOMElement(...intro, ...offerta); 1873 } 1874 } 1875 1876 else if (matchDomain('gazzetta.it')) { 1877 if (window.location.pathname.endsWith('_preview.shtml')) { 1878 let paywall = document.querySelector('section.bck-freemium__wall'); 1879 if (paywall) { 1880 removeDOMElement(paywall); 1881 if (!window.location.search.startsWith('?reason=unauthenticated')) { 1882 window.location.href = window.location.pathname.replace('_preview', '') + '?gaa_at=g'; 1883 } else { 1884 let json_script = getArticleJsonScript(); 1885 let header = document.querySelector('div.content > h2'); 1886 if (json_script) { 1887 let json = JSON.parse(json_script.text); 1888 if (json) { 1889 let json_text = json.articleBody.replace(/(\s{3}| )/g, '\r\n\r\n'); 1890 let content = document.querySelector('div.content > p.has-first-letter'); 1891 if (json_text && content) { 1892 let content_new = document.createElement('p'); 1893 content_new.innerText = json_text; 1894 content.parentNode.replaceChild(content_new, content); 1895 let article_body = document.querySelector('section.body-article'); 1896 if (article_body) 1897 article_body.style = 'height: auto;'; 1898 } else 1899 header_nofix(header); 1900 } 1901 } else 1902 header_nofix(header); 1903 } 1904 } 1905 } else if (window.location.pathname.endsWith('_amp.shtml')) 1906 ampToHtml(); 1907 } 1908 1909 else if (matchDomain('ilfattoquotidiano.it')) { 1910 let url = window.location.href; 1911 if (url.includes('/amp/')) { 1912 amp_unhide_subscr_section('amp-ad, amp-embed, div#_4sVideoContainer'); 1913 let comments = document.querySelector('div.content.comments'); 1914 removeDOMElement(comments); 1915 } else if (window.location.pathname.match(/\/\d{4}\/\d{2}\/\d{2}\//)) { 1916 let paywall = document.querySelector('div.read-more'); 1917 if (paywall) { 1918 removeDOMElement(paywall); 1919 window.location.href = window.location.pathname + 'amp'; 1920 } 1921 } 1922 } 1923 1924 else if (matchDomain('ilfoglio.it')) { 1925 if (window.location.pathname.endsWith('/amp/')) { 1926 amp_unhide_subscr_section('amp-ad, [class^="adv-"], div#gmpVideoContainer'); 1927 } else { 1928 let paywall = document.querySelector('div.paywall'); 1929 let amphtml = document.querySelector('link[rel="amphtml"]'); 1930 if (paywall && amphtml) { 1931 removeDOMElement(paywall); 1932 window.location.href = amphtml.href; 1933 } 1934 let ads = document.querySelectorAll('.advertisement'); 1935 removeDOMElement(...ads); 1936 } 1937 } 1938 1939 else if (matchDomain('ilmanifesto.it')) { 1940 window.setTimeout(function () { 1941 if (window.location.pathname.match(/((\w)+(\-)+){3,}/)) { 1942 let paywall = document.querySelector('div[class^="PostPaywall_PostPaywall__"]'); 1943 if (paywall && dompurify_loaded) { 1944 removeDOMElement(paywall); 1945 let json_script = document.querySelector('script#__NEXT_DATA__'); 1946 if (json_script) { 1947 let json = JSON.parse(json_script.innerText); 1948 if (json && json.props.pageProps.content && json.props.pageProps.content.content) { 1949 let article_new = json.props.pageProps.content.content; 1950 let article = document.querySelector('div.ArticleBody'); 1951 if (article) { 1952 article.innerHTML = ''; 1953 let parser = new DOMParser(); 1954 let doc = parser.parseFromString('<div>' + DOMPurify.sanitize(article_new) + '</div>', 'text/html'); 1955 let content_new = doc.querySelector('div'); 1956 article.appendChild(content_new); 1957 } 1958 } else 1959 window.location.reload(true); 1960 } 1961 } 1962 } 1963 let service_page = document.querySelector('div.service-page'); 1964 if (service_page) { 1965 window.setTimeout(function () { 1966 window.location.reload(true); 1967 }, 1000); 1968 } 1969 }, 1000); 1970 } 1971 1972 else if (matchDomain(['iltirreno.it', 'lanuovasardegna.it']) || matchDomain(['gazzettadimodena.it', 'gazzettadireggio.it', 'lanuovaferrara.it'])) { 1973 if (window.location.pathname.includes('/news/')) { 1974 window.setTimeout(function () { 1975 let banners = document.querySelectorAll('div.MuiSnackbar-root, div.css-16cchgy'); 1976 removeDOMElement(...banners); 1977 }, 1000); 1978 } 1979 } 1980 1981 else if (matchDomain(it_ilmessaggero_domains)) { 1982 if (window.location.pathname.toLowerCase().includes('/amp/')) { 1983 amp_unhide_subscr_section('amp-ad, amp-embed'); 1984 } 1985 } 1986 1987 else if (matchDomain(it_quotidiano_domains)) { 1988 if (window.location.pathname.endsWith('/amp') || window.location.search.startsWith('?amp')) { 1989 amp_unhide_access_hide('="c.customGranted"', '="NOT c.customGranted"', 'amp-ad, amp-embed, amp-fx-flying-carpet, .watermark-adv, .amp__watermark'); 1990 } else { 1991 let paywall = document.querySelector('div[data-testid="paywall-container"], div[class^="Paywall_paywall_"]'); 1992 let amphtml = document.querySelector('link[rel="amphtml"]'); 1993 if (!amphtml) 1994 amphtml = {href: window.location.pathname + '/amp'}; 1995 if (paywall && amphtml) { 1996 removeDOMElement(paywall); 1997 window.location.href = amphtml.href; 1998 } else { 1999 let ads = document.querySelectorAll('div[id^="div-gpt-ad"]'); 2000 removeDOMElement(...ads); 2001 } 2002 } 2003 } 2004 2005 else if (matchDomain('italiaoggi.it')) { 2006 let paywall = document.querySelector('div.boxAbb'); 2007 if (paywall && dompurify_loaded) { 2008 let overlay = document.querySelector('div.article-locked-overlay'); 2009 removeDOMElement(paywall, overlay); 2010 let article_locked = document.querySelector('div.article-locked'); 2011 if (article_locked) { 2012 article_locked.classList.remove('article-locked'); 2013 let json_script = getArticleJsonScript(); 2014 if (json_script) { 2015 let json = JSON.parse(json_script.text); 2016 if (json) { 2017 let json_text = json.articleBody; 2018 let content = article_locked.querySelector('section'); 2019 if (json_text && content) { 2020 let parser = new DOMParser(); 2021 json_text = json_text.replace(/&apos;/g, "'").replace(/;/g, ''); 2022 let doc = parser.parseFromString('<div><section>' + DOMPurify.sanitize(json_text) + '</section></div>', 'text/html'); 2023 let content_new = doc.querySelector('div'); 2024 content.parentNode.replaceChild(content_new, content); 2025 } 2026 } 2027 } 2028 } 2029 } 2030 } 2031 2032 else if (matchDomain(it_gedi_domains)) { 2033 if (matchDomain('espresso.repubblica.it')) { 2034 if (!window.location.pathname.match(/\amp(\/)?$/)) { 2035 let paywall = document.querySelector('div#paywall'); 2036 let amphtml = document.querySelector('link[rel="amphtml"]'); 2037 if (paywall && amphtml) { 2038 removeDOMElement(paywall); 2039 window.location.href = amphtml.href; 2040 } 2041 } else { 2042 amp_unhide_access_hide('="showContent"', '="NOT (showContent)"', 'amp-ad, amp-embed'); 2043 let logo = document.querySelector('div.logo-container > a'); 2044 if (logo) { 2045 logo.innerText = "L'Espresso"; 2046 logo.style.color = 'white'; 2047 } 2048 let placeholders = document.querySelectorAll('figure > amp-img[placeholder][src]'); 2049 for (let elem of placeholders) { 2050 let img = document.createElement('img'); 2051 img.src = elem.getAttribute('src'); 2052 elem.parentNode.replaceChild(img, elem); 2053 } 2054 let inline_videos = document.querySelectorAll('div.video-container > iframe[src]'); 2055 for (let video of inline_videos) { 2056 let elem = document.createElement('a'); 2057 elem.href = video.src; 2058 elem.innerText = '>>> external video-link'; 2059 elem.target = '_blank'; 2060 video.parentNode.replaceChild(elem, video); 2061 } 2062 } 2063 } else { 2064 if (!window.location.pathname.match(/\amp(\/)?$/)) { 2065 let paywall = document.querySelector('div#paywall'); 2066 let ads = document.querySelectorAll('div[id^="adv"]'); 2067 removeDOMElement(paywall, ...ads); 2068 } else 2069 ampToHtml(); 2070 } 2071 } 2072 2073 else if (matchDomain('money.it')) { 2074 if (!window.location.search.startsWith('?page=amp')) { 2075 let paywall = document.querySelector('div#paywall'); 2076 if (paywall) { 2077 removeDOMElement(paywall); 2078 let article_id_dom = document.querySelector('div[data-idarticle]'); 2079 if (article_id_dom) { 2080 let article_id = article_id_dom.getAttribute('data-idarticle'); 2081 window.location.href = 'https://www.money.it/?page=amp&id_article=' + article_id; 2082 } 2083 } 2084 } 2085 } 2086 2087 else 2088 csDone = true; 2089 2090 } else if (window.location.hostname.match(/\.(be|nl)$/) || matchDomain(['artsenkrant.com', 'lavenir.net'])) {//belgium/netherlands 2091 2092 if (matchDomain(be_groupe_ipm_domains)) { 2093 let paywall = document.querySelector('div.is-preview'); 2094 if (paywall) { 2095 paywall.classList.remove('is-preview'); 2096 window.setTimeout(function () { 2097 let div_hidden = document.querySelector('div.is-hidden'); 2098 if (div_hidden) 2099 div_hidden.classList.remove('is-hidden'); 2100 }, 1000); 2101 } 2102 let ads = document.querySelectorAll('div.ap-AdContainer, div.ap-Outbrain'); 2103 hideDOMElement(...ads); 2104 } 2105 2106 else if (matchDomain('fd.nl')) { 2107 let paywall = document.querySelectorAll('section.upsell, div.upsell-modal-background'); 2108 if (paywall.length) 2109 refreshCurrentTab(); 2110 let header = document.querySelector('div.fd-message[data-slot="Artikel/Header"]'); 2111 removeDOMElement(header); 2112 } 2113 2114 else if (matchDomain('ftm.nl')) { 2115 let banners = document.querySelectorAll('div.banner-pp, a.readmore'); 2116 removeDOMElement(...banners); 2117 } 2118 2119 else if (matchDomain(be_roularta_domains)) { 2120 let paywall = document.querySelector('div[id*="wall-modal"]'); 2121 if (paywall) { 2122 removeDOMElement(paywall); 2123 let html = document.querySelector('html[class]'); 2124 if (html) 2125 html.removeAttribute('class'); 2126 function roularta_noscroll(node) { 2127 node.removeAttribute('style'); 2128 node.removeAttribute('class'); 2129 } 2130 waitDOMAttribute('html', 'html', 'class', roularta_noscroll, true); 2131 let intro = document.querySelectorAll('div.article-body > p, div.article-body > style'); 2132 removeDOMElement(...intro); 2133 let locked = document.querySelector('body.locked'); 2134 if (locked) 2135 locked.classList.remove('locked'); 2136 } 2137 if (!window.navigator.userAgent.toLowerCase().includes('chrome') && !matchDomain(['artsenkrant.com', 'kw.be']) && window.location.href.match(/\/((\w)+(\-)+){3,}/)) { 2138 let lazy_images = document.querySelectorAll('[src^="data:image/"][data-lazy-src]'); 2139 for (let elem of lazy_images) { 2140 elem.src = elem.getAttribute('data-lazy-src'); 2141 } 2142 } 2143 let ads = document.querySelectorAll('div.rmgAd'); 2144 hideDOMElement(...ads); 2145 } 2146 2147 else if (matchDomain(['lc.nl', 'dvhn.nl']) || document.querySelector('link[href*=".ndcmediagroep.nl/"]')) { 2148 if (true) { 2149 let paywall = document.querySelector('div.signupPlus, div.pw-wrapper'); 2150 if (paywall && dompurify_loaded) { 2151 let intro = document.querySelector('div.startPayWall'); 2152 removeDOMElement(paywall, intro); 2153 let html = document.documentElement.outerHTML; 2154 if (html.includes('window.__NUXT__=')) { 2155 let json = html.split('window.__NUXT__=')[1].split('</script>')[0].trim(); 2156 let url_nuxt = json.match(/[(,]null,/) ? json.split(/[(,]null,/)[1].match(/\d+\.(html|ece)/)[0] : false; 2157 if (url_nuxt && !window.location.pathname.includes(url_nuxt)) 2158 refreshCurrentTab(); 2159 else if (json.includes(',body:')) { 2160 let json_text = json.split(',body:')[1].split(/,(leadText|brand_key|tts):/)[0].replace(/([{,])([a-zA-Z_0-9]+\d?):/g, "$1\"$2\":").replace(/\":(\[)?([\w\$\.]+)([\]},])/g, "\":$1\"$2\"$3"); 2161 let article = document.querySelector('div.content'); 2162 if (article) { 2163 article.innerHTML = ''; 2164 try { 2165 let pars = JSON.parse(json_text); 2166 function addParText(elem, par_text, add_br = false) { 2167 if (par_text.length > 2) { 2168 let span = document.createElement('span'); 2169 span.innerText = par_text; 2170 elem.appendChild(span); 2171 if (add_br) 2172 elem.appendChild(document.createElement('br')); 2173 } 2174 } 2175 for (let par of pars) { 2176 let elem = document.createElement('p'); 2177 if (par.typename === 'HTMLCustomEmbed') { 2178 if (par.code) { 2179 let parser = new DOMParser(); 2180 let article_html = parser.parseFromString('<div>' + DOMPurify.sanitize(par.code, {ADD_TAGS: ['iframe']}) + '</div>', 'text/html'); 2181 elem = article_html.querySelector('div'); 2182 } 2183 } else if (par.insertbox_head || par.insertbox_text) { 2184 if (par.insertbox_head && par.insertbox_head.length > 2) { 2185 addParText(elem, par.insertbox_head, true); 2186 } 2187 if (par.insertbox_text) { 2188 for (let item of par.insertbox_text) { 2189 if (item.children) { 2190 for (let child of item.children) { 2191 if (child.text) { 2192 addParText(elem, child.text, true); 2193 } else if (child.href && child.href.length > 2) { 2194 let par_link = document.createElement('a'); 2195 par_link.href = child.href; 2196 par_link.innerText = child.children[0].text; 2197 elem.appendChild(par_link); 2198 elem.appendChild(document.createElement('br')); 2199 } else if (child.children) { 2200 for (let sub_child of child.children) { 2201 if (sub_child.text) { 2202 addParText(elem, sub_child.text); 2203 } else if (sub_child.children && sub_child.children.length && sub_child.children[0].text) { 2204 addParText(elem, sub_child.children[0].text); 2205 } 2206 } 2207 } 2208 } 2209 } 2210 } 2211 } 2212 } else if (par.text) { 2213 addParText(elem, par.text); 2214 } else if (par.children) { 2215 for (let child of par.children) { 2216 if (child.relation) { 2217 if (child.type === 'img' && child.relation.href) { 2218 let figure = document.createElement('figure'); 2219 let img = document.createElement('img'); 2220 img.src = child.relation.href; 2221 figure.appendChild(img); 2222 if (child.relation.caption && child.relation.caption.length > 2) { 2223 let caption = document.createElement('figcaption'); 2224 caption.innerText = item.caption; 2225 figure.appendChild(caption); 2226 } 2227 elem.appendChild(figure); 2228 } else if (child.relation.link && child.relation.link.length > 2 && ((child.relation.title && child.relation.title.length > 2) || child.relation.imageAlt)) { 2229 let par_link = document.createElement('a'); 2230 par_link.href = child.relation.link; 2231 par_link.innerText = child.relation.title.length > 2 ? child.relation.title : (child.relation.imageAlt.length > 2 ? child.relation.imageAlt : child.relation.link); 2232 elem.appendChild(par_link); 2233 } 2234 } else if (child.text) { 2235 addParText(elem, child.text); 2236 } else if (child.children && child.children.length && child.children[0].text && child.children[0].text.length > 2) { 2237 if ((child.href && child.href.length > 2) || (child.relation && child.relation.follow && child.relation.follow.url)) { 2238 let par_link = document.createElement('a'); 2239 par_link.href = child.href || child.relation.follow.url; 2240 par_link.innerText = child.children[0].text; 2241 elem.appendChild(par_link); 2242 } else { 2243 addParText(elem, child.children[0].text); 2244 } 2245 } 2246 } 2247 } else if (par.typename.length > 2) 2248 console.log(par); 2249 if (elem.hasChildNodes()) { 2250 article.appendChild(elem); 2251 } 2252 } 2253 } catch (err) { 2254 console.log(err); 2255 } 2256 } 2257 } 2258 } 2259 } 2260 } 2261 let ads = document.querySelectorAll('.top__ad, .marketingblock-article'); 2262 removeDOMElement(...ads); 2263 } 2264 2265 else if (matchDomain(nl_mediahuis_region_domains)) { 2266 window.setTimeout(function () { 2267 let close_button = document.querySelector('button[data-testid="button-close"]'); 2268 if (close_button) 2269 close_button.click(); 2270 let premium = document.querySelector('div.common-components-plus_pluslabel--container'); 2271 if (premium && dompurify_loaded) { 2272 let hidden_article = document.querySelector('div[data-auth-body="article"]'); 2273 if (hidden_article) 2274 hidden_article.removeAttribute('style'); 2275 let paywall = document.querySelector('div[data-auth-root="paywall"]'); 2276 removeDOMElement(paywall); 2277 let auth_body = document.querySelector('div[data-auth-body="article"]'); 2278 if (paywall && auth_body) { 2279 let auth_body_par_count = auth_body.querySelectorAll('p'); 2280 if (auth_body_par_count.length < 2) { 2281 let json_script = document.querySelector('script[data-fragment-type="PacoArticleContent"]'); 2282 let json_str = json_script.text.substring(json_script.textContent.indexOf('{')); 2283 try { 2284 let json = JSON.parse(json_str); 2285 let article = Object.values(json)[0]['data']['article']['body']; 2286 auth_body.innerHTML = ''; 2287 let par_html, par_dom, par_elem, par_div, par_key; 2288 let parser = new DOMParser(); 2289 for (let par of article) { 2290 for (let key in par) { 2291 par_dom = document.createElement('p'); 2292 par_elem = ''; 2293 par_key = par[key]; 2294 if (key === 'subhead') { 2295 par_html = parser.parseFromString('<div><strong>' + DOMPurify.sanitize(par_key) + '</strong></div>', 'text/html'); 2296 par_elem = par_html.querySelector('div'); 2297 } else if (key === 'twitter' || key === 'instagram') { 2298 par_elem = document.createElement('a'); 2299 Object.assign(par_elem, { 2300 href: par_key, 2301 innerText: par_key.split('?')[0], 2302 target: '_blank' 2303 }); 2304 } else if (key === 'youtube') { 2305 par_elem = document.createElement('iframe'); 2306 Object.assign(par_elem, { 2307 src: 'https://www.youtube.com/embed/' + par_key.id, 2308 id: 'ytplayer', 2309 type: 'text/html', 2310 width: 640, 2311 height: 360, 2312 frameborder: 0 2313 }); 2314 } else if (key === 'streamone') { 2315 par_elem = document.createElement('iframe'); 2316 Object.assign(par_elem, { 2317 src: 'https://content.tmgvideo.nl/embed/item=' + par_key.id, 2318 type: 'text/html', 2319 width: 640, 2320 height: 360, 2321 frameborder: 0 2322 }); 2323 } else if (key === 'image') { 2324 par_elem = document.createElement('div'); 2325 let par_img = document.createElement('img'); 2326 par_img.src = par_key.url; 2327 par_elem.appendChild(par_img); 2328 par_div = document.createElement('div'); 2329 par_div.innerText = par[key].caption ? par[key].caption : ''; 2330 par_div.innerText += par[key].credit ? '\n' + par[key].credit : ''; 2331 par_elem.appendChild(par_div); 2332 } else { 2333 par_html = parser.parseFromString('<p style="font-size: 18px; line-height: 1.625;">' + DOMPurify.sanitize(par_key) + '</div>', 'text/html'); 2334 par_elem = par_html.querySelector('p'); 2335 } 2336 if (par_elem) 2337 par_dom.appendChild(par_elem); 2338 auth_body.appendChild(par_dom); 2339 } 2340 } 2341 } catch (err) { 2342 console.warn('unable to parse text'); 2343 console.warn(err); 2344 } 2345 } 2346 } 2347 } 2348 }, 500); 2349 } 2350 2351 else if (matchDomain(nl_dpg_adr_domains.concat(['hln.be']))) { 2352 let url = window.location.href; 2353 let paywall = document.querySelector('div#remaining-paid-content'); 2354 if (paywall) { 2355 removeDOMElement(paywall); 2356 let article = document.querySelector('div.article__body'); 2357 if (article) 2358 article.firstChild.before(archiveLink(url)); 2359 } 2360 } 2361 2362 else if (matchDomain(nl_dpg_media_domains)) { 2363 let banners = document.querySelectorAll('div[data-temptation-position^="PAGE_"], div[class^="ad--"]'); 2364 let paywall = document.querySelectorAll('[data-temptation-position^="ARTICLE_"]'); 2365 removeDOMElement(...banners, ...paywall); 2366 } 2367 2368 else if (matchDomain('nrc.nl')) { 2369 let banners = document.querySelectorAll('div[id$="modal__overlay"], div.header__subscribe-bar, div.banner'); 2370 removeDOMElement(...banners); 2371 } 2372 2373 else if (matchDomain('telegraaf.nl')) { 2374 if (window.location.href.startsWith('https://www.telegraaf.nl/error?ref=/')) { 2375 window.setTimeout(function () { 2376 window.location.href = window.location.href.split('&')[0].replace('error?ref=/', ''); 2377 }, 500); 2378 } 2379 let refresh = document.querySelector('div[id="content"] > meta[http-equiv="refresh"]'); 2380 if (refresh) { 2381 window.setTimeout(function () { 2382 window.location.reload(true); 2383 }, 500); 2384 } 2385 let paywall = document.querySelector('div.MeteringNotification__backdrop, data-hydrate[data-name="PaywallHandler"]'); 2386 let article_body = document.querySelector('div.DetailBodyBlocks, section.TextArticlePage__imageWrapper, section > div.DetailArticleImage'); 2387 if (paywall && article_body) { 2388 let div_main = document.createElement('div'); 2389 div_main.style = 'margin: 20px 0px;'; 2390 let div_elem = document.createElement('div'); 2391 let par_style = 'font-weight: normal; font-size: 16px; line-height: 1.5;'; 2392 let scripts = document.querySelectorAll('script:not([src]):not([type])'); 2393 let apollo_script; 2394 for (let script of scripts) { 2395 if (script.text.includes('window.__APOLLO_STATE__=')) { 2396 apollo_script = script; 2397 break; 2398 } 2399 } 2400 if (apollo_script) { 2401 removeDOMElement(paywall); 2402 try { 2403 let apollo_json = JSON.parse(apollo_script.text.replace(/(^window.__APOLLO_STATE__=|;$)/g, '')); 2404 let start = false; 2405 for (let key in apollo_json) { 2406 let elem = apollo_json[key]; 2407 if (!start) { 2408 if (key.includes('.introBlocks.')) 2409 start = true; 2410 } else { 2411 let typename = elem.__typename; 2412 if (key.startsWith('Article:') || ['ArticleAuthorBiography'].includes(typename)) 2413 break; 2414 else { 2415 let par = document.createElement('p'); 2416 if (typename === 'HtmlBlock') { 2417 let item = document.createElement('p'); 2418 item.innerText = elem.contentHTML.replace(/((<|\\u003c)([^>]+)(>|\\u003e))/gi, ''); 2419 item.style = par_style; 2420 par.appendChild(item); 2421 } else if (typename === 'SubheadBlock') { 2422 let item = document.createElement('p'); 2423 item.innerText = elem.text.replace(/((<|\\u003c)([^>]+)(>|\\u003e))/gi, ''); 2424 item.style = par_style; 2425 par.appendChild(item); 2426 } else if (typename === 'Image') { 2427 let figure = document.createElement('figure'); 2428 let img = document.createElement('img'); 2429 img.src = elem.url.startsWith('https:') ? elem.url : 'https:' + elem.url; 2430 img.width = !mobile ? 640 : 320; 2431 figure.appendChild(img); 2432 if (elem.description) { 2433 let caption = document.createElement('figcaption'); 2434 caption.innerText = elem.description + (elem.copyright ? ' | ' + elem.copyright : ''); 2435 figure.appendChild(caption); 2436 } 2437 par.appendChild(figure); 2438 } else if (typename === 'Article') { 2439 let item = document.createElement('a'); 2440 item.href = elem.url.startsWith('https:') ? elem.url : 'https:' + elem.url; 2441 item.innerText = elem.title; 2442 par.appendChild(item); 2443 } else if (!['ImageBlock', 'InlineRelatedArticlesBlock', 'Video', 'Webshop'].includes(typename)) 2444 console.log(elem); 2445 if (par.childNodes) { 2446 div_main.appendChild(par); ; 2447 } 2448 } 2449 } 2450 } 2451 } catch (err) { 2452 console.log(err); 2453 } 2454 } else { 2455 let json_script = getArticleJsonScript(); 2456 if (json_script) { 2457 removeDOMElement(paywall); 2458 try { 2459 let json = JSON.parse(json_script.text); 2460 if (json) { 2461 let json_text = json.articleBody; 2462 if (json_text) { 2463 let intro = document.querySelector('span[id^="articleIntro"], p.Article__intro > span'); 2464 if (intro) 2465 json_text = json_text.replace(intro.innerText + '\n\n', ''); 2466 let text_array = json_text.split('\\n'); 2467 text_array.forEach(p_text => { 2468 let p_div = document.createElement('p'); 2469 p_div.innerText = p_text; 2470 p_div.style = par_style; 2471 div_elem.appendChild(p_div); 2472 }); 2473 div_main.appendChild(div_elem); 2474 } 2475 } 2476 } catch (err) { 2477 console.log(err); 2478 } 2479 } 2480 } 2481 article_body.after(div_main); 2482 } 2483 let banners = document.querySelectorAll('.ArticleBodyBlocks__inlineArticleSpotXBanner, .WebpushOptin'); 2484 removeDOMElement(...banners); 2485 } 2486 2487 else if (matchDomain('vn.nl')) { 2488 let paywall = document.querySelector('div.content__message-no-access-container'); 2489 if (paywall && dompurify_loaded) { 2490 let content_restriction = document.querySelector('div.content__restriction'); 2491 removeDOMElement(paywall, content_restriction); 2492 let body = document.querySelector('body'); 2493 if (body) 2494 body.style = 'height:auto !important;'; 2495 let article_content = document.querySelector('section[data-article-content-element]'); 2496 if (article_content) 2497 article_content.style = 'max-height:none !important;'; 2498 let json_url_dom = document.querySelector('link[rel="alternate"][type="application/json"][href]'); 2499 if (json_url_dom) { 2500 let json_url = json_url_dom.href; 2501 fetch(json_url) 2502 .then(response => { 2503 if (response.ok) { 2504 response.json().then(json => { 2505 let json_text = json.content.rendered; 2506 let content = document.querySelector('div[data-article-content-target]'); 2507 if (json_text && content) { 2508 let parser = new DOMParser(); 2509 let doc = parser.parseFromString('<div data-article-content-target>' + DOMPurify.sanitize(json_text, {ADD_TAGS: ['iframe'], ADD_ATTR: ['frameborder']}) + '</div>', 'text/html'); 2510 let content_new = doc.querySelector('div'); 2511 content.parentNode.replaceChild(content_new, content); 2512 } 2513 }); 2514 } 2515 }); 2516 } 2517 } 2518 } 2519 2520 else 2521 csDone = true; 2522 2523 } else if (window.location.hostname.match(/\.(ie|uk)$/) || matchDomain(['citywire.com', 'ft.com', 'scotsman.com', 'tes.com'])) {//united kingdom/ireland 2524 2525 if (matchDomain('autocar.co.uk')) { 2526 let url = window.location.href; 2527 let paywall = document.querySelector('div.ms-block, div.register-block'); 2528 if (paywall) { 2529 removeDOMElement(paywall); 2530 csDoneOnce = true; 2531 let url_cache = 'https://webcache.googleusercontent.com/search?q=cache:' + url.split('?')[0]; 2532 replaceDomElementExt(url_cache, true, false, 'div.content-wrapper'); 2533 } 2534 } 2535 2536 else if (matchDomain(['belfasttelegraph.co.uk', 'independent.ie'])) { 2537 let flip_pay = document.querySelector('div#flip-pay[style]'); 2538 if (flip_pay && dompurify_loaded) { 2539 let content = document.querySelector('script[data-fragment-type="ArticleContent"]'); 2540 if (content) { 2541 removeDOMElement(flip_pay); 2542 let intro = document.querySelector('div[data-auth-intro="article"]'); 2543 if (intro && intro.parentNode) { 2544 let content_text = content.innerText; 2545 if (content_text.includes('__PRELOADED_STATE_GRAPH')) { 2546 content_text = content_text.replace(/window\["__PRELOADED_STATE_GRAPH__.+"\]\s=\s/, ''); 2547 try { 2548 let json = JSON.parse(content_text); 2549 if (Object.keys(json).length) { 2550 let key = Object.keys(json)[0]; 2551 let pars = json[key].data.article.body; 2552 let parser = new DOMParser(); 2553 for (let par of pars) { 2554 for (let type in par) { 2555 let item = par[type]; 2556 let elem = document.createElement('p'); 2557 elem.setAttribute('style', "margin: 10px;"); 2558 if (type === 'bullet_list') { 2559 let ul = document.createElement('ul'); 2560 for (let sub_item of item) { 2561 let li = document.createElement('li'); 2562 li.innerText = sub_item; 2563 ul.appendChild(li); 2564 } 2565 elem.appendChild(ul); 2566 } else if (type === 'image') { 2567 let figure = document.createElement('figure'); 2568 let img = document.createElement('img'); 2569 img.src = item.url; 2570 figure.appendChild(img); 2571 let caption = document.createElement('figcaption'); 2572 caption.innerText = item.caption; 2573 figure.appendChild(caption); 2574 elem.appendChild(figure); 2575 } else if (type === 'related') { 2576 if (item.articles) { 2577 let articles = item.articles; 2578 for (let article of articles) { 2579 let elem_link = document.createElement('a'); 2580 elem_link.href = article.webcmsRelativeUrl; 2581 elem_link.innerText = article.title; 2582 elem.appendChild(elem_link); 2583 elem.appendChild(document.createElement('br')); 2584 } 2585 } 2586 } else if (type !== 'ad') { 2587 let html = parser.parseFromString('<p style="font-size: 18px; font-family: Georgia, serif; margin: 10px;">' + DOMPurify.sanitize(item, {ADD_TAGS: ['iframe']}) + '</p>', 'text/html'); 2588 elem = html.querySelector('p'); 2589 if (!['p', 'subhead', 'legacy-ml'].includes(type)) { 2590 console.log(type); 2591 console.log(item); 2592 } 2593 } 2594 window.setTimeout(function () { 2595 if (elem) 2596 intro.parentNode.appendChild(elem); 2597 }, 500); 2598 } 2599 } 2600 } 2601 } catch (err) { 2602 console.log(err); 2603 } 2604 } 2605 } 2606 } else 2607 flip_pay.removeAttribute('style'); 2608 } 2609 let ads = document.querySelectorAll('div[id^="ad_article"]'); 2610 hideDOMElement(...ads); 2611 } 2612 2613 else if (matchDomain('businesspost.ie')) { 2614 function bpie_main() { 2615 if ($) { 2616 let article_id_dom = document.querySelector('article[id]'); 2617 let article_id; 2618 if (article_id_dom) 2619 article_id = article_id_dom.id; 2620 if (article_id) { 2621 let bp_ajaxurl = 'https://www.businesspost.ie/wp-admin/admin-ajax.php'; 2622 let data_ajax = { 2623 action: 'fetch_article_content', 2624 type: 'POST', 2625 data: { 2626 id: article_id 2627 }, 2628 dataType: 'json', 2629 contentType: 'application/json' 2630 }; 2631 $.ajax({ 2632 type: 'POST', 2633 url: bp_ajaxurl, 2634 data: data_ajax, 2635 success: function (data) { 2636 window.postMessage({type: 'from_page', data: data}); 2637 } 2638 }); 2639 } 2640 } else 2641 window.location.reload(true); 2642 } 2643 csDoneOnce = true; 2644 window.setTimeout(function () { 2645 let paywall = document.querySelector('div#bp_paywall_content'); 2646 let article_id_dom = document.querySelector('article[id]'); 2647 let article_id; 2648 if (article_id_dom) 2649 article_id = article_id_dom.id; 2650 if (paywall || article_id) { 2651 removeDOMElement(paywall); 2652 insert_script(bpie_main); 2653 } 2654 }, 500); 2655 } 2656 2657 else if (matchDomain('citywire.com')) { 2658 let url = window.location.href; 2659 let paywall = document.querySelector('div.locked-content.cw-article-body'); 2660 if (paywall) { 2661 paywall.classList.remove('locked-content'); 2662 csDoneOnce = true; 2663 let url_cache = 'https://webcache.googleusercontent.com/search?q=cache:' + url.split('?')[0]; 2664 replaceDomElementExt(url_cache, true, false, 'div.cw-article-body'); 2665 } 2666 window.setTimeout(function () { 2667 let banner = document.querySelector('div#lockedLoginPanel'); 2668 removeDOMElement(banner); 2669 let article = document.querySelector('div.cw-article-body'); 2670 if (article) 2671 removeDOMElement(article.nextSibling); 2672 }, 1000); 2673 } 2674 2675 else if (matchDomain('ft.com')) { 2676 if (window.location.hostname.startsWith('amp.')) { 2677 amp_unhide_subscr_section('.ad-container, amp-ad'); 2678 } else { 2679 let banners = document.querySelectorAll('.o-cookie-message, .js-article-ribbon, .o-ads, .o-banner'); 2680 removeDOMElement(...banners); 2681 } 2682 } 2683 2684 else if (matchDomain('independent.co.uk')) { 2685 let url = window.location.href; 2686 if (window.location.search.match(/(\?|&)amp/)) { 2687 let ads = document.querySelectorAll('amp-ad, amp-embed, [id^="ad-"]'); 2688 removeDOMElement(...ads); 2689 } else { 2690 let paywall = document.querySelector('div.article-premium'); 2691 let related = document.querySelector('div.related'); 2692 let msg = document.querySelector('div#bpc_archive'); 2693 if (paywall && !related && !msg) { 2694 paywall.classList.remove('article-premium'); 2695 let article = document.querySelector('div#main'); 2696 if (article) 2697 article.firstChild.before(archiveLink(url)); 2698 } 2699 } 2700 } 2701 2702 else if (matchDomain('prospectmagazine.co.uk')) { 2703 let url = window.location.href; 2704 let paywall = document.querySelector('div.paywall_overlay_blend, div.paywall'); 2705 if (paywall) { 2706 removeDOMElement(paywall); 2707 csDoneOnce = true; 2708 let url_cache = 'https://webcache.googleusercontent.com/search?q=cache:' + url.split('?')[0]; 2709 replaceDomElementExt(url_cache, true, false, 'main'); 2710 } 2711 window.setTimeout(function () { 2712 let ads = document.querySelectorAll('.ad-banner, .advert'); 2713 removeDOMElement(...ads); 2714 }, 1000); 2715 } 2716 2717 else if (matchDomain('spectator.co.uk')) { 2718 let banner = document.querySelector('#subscribe-ribbon'); 2719 removeDOMElement(banner); 2720 } 2721 2722 else if (matchDomain('stylist.co.uk')) { 2723 let paywall = document.querySelector('div.css-1agpii8'); 2724 if (paywall) { 2725 removeDOMElement(paywall); 2726 let json_script = document.querySelector('script#__NEXT_DATA__'); 2727 if (json_script) { 2728 try { 2729 let json = JSON.parse(json_script.text); 2730 if (json.props.pageProps.data.post.acf.widgets) { 2731 let url_next = json.props.pageProps.data.post.id; 2732 if (url_next && !window.location.pathname.endsWith(url_next)) 2733 refreshCurrentTab(); 2734 let pars = json.props.pageProps.data.post.acf.widgets; 2735 let first_par = document.querySelector('p.css-12ac4a9'); 2736 if (first_par) { 2737 let par_class = first_par.getAttribute('class'); 2738 let article = first_par.parentNode; 2739 let teaser = article.querySelectorAll('div.css-1q9dbt6 > p'); 2740 removeDOMElement(...teaser); 2741 if (article) { 2742 let parser = new DOMParser(); 2743 for (let par of pars) { 2744 let elem = document.createElement('p'); 2745 elem.style = 'font-family: "Source Serif Pro"; font-size: 20px; line-height: 34px;'; 2746 if (par.paragraph) { 2747 let content = par.paragraph; 2748 let content_new = parser.parseFromString('<div class="css-1q9dbt6">' + DOMPurify.sanitize(content) + '</div>', 'text/html'); 2749 elem = content_new.querySelector('div'); 2750 } else if (par.acf_fc_layout === 'heading') { 2751 if (par.text) 2752 elem.appendChild(document.createTextNode(par.text)); 2753 } else if (par.image) { 2754 let figure = document.createElement('figure'); 2755 let img = document.createElement('img'); 2756 img.src = par.image.url; 2757 img.alt = par.image.alt; 2758 img.style = mobile ? 'width: 320px;' : 'width: 640px;'; 2759 figure.appendChild(img); 2760 if (par.image.caption || par.image.description) { 2761 let caption = document.createElement('figcaption'); 2762 caption.innerText = par.image.caption + ' ' + par.image.description; 2763 figure.appendChild(caption); 2764 } 2765 elem.appendChild(figure); 2766 } else if (par.acf_fc_layout === 'listicle') { 2767 let ul = document.createElement('ul'); 2768 for (let sub_item of par.item) { 2769 let li = document.createElement('li'); 2770 if (sub_item.url) { 2771 let par_link = document.createElement('a'); 2772 par_link.href = sub_item.url; 2773 par_link.innerText = sub_item.title; 2774 par_link.target = '_blank'; 2775 li.appendChild(par_link); 2776 } else 2777 li.innerText = sub_item.title; 2778 if (sub_item.paragraph) { 2779 let content = sub_item.paragraph; 2780 let content_new = parser.parseFromString('<div class="css-1q9dbt6">' + DOMPurify.sanitize(content) + '</div>', 'text/html'); 2781 let par_elem = content_new.querySelector('div'); 2782 li.appendChild(par_elem); 2783 } 2784 if (sub_item.image) { 2785 let img = document.createElement('img'); 2786 img.src = sub_item.image.url; 2787 img.alt = sub_item.image.alt; 2788 img.style = mobile ? 'width: 320px;' : 'width: 640px;'; 2789 li.appendChild(img); 2790 li.appendChild(document.createElement('br')); 2791 } 2792 li.style = 'font-size: 20px; margin: 20px 0px;'; 2793 ul.appendChild(li); 2794 } 2795 elem.appendChild(ul); 2796 } else if (par.embed_link) { 2797 let par_link = document.createElement('a'); 2798 par_link.href = par.embed_link; 2799 par_link.innerText = 'Embedded link: ' + par.embed_link; 2800 par_link.target = '_blank'; 2801 elem.appendChild(par_link); 2802 } else if (par.acf_fc_layout === 'divider') { 2803 elem.appendChild(document.createElement('hr')); 2804 } else if (par.acf_fc_layout === 'related_articles') { 2805 if (par.posts) { 2806 for (let post of par.posts) { 2807 if (post.link && post.title.rendered) { 2808 let par_link = document.createElement('a'); 2809 par_link.href = post.link; 2810 par_link.innerText = 'You may also like: ' + post.title.rendered; 2811 elem.appendChild(par_link); 2812 elem.appendChild(document.createElement('br')); 2813 } 2814 } 2815 } 2816 } else if (!['newsletter_signup', 'pull-quote'].includes(par.acf_fc_layout)) 2817 console.log(par); 2818 if (elem.hasChildNodes) 2819 article.appendChild(elem); 2820 } 2821 let div_nostyle = document.querySelectorAll('div.css-1q9dbt6 > *'); 2822 for (let elem of div_nostyle) 2823 elem.style = 'font-family: "Source Serif Pro"; font-size: 20px; line-height: 34px;'; 2824 } 2825 } 2826 } 2827 } catch (err) { 2828 console.log(err); 2829 } 2830 } 2831 } 2832 } 2833 2834 else if (matchDomain('telegraph.co.uk')) { 2835 if (window.location.pathname.endsWith('/amp/')) { 2836 let paywall = document.querySelectorAll('.premium-paywall'); 2837 if (paywall.length) { 2838 let truncated_content = document.querySelector('.truncated-content'); 2839 removeDOMElement(...paywall, truncated_content); 2840 amp_unhide_access_hide('="c.result=\'ALLOW_ACCESS\'"', '', 'amp-ad, amp-embed', false); 2841 } else { 2842 let amp_ads = document.querySelectorAll('amp-ad, amp-embed'); 2843 removeDOMElement(...amp_ads); 2844 } 2845 } else { 2846 let subwall = document.querySelectorAll('[class^="subwall"]'); 2847 let ads = document.querySelectorAll('.advert, .commercial-unit'); 2848 removeDOMElement(...subwall, ...ads); 2849 } 2850 } 2851 2852 else if (matchDomain('tes.com')) { 2853 let banner = document.querySelector('div.js-paywall-info'); 2854 removeDOMElement(banner); 2855 } 2856 2857 else if (matchDomain('the-tls.co.uk')) { 2858 let paywall = document.querySelector('.tls-single-article__closed-paywall'); 2859 if (paywall && dompurify_loaded) { 2860 removeDOMElement(paywall); 2861 let json_url_dom = document.querySelector('link[rel="alternate"][type="application/json"][href]'); 2862 let json_url = json_url_dom.href; 2863 fetch(json_url) 2864 .then(response => { 2865 if (response.ok) { 2866 response.json().then(json => { 2867 let json_text = json.content.rendered; 2868 let content = document.querySelector('div.tls-article-body'); 2869 if (json_text && content) { 2870 let parser = new DOMParser(); 2871 let doc = parser.parseFromString('<div class="tls-article-body">' + DOMPurify.sanitize(json_text) + '</div>', 'text/html'); 2872 let content_new = doc.querySelector('div'); 2873 content.parentNode.replaceChild(content_new, content); 2874 } 2875 }); 2876 } 2877 }); 2878 } 2879 let fade = document.querySelector('div.tls-single-article__closed-paywall-wrapper'); 2880 removeDOMElement(fade); 2881 } 2882 2883 else if (matchDomain('theneweuropean.co.uk')) { 2884 let paywall = document.querySelector('div[data-show-fade-on-noaccess]'); 2885 if (paywall) { 2886 removeDOMElement(paywall); 2887 let content = document.querySelector('div[data-show-has-access]'); 2888 if (content) 2889 content.removeAttribute('data-show-has-access'); 2890 } 2891 let banners = document.querySelectorAll('div[data-show-subs-blocked]'); 2892 removeDOMElement(...banners); 2893 } 2894 2895 else if (matchDomain('thetimes.co.uk')) { 2896 let url = window.location.href; 2897 if (window.location.hostname !== 'epaper.thetimes.co.uk') { 2898 let paywall = document.querySelector('div#paywall-portal-article-footer'); 2899 if (paywall && !url.includes('?shareToken=')) { 2900 removeDOMElement(paywall); 2901 let article = document.querySelector('article[class^="responsive__BodyContainer"]'); 2902 if (article) 2903 article.firstChild.before(archiveLink(url)); 2904 waitDOMAttribute('body', 'BODY', 'style', node => node.removeAttribute('style'), true); 2905 waitDOMAttribute('html', 'HTML', 'style', node => node.removeAttribute('style'), true); 2906 } 2907 let paywall_page = document.querySelector('div#paywall-portal-page-footer'); 2908 let block = document.querySelector('.subscription-block'); 2909 let ads = document.querySelectorAll('#ad-article-inline, #sticky-ad-header, div[class*="InlineAdWrapper"], div[class*="NativeAd"], div.gyLkkj'); 2910 removeDOMElement(paywall_page, block, ...ads); 2911 } 2912 } 2913 2914 else if (matchDomain(uk_nat_world_domains) || document.querySelector('footer > div a[href^="https://www.nationalworldplc.com"]')) { 2915 let premium = document.querySelector('div.premium'); 2916 if (premium) 2917 premium.removeAttribute('class'); 2918 let amp_images = document.querySelectorAll('article amp-img[src^="https://"]'); 2919 for (let amp_image of amp_images) { 2920 let elem = document.createElement('img'); 2921 Object.assign(elem, { 2922 src: amp_image.getAttribute('src'), 2923 alt: amp_image.getAttribute('alt') 2924 }); 2925 amp_image.parentNode.replaceChild(elem, amp_image); 2926 } 2927 let ads = document.querySelectorAll('div[class^="MarkupAds__Container-"], div[class*="_AdContainer-"], div[class^="Dailymotion__Wrapper-"], div.OUTBRAIN'); 2928 removeDOMElement(...ads); 2929 } 2930 2931 else 2932 csDone = true; 2933 2934 } else if (window.location.hostname.match(/\.(ar|br|cl|pe|uy)$/) || matchDomain(['clarin.com', 'elespectador.com', 'elmercurio.com', 'eltiempo.com', 'eltribuno.com', 'globo.com', 'lasegunda.com', 'latercera.com'])) {//south america 2935 2936 if (matchDomain('abril.com.br')) { 2937 if (window.location.pathname.endsWith('/amp/')) { 2938 let paywall = document.querySelector('.piano-modal'); 2939 let amp_ads = document.querySelectorAll('amp-ad, amp-embed'); 2940 removeDOMElement(paywall, ...amp_ads); 2941 } else { 2942 let ads = document.querySelectorAll('div.ads, div[class^="ads-"]'); 2943 hideDOMElement(...ads); 2944 } 2945 } 2946 2947 else if (matchDomain(ar_grupo_clarin_domains)) { 2948 let ads = document.querySelectorAll('.ad-slot, .box-adv, .sticky, .wrapperblock'); 2949 removeDOMElement(...ads); 2950 } 2951 2952 else if (matchDomain('crusoe.uol.com.br')) { 2953 let ads = document.querySelectorAll('#gpt-leaderboard, .ads_desktop, .catchment-box'); 2954 removeDOMElement(...ads); 2955 } 2956 2957 else if (matchDomain(pe_grupo_elcomercio_domains)) { 2958 let paywall = document.querySelector('.paywall'); 2959 if (paywall) { 2960 paywall.removeAttribute('class'); 2961 paywall.removeAttribute('style'); 2962 let fade = document.querySelector('p.story-contents--fade'); 2963 if (fade) 2964 fade.classList.remove('story-contents--fade'); 2965 } 2966 let ads = document.querySelectorAll('div[class^="content_gpt"]'); 2967 removeDOMElement(...ads); 2968 } 2969 2970 else if (matchDomain('elespectador.com')) { 2971 if (window.location.search.match(/(\?|&)outputType=amp/)) { 2972 amp_unhide_subscr_section('amp-ad, amp-embed, [class^="Widget"], amp-fx-flying-carpet'); 2973 } else { 2974 let paywall = document.querySelector('div.exclusive_validation'); 2975 let amphtml = document.querySelector('link[rel="amphtml"]'); 2976 if (paywall && amphtml) { 2977 removeDOMElement(paywall); 2978 window.location.href = amphtml.href; 2979 } 2980 } 2981 } 2982 2983 else if (matchDomain('elmercurio.com')) { 2984 window.setTimeout(function () { 2985 let elem_hidden = document.querySelectorAll('[style="visibility:hidden"]'); 2986 for (let elem of elem_hidden) 2987 elem.removeAttribute('style'); 2988 let page_pdf_content = document.querySelector('div.page_pdf_content'); 2989 let close_html = document.querySelector('div.close_html'); 2990 let cont_page_full = document.querySelector('div.cont_page_full'); 2991 removeDOMElement(page_pdf_content, close_html, cont_page_full); 2992 }, 1000); 2993 window.setTimeout(function () { 2994 let cont_articlelight = document.querySelector('div.cont_articlelight'); 2995 if (cont_articlelight) 2996 cont_articlelight.setAttribute('style', 'height: 100% !important; width: 90% !important'); 2997 }, 3000); 2998 } 2999 3000 else if (matchDomain('elobservador.com.uy')) { 3001 if (window.location.pathname.endsWith('/amp')) { 3002 amp_unhide_access_hide('="observador.mostrarNota"'); 3003 let amp_images = document.querySelectorAll('div.fixed-container > amp-img.null'); 3004 for (let amp_image of amp_images) { 3005 let elem = document.createElement('img'); 3006 Object.assign(elem, { 3007 src: amp_image.getAttribute('src'), 3008 alt: amp_image.getAttribute('alt'), 3009 title: amp_image.getAttribute('title') 3010 }); 3011 amp_image.parentNode.replaceChild(elem, amp_image); 3012 } 3013 } else { 3014 let paywall = document.querySelector('div.mensaje_member'); 3015 if (paywall) { 3016 removeDOMElement(paywall); 3017 window.location.href = window.location.pathname + '/amp'; 3018 } 3019 } 3020 } 3021 3022 else if (matchDomain('eltiempo.com')) { 3023 let modulos = document.querySelector('div.modulos'); 3024 if (modulos) 3025 modulos.classList.remove('modulos'); 3026 } 3027 3028 else if (matchDomain('eltribuno.com')) { 3029 let lazy_images = document.querySelectorAll('img.lazyload[data-src]:not([src])'); 3030 for (let elem of lazy_images) { 3031 elem.src = elem.getAttribute('data-src'); 3032 elem.classList.remove('lazyload'); 3033 } 3034 } 3035 3036 else if (matchDomain('em.com.br')) { 3037 if (!window.location.pathname.endsWith('/amp.html')) { 3038 let paywall = document.querySelector('.news-blocked-content'); 3039 let amphtml = document.querySelector('link[rel="amphtml"]'); 3040 if (paywall && amphtml) { 3041 removeDOMElement(paywall); 3042 window.location.href = amphtml.href; 3043 } 3044 let ads = document.querySelectorAll('.ads, .containerads'); 3045 removeDOMElement(...ads); 3046 } else { 3047 amp_unhide_subscr_section('amp-ad, amp-embed, amp-fx-flying-carpet'); 3048 let compress_text = document.querySelector('div.compress-text'); 3049 if (compress_text) 3050 compress_text.classList.remove('compress-text'); 3051 } 3052 } 3053 3054 else if (matchDomain('estadao.com.br')) { 3055 if (window.location.pathname.match(/(\.amp$|^\/amp\/)/) || window.location.search.startsWith('?amp')) { 3056 amp_unhide_access_hide('="outputValue=\'hide_paywall\'"', '="outputValue=\'show_paywall\'"', 'amp-ad, amp-embed, amp-fx-flying-carpet, div[class^="pAd"]'); 3057 } else { 3058 let paywall = document.getElementById('paywall-wrapper-iframe-estadao'); 3059 let ads = document.querySelectorAll('div[class^="styles__Container-sc-"]'); 3060 removeDOMElement(paywall, ...ads); 3061 } 3062 } 3063 3064 else if (matchDomain('folha.uol.com.br')) { 3065 if (matchDomain('piaui.folha.uol.com.br')) { 3066 if (window.location.search.startsWith('?amp')) { 3067 amp_unhide_subscr_section(); 3068 } else { 3069 let paywall = document.querySelector('.revista--interna__assineonly'); 3070 let amphtml = document.querySelector('link[rel="amphtml"]'); 3071 if (paywall && amphtml) { 3072 removeDOMElement(paywall); 3073 window.location.href = amphtml.href; 3074 } 3075 } 3076 } else { 3077 if (window.location.pathname.startsWith('/amp/')) { 3078 amp_unhide_subscr_section('amp-ad, amp-sticky-ad, amp-embed'); 3079 } else { 3080 let signup = document.querySelector('.c-top-signup'); 3081 removeDOMElement(signup); 3082 } 3083 } 3084 } 3085 3086 else if (matchDomain('blogfolha.uol.com.br')) { 3087 let hidden_images = document.querySelectorAll('div[id^="attachment_"] > a > img[src^="http:"][srcset]'); 3088 for (let hidden_image of hidden_images) { 3089 hidden_image.src = hidden_image.src.replace('http:', 'https:'); 3090 hidden_image.srcset = ''; 3091 } 3092 } 3093 3094 else if (matchDomain('gauchazh.clicrbs.com.br')) { 3095 let ads = document.querySelectorAll('div.ad-banner, div.ad-container'); 3096 hideDOMElement(...ads); 3097 } 3098 3099 else if (matchDomain('ladiaria.com.uy')) { 3100 if (window.location.search.startsWith('?display=amp')) { 3101 csDoneOnce = true; 3102 ampToHtml(); 3103 } else { 3104 let banners = document.querySelectorAll('div.softwall, div.subscribe-notice'); 3105 removeDOMElement(...banners); 3106 } 3107 } 3108 3109 else if (matchDomain('latercera.com')) { 3110 let subscr_banner = document.querySelector('.empty'); 3111 removeDOMElement(subscr_banner); 3112 } 3113 3114 else if (matchDomain('lasegunda.com')) { 3115 let url = window.location.href; 3116 if (url.includes('digital.lasegunda.com/mobile')) { 3117 let lessreadmore = document.querySelectorAll('article.lessreadmore'); 3118 for (let article of lessreadmore) 3119 article.classList.remove('lessreadmore'); 3120 let bt_readmore = document.querySelectorAll('div[id*="bt_readmore_"]'); 3121 removeDOMElement(...bt_readmore); 3122 } 3123 } 3124 3125 else if (matchDomain('globo.com')) { 3126 if (matchDomain('valor.globo.com')) { 3127 if (!window.location.pathname.startsWith('/google/amp/')) { 3128 let paywall = document.querySelector('div.paywall'); 3129 let amphtml = document.querySelector('link[rel="amphtml"]'); 3130 if (paywall && amphtml) { 3131 removeDOMElement(paywall); 3132 window.location.href = amphtml.href; 3133 } 3134 } else { 3135 amp_unhide_subscr_section('amp-ad, amp-embed'); 3136 let amp_images = document.querySelectorAll('figure > amp-img[src^="https://"]'); 3137 for (let amp_image of amp_images) { 3138 let elem = document.createElement('img'); 3139 elem.src = amp_image.getAttribute('src'); 3140 elem.alt = amp_image.getAttribute('alt'); 3141 elem.style = mobile ? 'width: 320px;' : 'margin: 0px 250px; display:block;'; 3142 amp_image.parentNode.replaceChild(elem, amp_image); 3143 } 3144 } 3145 } else if (window.location.pathname.includes('/amp/')) 3146 ampToHtml(); 3147 if (!window.location.pathname.includes('/amp/')) { 3148 let ads = document.querySelectorAll('div[id^="ad-container"], div.content-ads, div[class^="block__advertising"]'); 3149 removeDOMElement(...ads); 3150 } 3151 } 3152 3153 else if (window.location.hostname.endsWith('.cl') && document.querySelector('meta[property="og:image"][content*="://impresa.soy-chile.cl/"]')) { 3154 window.setTimeout(function () { 3155 let content = document.querySelector('div.content'); 3156 if (content) 3157 content.setAttribute('id', 'content_new'); 3158 let modal_wrapper = document.querySelector('div.modal-wrapper'); 3159 removeDOMElement(modal_wrapper); 3160 }, 1000); 3161 waitDOMAttribute('body', 'BODY', 'class', node => node.removeAttribute('class'), true); 3162 csDoneOnce = true; 3163 } 3164 3165 else 3166 csDone = true; 3167 3168 } else {//other (like com/org & not at/be/br/ch/cl/de/dk/fi/fr/es/ie/nl/no/pe/pt/se/uk)) 3169 3170 if (matchDomain(usa_adv_local_domains)) { 3171 let url = window.location.href; 3172 if (url.includes('?outputType=amp')) { 3173 let amp_ads = document.querySelectorAll('.amp-ad-container, amp-embed'); 3174 removeDOMElement(...amp_ads); 3175 } else { 3176 let paywall = document.querySelector('.paywall'); 3177 let amphtml = document.querySelector('link[rel="amphtml"]'); 3178 if (!amphtml) 3179 amphtml = {href: window.location.pathname + '?outputType=amp'}; 3180 if (paywall && amphtml) { 3181 removeDOMElement(paywall); 3182 window.location.href = amphtml.href; 3183 } 3184 let ads = document.querySelectorAll('div.ad'); 3185 removeDOMElement(...ads); 3186 } 3187 } 3188 3189 else if (matchDomain('americanbanker.com') || matchDomain(usa_arizent_custom_domains)) { 3190 let inline_gate = document.querySelector('.inline-gate'); 3191 if (inline_gate) { 3192 inline_gate.classList.remove('inline-gate'); 3193 let inline_gated = document.querySelectorAll('.inline-gated'); 3194 for (let elem of inline_gated) 3195 elem.classList.remove('inline-gated'); 3196 } 3197 } 3198 3199 else if (matchDomain('artnet.com')) { 3200 if (window.location.pathname.endsWith('/amp-page')) { 3201 amp_unhide_subscr_section(); 3202 } else { 3203 let body_hidden = document.querySelector('.article-body'); 3204 if (body_hidden) 3205 body_hidden.style = 'display:block;'; 3206 } 3207 } 3208 3209 else if (matchDomain('asia.nikkei.com')) { 3210 let popup = document.querySelector('#pianoj_ribbon'); 3211 removeDOMElement(popup); 3212 } 3213 3214 else if (matchDomain('axios.com')) { 3215 function axios_noscroll(node) { 3216 node.removeAttribute('style'); 3217 let overlay = document.querySelector('div[class^="Modal_paywallContainer"]'); 3218 hideDOMElement(overlay); 3219 } 3220 waitDOMAttribute('html', 'HTML', 'style', axios_noscroll, true); 3221 let banners = document.querySelectorAll('div[data-vars-experiment="pro-paywall"], .apexAd'); 3222 hideDOMElement(...banners); 3223 csDoneOnce = true; 3224 } 3225 3226 else if (matchDomain('barandbench.com')) { 3227 let paywall = document.querySelector('div#paywall-banner'); 3228 if (paywall) { 3229 removeDOMElement(paywall); 3230 let json_script = getArticleJsonScript(); 3231 if (json_script) { 3232 let json = JSON.parse(json_script.text); 3233 if (json) { 3234 let json_text = json.articleBody; 3235 let content = document.querySelector('div.arr--story-page-card-wrapper'); 3236 if (json_text && content) { 3237 content.innerText = breakText(parseHtmlEntities(json_text)); 3238 } 3239 } 3240 } 3241 } 3242 } 3243 3244 else if (matchDomain('barrons.com')) { 3245 let url = window.location.href; 3246 if (!url.includes('barrons.com/amp/')) { 3247 let body_continuous = document.querySelector('body.is-continuous'); 3248 let snippet = document.querySelector('meta[content="snippet"]'); 3249 if (body_continuous && snippet) { 3250 removeDOMElement(snippet); 3251 window.location.href = url.replace('barrons.com', 'barrons.com/amp'); 3252 } 3253 let continue_buttons = document.querySelectorAll('button.snippet__buttons--continue'); 3254 for (let elem of continue_buttons) 3255 elem.addEventListener('click', function () { window.location.reload(); }); 3256 let barrons_ads = document.querySelectorAll('.barrons-body-ad-placement'); 3257 removeDOMElement(...barrons_ads); 3258 } else { 3259 amp_unhide_subscr_section('.wsj-ad, amp-ad'); 3260 } 3261 } 3262 3263 else if (matchDomain('billboard.com')) { 3264 if (window.location.pathname.endsWith('/amp/')) { 3265 amp_unhide_subscr_section('amp-ad, amp-embed'); 3266 } 3267 } 3268 3269 else if (matchDomain('bloomberg.com')) { 3270 let paywall = document.querySelectorAll('div[id^="fortress-"]'); 3271 let leaderboard = document.querySelector('div[id^="leaderboard"], div[class^="leaderboard"], div.canopy-container'); 3272 let ads = document.querySelectorAll('div[data-ad-status], div.dvz-v0-ad, div[class^="FullWidthAd_"]'); 3273 hideDOMElement(...paywall, leaderboard, ...ads); 3274 if (window.location.pathname.startsWith('/live/')) { 3275 setInterval(function () { 3276 window.localStorage.clear(); 3277 }, 15 * 60 * 1000); 3278 } 3279 } 3280 3281 else if (matchDomain('bloombergadria.com')) { 3282 let article_hidden = document.querySelector('article[style]'); 3283 if (article_hidden) 3284 article_hidden.removeAttribute('style'); 3285 let ads = document.querySelectorAll('.banner'); 3286 removeDOMElement(...ads); 3287 } 3288 3289 else if (matchDomain('bostonglobe.com')) { 3290 if (window.location.search.startsWith('?outputType=amp')) { 3291 amp_unhide_subscr_section(); 3292 } else { 3293 let ads = document.querySelectorAll('div.arc_ad'); 3294 hideDOMElement(...ads); 3295 } 3296 } 3297 3298 else if (matchDomain('bqprime.com')) { 3299 if (window.location.pathname.startsWith('/amp/')) { 3300 amp_unhide_subscr_section('.ad-container'); 3301 } else { 3302 window.setTimeout(function () { 3303 let geo_block = document.querySelector('div[class*="geotag-container_"]'); 3304 if (!window.location.search.startsWith('?rel=geo_block')) { 3305 if (geo_block) { 3306 removeDOMElement(geo_block); 3307 window.location.href = window.location.pathname + '?rel=geo_block'; 3308 } 3309 } else { 3310 if (geo_block) 3311 refreshCurrentTab(); 3312 else { 3313 let hidden_images = document.querySelectorAll('img[src^="data:image/"][data-src]'); 3314 for (let elem of hidden_images) 3315 elem.setAttribute('src', elem.getAttribute('data-src')); 3316 } 3317 } 3318 }, 1000); 3319 } 3320 let ads = document.querySelectorAll('.responsive-ad'); 3321 removeDOMElement(...ads); 3322 } 3323 3324 else if (matchDomain('business-standard.com')) { 3325 if (!window.location.pathname.startsWith('/amp/')) { 3326 let paywall = document.querySelector('div.subscribe-page'); 3327 if (paywall) { 3328 removeDOMElement(paywall); 3329 let json_script = getArticleJsonScript(); 3330 if (json_script) { 3331 let json = JSON.parse(json_script.text); 3332 if (json) { 3333 let json_text = breakText(parseHtmlEntities(json.articleBody)); 3334 let content = document.querySelector('div.storycontent'); 3335 if (json_text && content) { 3336 content.innerHTML = ''; 3337 let article_new = document.createElement('p'); 3338 article_new.innerText = json_text; 3339 content.appendChild(article_new); 3340 } 3341 } 3342 } 3343 } 3344 let banner = document.querySelector('section.sbcrbtmlfull'); 3345 let ads = document.querySelectorAll('div.advertisement-bg'); 3346 removeDOMElement(banner, ...ads); 3347 } else 3348 ampToHtml(); 3349 } 3350 3351 else if (matchDomain('businessinsider.com')) { 3352 let ads = document.querySelectorAll('div.l-ad, div.in-post-sticky, aside.has-video-ad'); 3353 hideDOMElement(...ads); 3354 } 3355 3356 else if (matchDomain('businessoffashion.com')) { 3357 if (window.location.search.startsWith('?outputType=amp')) { 3358 amp_unhide_access_hide(); 3359 } else { 3360 let ads = document.querySelectorAll('div[class^="default__AdsBlockWrapper"]'); 3361 removeDOMElement(...ads); 3362 } 3363 } 3364 3365 else if (matchDomain(ca_gcm_domains)) { 3366 let paywall = document.querySelector('div._block_1dgevo'); 3367 if (paywall) { 3368 removeDOMElement(paywall); 3369 window.setTimeout(function () { 3370 window.location.reload(true); 3371 }, 500); 3372 } 3373 let counter = document.querySelector('div#paywall-banner-content'); 3374 removeDOMElement(counter); 3375 } 3376 3377 else if (matchDomain('cen.acs.org')) { 3378 let meteredBar = document.querySelector('.meteredBar'); 3379 removeDOMElement(meteredBar); 3380 } 3381 3382 else if (matchDomain(['chronicle.com', 'philanthropy.com'])) { 3383 let preview = document.querySelector('div[data-content-summary]'); 3384 removeDOMElement(preview); 3385 let article_hidden = document.querySelector('div.contentBody[hidden]'); 3386 if (article_hidden) { 3387 let attributes = article_hidden.attributes; 3388 for (let elem of attributes) { 3389 let name = elem.name; 3390 if (name !== 'class') 3391 article_hidden.removeAttribute(name); 3392 } 3393 } 3394 } 3395 3396 else if (matchDomain('cnbc.com')) { 3397 let paywall = document.querySelector('div.ArticleGate-proGate'); 3398 if (paywall) { 3399 removeDOMElement(paywall); 3400 let article = document.querySelector('div.ArticleBody-articleBody'); 3401 if (article) 3402 article.style = "margin: 20px 0px; font-family: Lyon,Helvetica,Arial,sans-serif; font-size: 18px; line-height: 1.66"; 3403 let span_hidden = document.querySelectorAll('span[hidden]'); 3404 for (let elem of span_hidden) { 3405 elem.removeAttribute('hidden'); 3406 elem.removeAttribute('class'); 3407 } 3408 } 3409 } 3410 3411 else if (matchDomain('csmonitor.com')) { 3412 let paywall = document.querySelector('div.paywall'); 3413 removeDOMElement(paywall); 3414 } 3415 3416 else if (matchDomain('dailywire.com')) { 3417 let paywall = document.querySelector('#post-body-text > div > div[class]'); 3418 if (paywall) 3419 paywall.removeAttribute('class'); 3420 } 3421 3422 else if (matchDomain('dallasnews.com')) { 3423 if (window.location.search.startsWith('?outputType=amp')) { 3424 amp_unhide_subscr_section('amp-ad, amp-embed'); 3425 } else { 3426 let overlay = document.querySelector('div.sl-overlay'); 3427 removeDOMElement(overlay); 3428 let noscroll = document.querySelector('div#courier-body-wrapper[style]'); 3429 if (noscroll) 3430 noscroll.removeAttribute('style'); 3431 } 3432 } 3433 3434 else if (matchDomain('defector.com')) { 3435 let paywall = document.querySelector('div[class^="ContentGate_wrapper__"]'); 3436 removeDOMElement(paywall); 3437 } 3438 3439 else if (matchDomain('digiday.com')) { 3440 if (window.location.pathname.endsWith('/amp/')) { 3441 amp_unhide_access_hide('="NOT p.showPageviewExpired AND NOT p.showPayWall"', '', 'amp-ad, .advertisement, .ad-wrapper'); 3442 } 3443 } 3444 3445 else if (matchDomain('discovermagazine.com')) { 3446 window.setTimeout(function () { 3447 let mammoth = document.querySelector('.iXVGnF'); 3448 if (mammoth) 3449 window.location.reload(); 3450 let banner = document.querySelector('div.dPURIw'); 3451 hideDOMElement(banner); 3452 }, 1000); 3453 } 3454 3455 else if (matchDomain('dn.no')) { 3456 let url = window.location.href; 3457 let paywall = document.querySelector('div#dn-ncp-popup, div.paywall, iframe[title="Paywall"]'); 3458 if (paywall) { 3459 removeDOMElement(paywall); 3460 let article_sel = 'article'; 3461 let article = document.querySelector(article_sel); 3462 if (article) { 3463 let url_cache = 'https://webcache.googleusercontent.com/search?q=cache:' + url.split('?')[0]; 3464 replaceDomElementExt(url_cache, true, false, article_sel); 3465 } else { 3466 article = document.querySelector('main#main-story, main.lp_article_content'); 3467 if (article) 3468 article.firstChild.before(googleWebcacheLink(url)); 3469 } 3470 } 3471 window.setTimeout(function () { 3472 let preview = document.querySelector('html.dn-preview-page'); 3473 if (preview) 3474 preview.removeAttribute('class'); 3475 let infobox_content = document.querySelector('div.infobox__content'); 3476 if (infobox_content) 3477 infobox_content.removeAttribute('class'); 3478 let lazy_images = document.querySelectorAll('img[class*="lazy"][data-srcset]:not([src])'); 3479 for (let elem of lazy_images) { 3480 elem.src = elem.getAttribute('data-srcset').split(' ')[0]; 3481 if (elem.classList.contains('lazy')) 3482 elem.classList.remove('lazy'); 3483 else 3484 elem.removeAttribute('class'); 3485 } 3486 let ads = document.querySelectorAll('div[id^="googlead-"]'); 3487 removeDOMElement(...ads); 3488 }, 1000); 3489 } 3490 3491 else if (matchDomain('economictimes.com')) { 3492 if (window.location.pathname.includes('/amp_')) { 3493 let paywall = document.querySelector('.paywall_wrap'); 3494 if (paywall && dompurify_loaded) { 3495 let content = document.querySelector('.paywall[style="display:none;"]'); 3496 if (content) { 3497 let parser = new DOMParser(); 3498 let doc = parser.parseFromString('<div style="margin: 20px 0px;">' + DOMPurify.sanitize(content.innerText, {ADD_TAGS: ['iframe'], ADD_ATTR: ['frameborder']}) + '</div>', 'text/html'); 3499 let content_new = doc.querySelector('div'); 3500 if (content_new && content.parentNode) 3501 content.parentNode.replaceChild(content_new, content); 3502 } else 3503 window.location.href = 'https://economictimes.indiatimes.com' + window.location.pathname.replace('amp_prime', 'prime'); 3504 let intro = document.querySelector('.art_wrap'); 3505 let article_blocker = document.querySelector('.articleBlocker'); 3506 let amp_ads = document.querySelectorAll('amp-ad'); 3507 removeDOMElement(paywall, intro, article_blocker, ...amp_ads); 3508 } 3509 } else { 3510 window.setTimeout(function () { 3511 let paywall = document.querySelector('div#blocker_layer'); 3512 let data_prime = document.querySelector('div[data-prime="1"]'); 3513 let amphtml = document.querySelector('link[rel="amphtml"]'); 3514 if (paywall || data_prime) { 3515 removeDOMElement(paywall); 3516 if (data_prime) 3517 data_prime.removeAttribute('data-prime'); 3518 if (amphtml) 3519 window.location.href = amphtml.href; 3520 else if (window.location.pathname.startsWith('/epaper/')) 3521 window.location.href = 'https://economictimes.indiatimes.com' + window.location.pathname; 3522 } else { 3523 let ads = document.querySelectorAll('.adContainer'); 3524 removeDOMElement(...ads); 3525 } 3526 }, 500); 3527 } 3528 } 3529 3530 else if (matchDomain('economictimes.indiatimes.com')) { 3531 let paywall = document.querySelector('section.prime_paywall'); 3532 if (paywall) { 3533 removeDOMElement(paywall); 3534 let content = document.querySelector('div.content1, div.artText'); 3535 let full_text = document.querySelector('div.paywall.p1'); 3536 if (content && full_text) 3537 content.innerText = full_text.innerText; 3538 let page_content = document.querySelector('div.pageContent:not([style])'); 3539 if (page_content) 3540 page_content.setAttribute('style', 'height: auto !important;'); 3541 } 3542 } 3543 3544 else if (matchDomain('economist.com')) { 3545 let paywall = document.querySelector('div.paywall'); 3546 if (paywall) { 3547 let noscroll = document.querySelector('svelte-scroller-outer'); 3548 let hide_style = document.querySelector('body > style'); 3549 removeDOMElement(paywall, noscroll, hide_style); 3550 } 3551 let ads = document.querySelectorAll('div[class*="_advert__"]'); 3552 hideDOMElement(...ads); 3553 } 3554 3555 else if (matchDomain('enotes.com')) { 3556 let paywall = document.querySelectorAll('section.c-cta-section'); 3557 if (paywall.length) { 3558 removeDOMElement(...paywall); 3559 let blurred = document.querySelectorAll('div[class^="_"]'); 3560 for (let elem of blurred) 3561 elem.removeAttribute('class'); 3562 let intro = document.querySelectorAll('div.o-rte-text > p:not([class]), div.o-rte-text > h3'); 3563 for (let elem of intro) 3564 removeDOMElement(elem); 3565 let section_words = pageContains('p[class="u-align--center"]', /\(The entire section contains/); 3566 let ads = document.querySelectorAll('.ad-hfu'); 3567 removeDOMElement(...section_words, ...ads); 3568 } 3569 } 3570 3571 else if (matchDomain('espn.com')) { 3572 let url = window.location.href; 3573 let paywall = document.querySelector('aside.espn-plus-container-wrapper'); 3574 if (paywall) { 3575 removeDOMElement(paywall); 3576 replaceDomElementExt(url, false, false, 'div.article-body'); 3577 } 3578 } 3579 3580 else if (matchDomain('euobserver.com')) { 3581 let div_hidden = document.querySelector('div.membership-upsell.show'); 3582 if (div_hidden) 3583 div_hidden.classList.remove('show'); 3584 } 3585 3586 else if (matchDomain('euromoney.com')) { 3587 let url = window.location.href; 3588 let paywall = document.querySelector('div.paywall'); 3589 if (paywall) { 3590 removeDOMElement(paywall); 3591 csDoneOnce = true; 3592 let url_cache = 'https://webcache.googleusercontent.com/search?q=cache:' + url.split('?')[0]; 3593 replaceDomElementExt(url_cache, true, false, 'div.Paywall-content'); 3594 } 3595 let fade = document.querySelector('div[style*="background-image: linear-gradient"]'); 3596 removeDOMElement(fade); 3597 } 3598 3599 else if (matchDomain('fieldandstream.com')) { 3600 let overlay = document.querySelectorAll('div[class^="mailmunch-"]'); 3601 removeDOMElement(...overlay); 3602 let noscroll = document.querySelector('html.mailmunch-pop-open'); 3603 if (noscroll) 3604 noscroll.removeAttribute('class'); 3605 } 3606 3607 else if (matchDomain('financialexpress.com')) { 3608 let paywall = document.querySelector('div.paywall'); 3609 if (paywall) 3610 paywall.classList.remove('paywall'); 3611 let register = document.querySelector('div.pcl-wrap'); 3612 let ads_selector = window.location.pathname.endsWith('/lite/') ? 'amp-ad, amp-embed, .ad-bg-container' : 'div[class*="-ads-blocks-ad-unit"]'; 3613 let ads = document.querySelectorAll(ads_selector); 3614 removeDOMElement(register, ...ads); 3615 } 3616 3617 else if (matchDomain('firstthings.com')) { 3618 let paywall = document.querySelector('.paywall'); 3619 removeDOMElement(paywall); 3620 } 3621 3622 else if (matchDomain('foreignaffairs.com')) { 3623 window.setTimeout(function () { 3624 let paywall = document.querySelector('.paywall'); 3625 let loading_indicator = document.querySelector('.loading-indicator'); 3626 let msg_bottom = document.querySelector('.messages--container--bottom'); 3627 removeDOMElement(paywall, loading_indicator, msg_bottom); 3628 let article_dropcap = document.querySelectorAll('.article-dropcap'); 3629 for (let elem of article_dropcap) 3630 elem.classList.add('loaded'); 3631 }, 1000); 3632 } 3633 3634 else if (matchDomain('foreignpolicy.com')) { 3635 let content_ungated = document.querySelector('div.content-ungated'); 3636 if (content_ungated && dompurify_loaded) { 3637 removeDOMElement(content_ungated); 3638 let content_gated = document.querySelector('div.content-gated'); 3639 if (content_gated) { 3640 content_gated.classList.remove('content-gated'); 3641 let insider = document.querySelector('body.is-fp-insider'); 3642 if (insider) { 3643 window.setTimeout(function () { 3644 let json_script = getArticleJsonScript(); 3645 if (json_script) { 3646 let json = JSON.parse(json_script.text); 3647 if (json) { 3648 let content = json.Articlebody.replace(/\r\n/g, '<br>'); 3649 if (content) { 3650 let parser = new DOMParser(); 3651 let doc = parser.parseFromString('<div style="margin: 50px;">' + DOMPurify.sanitize(content) + '</div>', 'text/html'); 3652 let content_new = doc.querySelector('div'); 3653 content_gated.before(content_new); 3654 } 3655 } 3656 } 3657 }, 500); 3658 } 3659 } 3660 } 3661 } 3662 3663 else if (matchDomain('fortune.com')) { 3664 let paywall = document.querySelector('.paywall'); 3665 if (window.location.pathname.match(/\/amp(\/)?/)) { 3666 amp_unhide_access_hide('="NOT p.showRegWall AND NOT p.showPayWall"', '', '[class^="amp-ad"]'); 3667 removeDOMElement(paywall); 3668 } else { 3669 if (paywall) 3670 paywall.removeAttribute('class'); 3671 } 3672 } 3673 3674 else if (matchDomain('ftm.eu')) { 3675 let banners = document.querySelectorAll('div.banner-pp, a.readmore'); 3676 removeDOMElement(...banners); 3677 } 3678 3679 else if (matchDomain('hbr.org')) { 3680 let popup = document.querySelector('.persistent-banner'); 3681 removeDOMElement(popup); 3682 let paywall = document.querySelector('site-paywall'); 3683 if (paywall) {//legacy 3684 removeDOMElement(paywall); 3685 let intro = document.querySelector('.article-ideainbrief'); 3686 if (intro) 3687 intro.removeAttribute('class'); 3688 let main_hidden = document.querySelector('div#main[style]'); 3689 if (main_hidden) 3690 main_hidden.removeAttribute('style'); 3691 } 3692 } 3693 3694 else if (matchDomain('hbrchina.org')) { 3695 let div_hidden = document.querySelector('div#the_content'); 3696 if (div_hidden) 3697 div_hidden.removeAttribute('style'); 3698 } 3699 3700 else if (matchDomain('hilltimes.com')) { 3701 let paywall = document.querySelectorAll('div[class^="paywallcont"]'); 3702 if (paywall.length) { 3703 removeDOMElement(...paywall); 3704 let json_script = document.querySelector('script.saswp-schema-markup-output'); 3705 if (json_script) { 3706 try { 3707 let json = JSON.parse(json_script.text); 3708 json_text = json.filter(x => x.articleBody)[0].articleBody.replace(/\s{2,}/g, '\r\n\r\n'); 3709 let article = document.querySelector('div#fadebg > p'); 3710 if (article) 3711 article.innerText = parseHtmlEntities(json_text); 3712 } catch (err) { 3713 console.log(err); 3714 } 3715 } 3716 } 3717 let banner = document.querySelector('section.hide_this_section'); 3718 hideDOMElement(banner); 3719 } 3720 3721 else if (matchDomain('hindustantimes.com')) { 3722 let paywall = document.querySelector('.freemium-card'); 3723 if (paywall) { 3724 removeDOMElement(paywall); 3725 let freemium_text = document.querySelector('.freemiumText'); 3726 if (freemium_text) 3727 freemium_text.classList.remove('freemiumText'); 3728 } 3729 let noscroll = document.querySelector('body.open-popup'); 3730 if (noscroll) 3731 noscroll.classList.remove('open-popup'); 3732 let close_story = document.querySelector('.closeStory'); 3733 let ads = document.querySelectorAll('div[class^="adHeight"]'); 3734 removeDOMElement(close_story, ...ads); 3735 } 3736 3737 else if (matchDomain('hindutamil.in')) { 3738 if (!window.location.pathname.startsWith('/amp/')) { 3739 let paywall = document.querySelector('div.premium-class-bt'); 3740 let amphtml = document.querySelector('link[rel="amphtml"]'); 3741 if (paywall && amphtml) { 3742 removeDOMElement(paywall); 3743 window.location.href = amphtml.href; 3744 } 3745 } 3746 } 3747 3748 else if (matchDomain('historyextra.com')) { 3749 let article_masked = document.querySelector('.template-article__masked'); 3750 if (article_masked) { 3751 let extra_pars = document.querySelectorAll('div.template-article__masked > p'); 3752 removeDOMElement(...extra_pars); 3753 article_masked.classList.remove('template-article__masked'); 3754 } 3755 let ad_banner = document.querySelector('.ad-banner-container'); 3756 removeDOMElement(ad_banner); 3757 } 3758 3759 else if (matchDomain(usa_hearst_comm_domains)) { 3760 let wrapper = document.querySelector('.belowMastheadWrapper'); 3761 let ads = document.querySelectorAll('div.adModule'); 3762 removeDOMElement(wrapper, ...ads); 3763 } 3764 3765 else if (matchDomain('inc42.com')) { 3766 let url = window.location.href; 3767 let paywall = document.querySelector('div#inc42_article_content_lock'); 3768 let article_sel = 'div.content-wrapper, section[amp-access="status"]'; 3769 if (paywall) { 3770 removeDOMElement(paywall); 3771 csDoneOnce = true; 3772 let url_cache = 'https://webcache.googleusercontent.com/search?q=cache:' + url.split('?')[0]; 3773 replaceDomElementExt(url_cache, true, false, article_sel); 3774 } 3775 window.setTimeout(function () { 3776 if (window.location.pathname.endsWith('/amp/')) { 3777 let lazy_images = document.querySelectorAll('img.lazyload[src^="data:image/"][data-src]'); 3778 for (let elem of lazy_images) { 3779 elem.src = elem.getAttribute('data-src'); 3780 elem.classList.remove('lazyload'); 3781 if (elem.width > 1000) { 3782 let ratio = elem.width / 640; 3783 if (window.navigator.userAgent.toLowerCase().includes('mobile')) 3784 ratio = elem.width / 320; 3785 elem.width = elem.width / ratio; 3786 elem.height = elem.height / ratio; 3787 } 3788 } 3789 } 3790 let also_read = document.querySelector('div > .also-read'); 3791 if (also_read) { 3792 let article = document.querySelector(article_sel); 3793 if (article) 3794 article.appendChild(also_read.parentNode); 3795 } 3796 }, 1000); 3797 } 3798 3799 else if (matchDomain('indianexpress.com')) { 3800 if (window.location.pathname.endsWith('/lite/')) 3801 amp_unhide_access_hide('="metering.result=\'ALLOW_ACCESS\'"', '', 'amp-ad, amp-embed'); 3802 else { 3803 let paywall = document.querySelector('div#pcl-rest-content[style]'); 3804 if (paywall) 3805 paywall.removeAttribute('style'); 3806 let register = document.querySelector('div#app-pcl'); 3807 let ads = document.querySelectorAll('div[class^="adsbox"]'); 3808 removeDOMElement(register, ...ads); 3809 } 3810 } 3811 3812 else if (matchDomain('indiatoday.in')) { 3813 if (window.location.pathname.match(/(\/amp)?\/magazine\//)) { 3814 let url = window.location.href; 3815 if (!url.includes('/amp/')) { 3816 let paywall = document.querySelector('#csc-paywall'); 3817 let amphtml = document.querySelector('link[rel="amphtml"]'); 3818 if (paywall && amphtml) { 3819 removeDOMElement(paywall); 3820 window.location.href = amphtml.href; 3821 } 3822 } else { 3823 amp_unhide_access_hide('="granted"', '="NOT NOT granted"', 'amp-ad, amp-embed'); 3824 } 3825 } else 3826 csDoneOnce = true; 3827 } 3828 3829 else if (matchDomain('infzm.com')) { 3830 let url = window.location.href; 3831 if (url.includes('/wap/#/')) { 3832 let container = document.querySelector('section.container'); 3833 if (container) 3834 container.classList.remove('container'); 3835 let overlay = document.querySelector('div.article-content[style]'); 3836 if (overlay) 3837 overlay.removeAttribute('style'); 3838 } 3839 } 3840 3841 else if (matchDomain('inkl.com')) { 3842 let paywall = document.querySelector('div.paywall'); 3843 if (paywall) { 3844 paywall.removeAttribute('class'); 3845 let gradient_container = document.querySelector('div.gradient-container'); 3846 removeDOMElement(gradient_container); 3847 } 3848 let what_is_inkl = document.querySelector('.what-is-inkl-container, .features-panel'); 3849 let signup = document.querySelectorAll('.article-signup-container, .locked-sign-up-container, div[class*="/inkl-watermark.svg"]'); 3850 let shared_banner = document.querySelector('div.shared-article-inline-banner'); 3851 removeDOMElement(what_is_inkl, ...signup, shared_banner); 3852 let dismiss_button = document.querySelector('div.dismiss-button-container button.btn'); 3853 if (dismiss_button) 3854 dismiss_button.click(); 3855 let dive_deeper_summary_bodies = document.querySelectorAll('div.dive-deeper-container div.summary-body'); 3856 if (dive_deeper_summary_bodies) { 3857 for (let summary_body of dive_deeper_summary_bodies) { 3858 if (!summary_body.querySelector('a')) { 3859 let ng_click = summary_body.getAttribute('ng-click').replace("showArticle('", '').replace("')", ''); 3860 let weblink = document.createElement('a'); 3861 weblink.text = 'open'; 3862 weblink.href = 'https://www.inkl.com/news/' + ng_click; 3863 summary_body.appendChild(weblink); 3864 } 3865 } 3866 } 3867 } 3868 3869 else if (matchDomain('ipolitics.ca')) { 3870 let login = document.querySelector('div.login'); 3871 if (login && dompurify_loaded) { 3872 removeDOMElement(login); 3873 let json_script = document.querySelector('script#__NEXT_DATA__'); 3874 if (json_script) { 3875 try { 3876 let json = JSON.parse(json_script.innerText); 3877 if (json && json.props.pageProps.post && json.props.pageProps.post.content) { 3878 let url_next = json.props.pageProps.post.slug; 3879 if (url_next && !window.location.pathname.includes(url_next)) 3880 refreshCurrentTab(); 3881 let article_new = json.props.pageProps.post.content; 3882 let article = document.querySelector('.post-body'); 3883 if (article) { 3884 article.innerHTML = ''; 3885 article.classList.remove('locked'); 3886 let parser = new DOMParser(); 3887 let doc = parser.parseFromString('<div>' + DOMPurify.sanitize(article_new) + '</div>', 'text/html'); 3888 let content_new = doc.querySelector('div'); 3889 article.appendChild(content_new); 3890 } 3891 } else { 3892 refreshCurrentTab(); 3893 } 3894 } catch (err) { 3895 console.log(err); 3896 } 3897 } 3898 } 3899 } 3900 3901 else if (matchDomain('japantimes.co.jp')) { 3902 if (!window.location.pathname.endsWith('/amp')) { 3903 window.setTimeout(function () { 3904 let paywall = document.querySelector('div.blocker > div.tp-container-inner'); 3905 if (paywall) { 3906 removeDOMElement(paywall.parentNode); 3907 let json_script = getArticleJsonScript(); 3908 if (json_script) { 3909 let json = JSON.parse(json_script.text); 3910 if (json) { 3911 let json_text = json.articleBody; 3912 let article = document.querySelector('div.article-body'); 3913 if (json_text && article) { 3914 let article_new = document.createElement('p'); 3915 article_new.innerText = breakText(json_text); 3916 article.innerHTML = ''; 3917 article.appendChild(article_new); 3918 article.classList.remove('blurred-text'); 3919 } 3920 } 3921 } 3922 } 3923 }, 1000); 3924 } else 3925 ampToHtml(); 3926 } 3927 3928 else if (matchDomain('jpost.com')) { 3929 let premium_banners = document.querySelectorAll('.hide-for-premium, #hiddenPremiumForm, #hiddenLink'); 3930 removeDOMElement(...premium_banners); 3931 } 3932 3933 else if (matchDomain(['latimes.com', 'sandiegouniontribune.com'])) { 3934 let ads = document.querySelectorAll('div.enhancement, div.google-dfp-ad-wrapper'); 3935 removeDOMElement(...ads); 3936 } 3937 3938 else if (matchDomain('ledevoir.com')) { 3939 let counter = document.querySelector('.paywall-breakpoint-wrapper'); 3940 removeDOMElement(counter); 3941 } 3942 3943 else if (matchDomain('livelaw.in')) { 3944 let paywall = document.querySelector('div#subscription_paid_message, div.subscribeNow'); 3945 if (paywall) { 3946 let intro = document.querySelector('div.story'); 3947 removeDOMElement(paywall, intro); 3948 let restricted_message = document.querySelector('div.restricted_message'); 3949 if (restricted_message) 3950 restricted_message.classList.remove('restricted_message'); 3951 let paywall_content = document.querySelector('div.paywall-content.hide'); 3952 if (paywall_content) 3953 paywall_content.classList.remove('hide'); 3954 } 3955 let ads = document.querySelectorAll('inside-post-ad, amp-ad'); 3956 removeDOMElement(...ads); 3957 } 3958 3959 else if (matchDomain('livemint.com')) { 3960 if (window.location.pathname.includes('/amp-')) { 3961 let paywall = document.querySelectorAll('[amp-access="NOT subscribed"]'); 3962 removeDOMElement(...paywall); 3963 } else { 3964 let paywall = document.querySelector('div.paywall'); 3965 if (paywall) 3966 paywall.classList.remove('paywall'); 3967 let ads = document.querySelectorAll('[class^="ad"], [id^="ad"], #subscribeAd, .taboolaHeight'); 3968 removeDOMElement(...ads); 3969 } 3970 } 3971 3972 else if (matchDomain('magazine.atavist.com')) { 3973 let bottom_notification = document.querySelector('div.bottom-notification'); 3974 let overlay = document.querySelector('div.notification-overlay'); 3975 removeDOMElement(bottom_notification, overlay); 3976 let paywall = document.querySelector('body.paywall-notification-visible'); 3977 if (paywall) 3978 paywall.classList.remove('paywall-notification-visible'); 3979 } 3980 3981 else if (matchDomain('marketwatch.com')) { 3982 let premium = document.querySelector('html.is-paywall'); 3983 let url = window.location.href; 3984 if (!url.includes('/amp/')) { 3985 if (premium) { 3986 premium.classList.remove('is-paywall'); 3987 window.location.href = url.replace('.marketwatch.com/', '.marketwatch.com/amp/'); 3988 } 3989 } else { 3990 let meter = document.querySelector('div.meter'); 3991 let container_sponsored = document.querySelector('div.container--sponsored'); 3992 removeDOMElement(meter, container_sponsored); 3993 amp_unhide_subscr_section('.display-ad'); 3994 } 3995 let ads = document.querySelectorAll('div.element--ad, div.j-ad'); 3996 removeDOMElement(...ads); 3997 } 3998 3999 else if (matchDomain('medscape.com')) { 4000 let ads = document.querySelectorAll('.AdUnit, [id^="ads-"]'); 4001 removeDOMElement(...ads); 4002 } 4003 4004 else if (matchDomain('mid-day.com')) { 4005 if (window.location.pathname.startsWith('/amp/')) { 4006 amp_unhide_access_hide('="granted"', '="NOT granted"', 'amp-ad, amp-embed, [class*="BannerAd"]'); 4007 } else { 4008 let paywall = document.querySelector('div#widget-_csc'); 4009 let amphtml = document.querySelector('link[rel="amphtml"]'); 4010 if (paywall && amphtml) { 4011 removeDOMElement(paywall); 4012 window.location.href = amphtml.href; 4013 } else { 4014 let read_more = document.querySelector('#read-more-my'); 4015 if (read_more) 4016 read_more.click(); 4017 } 4018 } 4019 } 4020 4021 else if (matchDomain('nationalgeographic.com')) { 4022 function natgeo_func(node) { 4023 removeDOMElement(node); 4024 let body = document.querySelector('body[class]'); 4025 if (body) { 4026 body.removeAttribute('class'); 4027 body.removeAttribute('style'); 4028 } 4029 } 4030 waitDOMElement('div[id^="fittPortal"]', 'DIV', natgeo_func, false); 4031 csDoneOnce = true; 4032 window.setTimeout(function () { 4033 let url = window.location.href; 4034 let subscribed = document.querySelector('.Article__Content--gated'); 4035 let overlay = document.querySelector('.Article__Content__Overlay--gated'); 4036 let msg = document.querySelector('div#bpc_archive'); 4037 if (subscribed && !msg) { 4038 subscribed.appendChild(archiveLink(url)); 4039 subscribed.setAttribute('style', 'overflow: visible !important;'); 4040 if (overlay) 4041 overlay.classList.remove('Article__Content__Overlay--gated'); 4042 } 4043 let ads = document.querySelectorAll('div.ad-slot, div.InsertedAd'); 4044 removeDOMElement(...ads); 4045 }, 1000); 4046 } 4047 4048 else if (matchDomain('nationalreview.com')) { 4049 if (!window.location.pathname.endsWith('/amp/')) { 4050 window.setTimeout(function () { 4051 let paywall = document.querySelector('div.continue-reading'); 4052 if (paywall) { 4053 removeDOMElement(paywall); 4054 refreshCurrentTab(); 4055 } 4056 }, 1000); 4057 } 4058 let zephr_wrapper = document.querySelector('div.zephr-wrapper'); 4059 hideDOMElement(zephr_wrapper); 4060 let ads = document.querySelectorAll('amp-ad, .ad-unit, .ad-skeleton, amp-connatix-player, div[class*="-connatix-"]'); 4061 hideDOMElement(...ads); 4062 } 4063 4064 else if (matchDomain('nautil.us')) { 4065 let banners = document.querySelectorAll('div[class^="a__sc-np"], div.subscibe-bar'); 4066 removeDOMElement(...banners); 4067 } 4068 4069 else if (matchDomain('newleftreview.org')) { 4070 window.setTimeout(function () { 4071 let url = window.location.href; 4072 let paywall = document.querySelector('div.promo-wrapper'); 4073 if (paywall) { 4074 removeDOMElement(paywall); 4075 csDoneOnce = true; 4076 let url_cache = 'https://webcache.googleusercontent.com/search?q=cache:' + url.split('?')[0]; 4077 replaceDomElementExt(url_cache, true, false, 'div.article-page'); 4078 } 4079 }, 500); 4080 } 4081 4082 else if (matchDomain('newrepublic.com')) { 4083 let modal = document.querySelector('div.article-scheduled-modal'); 4084 let pw_popups = document.querySelector('div#pwPopups'); 4085 let ads = document.querySelectorAll('.ad-unit, .ad-container'); 4086 removeDOMElement(modal, pw_popups, ...ads); 4087 } 4088 4089 else if (matchDomain('newscientist.com')) { 4090 let url = window.location.href; 4091 let paywall = document.querySelector('#subscription-barrier'); 4092 if (paywall) { 4093 removeDOMElement(paywall); 4094 csDoneOnce = true; 4095 let url_cache = 'https://webcache.googleusercontent.com/search?q=cache:' + url.split('?')[0]; 4096 replaceDomElementExt(url_cache, true, false, 'div.article-body, article'); 4097 } 4098 window.setTimeout(function () { 4099 let lazy_images = document.querySelectorAll('img.lazyload[data-src]:not([src])'); 4100 for (let elem of lazy_images) 4101 elem.src = elem.getAttribute('data-src').split('?')[0] + '?width=800'; 4102 let ads = document.querySelectorAll('div[class*="Advert"]'); 4103 removeDOMElement(...ads); 4104 }, 1000); 4105 } 4106 4107 else if (matchDomain('newsday.com')) { 4108 if (window.location.pathname.startsWith('/amp/')) { 4109 amp_unhide_access_hide('="AccessLevel = \'Full Content Access\' OR Error = true"', '="Error != true AND UserState != \'Subscribed\'"'); 4110 } else { 4111 let nd_lock = document.querySelector('html[class]'); 4112 if (nd_lock) 4113 nd_lock.removeAttribute('class'); 4114 let ads = document.querySelectorAll('div[class^="ad_full-banner_"]'); 4115 hideDOMElement(...ads); 4116 } 4117 } 4118 4119 else if (matchDomain(['nola.com', 'theadvocate.com'])) { 4120 if (window.location.pathname.endsWith('.amp.html')) { 4121 let body_hidden = document.querySelector('.site-container'); 4122 if (body_hidden) 4123 body_hidden.setAttribute('style', 'display:block;'); 4124 } 4125 } 4126 4127 else if (matchDomain('nybooks.com')) { 4128 let paywall_article = document.querySelector('.paywall-article'); 4129 if (paywall_article) 4130 paywall_article.classList.remove('paywall-article'); 4131 let banner = document.querySelector('div.toast-cta, div.inline-ad'); 4132 removeDOMElement(banner); 4133 } 4134 4135 else if (matchDomain('nytimes.com')) { 4136 let banners = document.querySelectorAll('div[data-testid="inline-message"], div[id^="ad-"], div.expanded-dock, div.pz-ad-box'); 4137 removeDOMElement(...banners); 4138 } 4139 4140 else if (matchDomain('nzherald.co.nz')) { 4141 // plus code in contentScript_once_var.js (timing) 4142 let premium_toaster = document.querySelector('#premium-toaster'); 4143 let ads = document.querySelectorAll('.ad'); 4144 hideDOMElement(premium_toaster, ...ads); 4145 } 4146 4147 else if (matchDomain('outlookbusiness.com')) { 4148 let paywall = document.querySelector('div#csc-paywall'); 4149 if (paywall && dompurify_loaded) { 4150 removeDOMElement(paywall); 4151 let json_script = document.querySelector('script#__NEXT_DATA__'); 4152 if (json_script) { 4153 let json = JSON.parse(json_script.innerText); 4154 if (json && json.props.initialState.dashboard.ARTICLE_POST_DETAIL_API.data.article_data.description) { 4155 let article_new = json.props.initialState.dashboard.ARTICLE_POST_DETAIL_API.data.article_data.description; 4156 let article = document.querySelector('div.story-content'); 4157 if (article) { 4158 article.innerHTML = ''; 4159 let parser = new DOMParser(); 4160 let doc = parser.parseFromString('<div>' + DOMPurify.sanitize(article_new) + '</div>', 'text/html'); 4161 let content_new = doc.querySelector('div'); 4162 article.appendChild(content_new); 4163 } 4164 } 4165 } 4166 } 4167 } 4168 4169 else if (matchDomain('outlookindia.com')) { 4170 let paywall = document.querySelector('div.paywall'); 4171 if (paywall) { 4172 removeDOMElement(paywall); 4173 let json_script = getArticleJsonScript(); 4174 if (json_script) { 4175 let json = JSON.parse(json_script.text); 4176 if (json) { 4177 let json_text = parseHtmlEntities(json.articleBody).replace(/\n/g, "$&\r\n"); 4178 let content = document.querySelector('div#articleBody'); 4179 if (json_text && content) { 4180 content.innerHTML = ''; 4181 let article_new = document.createElement('p'); 4182 article_new.innerText = json_text; 4183 content.appendChild(article_new); 4184 } 4185 } 4186 } 4187 } 4188 } 4189 4190 else if (matchDomain('project-syndicate.org')) { 4191 let url = window.location.href; 4192 let paywall = document.querySelector('div.paywall--base'); 4193 if (paywall) { 4194 removeDOMElement(paywall); 4195 let article = document.querySelector('div[data-page-area="article-body"]'); 4196 if (article) 4197 article.firstChild.before(archiveLink(url)); 4198 } 4199 } 4200 4201 else if (matchDomain('puck.news')) { 4202 let url = window.location.href; 4203 let paywall = document.querySelectorAll('div[class*="paywall"]'); 4204 if (paywall.length) { 4205 removeDOMElement(...paywall); 4206 csDoneOnce = true; 4207 let url_cache = 'https://webcache.googleusercontent.com/search?q=cache:' + url.split('?')[0]; 4208 replaceDomElementExt(url_cache, true, false, 'div.entry-content'); 4209 let overlay = document.querySelector('body.paywall-active'); 4210 if (overlay) 4211 overlay.classList.remove('paywall-active'); 4212 let article_style = document.querySelector('article[style]'); 4213 if (article_style) 4214 article_style.removeAttribute('style'); 4215 } 4216 } 4217 4218 else if (matchDomain('quora.com')) { 4219 let overlays = document.querySelectorAll('div[class*="_overlay"]'); 4220 removeDOMElement(...overlays); 4221 let mask_image = document.querySelector('div.jhqnqh'); 4222 if (mask_image) 4223 mask_image.classList.remove('jhqnqh'); 4224 let read_more_buttons = document.querySelectorAll('button.puppeteer_test_read_more_button.qu-bg--gray_ultralight'); 4225 for (let elem of read_more_buttons) 4226 elem.click(); 4227 let overlay_cards = document.querySelectorAll('div[class*="OverlayCard"]'); 4228 for (let elem of overlay_cards) 4229 elem.removeAttribute('class'); 4230 window.setTimeout(function () { 4231 let answers = document.querySelectorAll('div[class*="dom_annotate_question_answer_item_"]'); 4232 for (let answer of answers) { 4233 let wall = answer.querySelector('div.content-monetization-wall'); 4234 if (wall) { 4235 wall.classList.remove('content-monetization-wall'); 4236 let timestamp_link = answer.querySelector('a.answer_timestamp[href]'); 4237 if (timestamp_link) { 4238 let answer_link = document.createElement('a'); 4239 answer_link.innerText = 'BPC > open Quora+ answer'; 4240 answer_link.href = timestamp_link.href; 4241 wall.appendChild(answer_link); 4242 } 4243 } 4244 } 4245 }, 500); 4246 } 4247 4248 else if (matchDomain('rugbypass.com')) { 4249 if (window.location.pathname.startsWith('/plus/')) { 4250 let paywall = document.querySelector('.premium-fold-bottom'); 4251 if (paywall) { 4252 paywall.classList.remove('premium-fold-bottom'); 4253 let offer = document.querySelector('.plus-article-offer'); 4254 removeDOMElement(offer); 4255 let fade = document.querySelector('.fade'); 4256 if (fade) 4257 fade.classList.remove('fade'); 4258 } 4259 } else 4260 csDoneOnce = true; 4261 } 4262 4263 else if (matchDomain('science.org')) { 4264 let paywall = document.querySelector('div.alert-read-limit'); 4265 removeDOMElement(paywall); 4266 let overlay = document.querySelector('body.alert-read-limit__overlay'); 4267 if (overlay) 4268 overlay.classList.remove('alert-read-limit__overlay'); 4269 } 4270 4271 else if (matchDomain('scmp.com')) { 4272 if (window.location.href.includes('/amp.')) { 4273 let div_hidden = document.querySelectorAll('div.article-body[amp-access][amp-access-hide]'); 4274 for (let elem of div_hidden) 4275 elem.removeAttribute('amp-access-hide'); 4276 let default_meters = document.querySelectorAll('div.default-meter, div#archive-article-meter'); 4277 let adverts = document.querySelectorAll('amp-ad, div.ad-banner, div.advert-fly-carpet-container, div.inline-advert'); 4278 removeDOMElement(...default_meters, ...adverts); 4279 } else 4280 csDoneOnce = true; 4281 } 4282 4283 else if (matchDomain('seattletimes.com')) { 4284 let ads = document.querySelectorAll('.top-ad-wrapper, .ad-container'); 4285 removeDOMElement(...ads); 4286 } 4287 4288 else if (matchDomain('seekingalpha.com')) { 4289 if (!window.location.pathname.startsWith('/amp/')) { 4290 let locked = document.querySelector('div[data-test-id="post-locked-banner"]'); 4291 let amphtml = document.querySelector('link[rel="amphtml"]'); 4292 if (locked && amphtml) { 4293 locked.removeAttribute('data-test-id'); 4294 window.location.href = amphtml.href; 4295 } else { 4296 let read_more = document.querySelector('button[id^="continueReadingButton"]'); 4297 if (read_more) 4298 read_more.click(); 4299 } 4300 } else { 4301 amp_unhide_access_hide('*="premium_access OR"', '', '.ad-wrap'); 4302 let paywall = document.querySelector('[class*="paywall-container"]'); 4303 removeDOMElement(paywall); 4304 } 4305 } 4306 4307 else if (matchDomain('slate.com')) { 4308 let slate_roadblock = document.querySelector('.slate-roadblock'); 4309 let ads = document.querySelectorAll('section[class*="-ad"]'); 4310 removeDOMElement(slate_roadblock, ...ads); 4311 } 4312 4313 else if (matchDomain('slideshare.net')) { 4314 let limit_overlay = document.querySelector('.limit-overlay'); 4315 if (limit_overlay) 4316 limit_overlay.classList.remove('limit-overlay'); 4317 } 4318 4319 else if (matchDomain('sloanreview.mit.edu')) { 4320 let url = window.location.href; 4321 let paywall = document.querySelector('body.is-paywall'); 4322 if (paywall) { 4323 paywall.classList.remove('is-paywall'); 4324 csDoneOnce = true; 4325 let url_cache = 'https://webcache.googleusercontent.com/search?q=cache:' + url.split('?')[0]; 4326 replaceDomElementExt(url_cache, true, false, 'div#article-content'); 4327 } 4328 } 4329 4330 else if (matchDomain('sofrep.com')) { 4331 let paywall = document.querySelector('div.paywall'); 4332 if (paywall) { 4333 paywall.removeAttribute('class'); 4334 let intro = document.querySelector('div.non-paywall'); 4335 removeDOMElement(intro); 4336 waitDOMElement('div#paywall_wrap', 'DIV', node => removeDOMElement(node.parentNode)); 4337 } 4338 let banners = document.querySelectorAll('#scrollerCTA, #botCta'); 4339 removeDOMElement(...banners); 4340 } 4341 4342 else if (matchDomain('spglobal.com')) { 4343 let overlay = document.querySelector('.article__overlay'); 4344 removeDOMElement(overlay); 4345 let html_noscroll = document.querySelector('html[class]'); 4346 if (html_noscroll) 4347 html_noscroll.removeAttribute('class'); 4348 } 4349 4350 else if (matchDomain('sportico.com')) { 4351 if (window.location.pathname.endsWith('/amp/')) 4352 amp_unhide_subscr_section('amp-ad, amp-embed', false); 4353 } 4354 4355 else if (matchDomain('staradvertiser.com')) { 4356 if (window.location.pathname.endsWith('/amp/')) { 4357 amp_unhide_subscr_section(); 4358 } else { 4359 let paywall = document.querySelector('div#hsa-paywall-overlay'); 4360 if (paywall) { 4361 removeDOMElement(paywall); 4362 let div_hidden = document.querySelector('div#hsa-paywall-content[style]'); 4363 if (div_hidden) 4364 div_hidden.removeAttribute('style'); 4365 } 4366 } 4367 } 4368 4369 else if (matchDomain('startribune.com')) { 4370 let modal = document.querySelector('body.ReactModal__Body--open'); 4371 if (modal) 4372 modal.classList.remove('ReactModal__Body--open'); 4373 let banner = document.querySelector('div#meterContent, div[class*="Limit-container-"]'); 4374 let banner_modal; 4375 if (banner) 4376 banner_modal = banner.closest('div.ReactModalPortal'); 4377 let ads = document.querySelectorAll('div.ad-placeholder'); 4378 removeDOMElement(banner_modal, ...ads); 4379 } 4380 4381 else if (matchDomain('statista.com')) { 4382 if (window.location.pathname.startsWith('/outlook/')) { 4383 let promo = document.querySelector('section#promotionElement'); 4384 let chartbox_paywall = document.querySelectorAll('div.xmoChartBoxPaywall'); 4385 removeDOMElement(promo, ...chartbox_paywall); 4386 let blurred = document.querySelectorAll('.blurred'); 4387 for (let elem of blurred) 4388 elem.removeAttribute('class'); 4389 } 4390 } 4391 4392 else if (matchDomain('stereogum.com')) { 4393 let paywall = document.querySelector('div.members-only-overlay-wrapper'); 4394 if (paywall && dompurify_loaded) { 4395 removeDOMElement(paywall); 4396 let json_url_dom = document.querySelector('link[rel="alternate"][type="application/json"][href]'); 4397 let json_url = json_url_dom.href; 4398 fetch(json_url) 4399 .then(response => { 4400 if (response.ok) { 4401 response.json().then(json => { 4402 try { 4403 let json_text = json.acf.article_modules[0].copy.replace(/data-src/g, 'src'); 4404 let content = document.querySelector('div.article__content div.text-block__inner'); 4405 if (json_text && content) { 4406 let parser = new DOMParser(); 4407 let doc = parser.parseFromString('<div>' + DOMPurify.sanitize(json_text, {ADD_TAGS: ['iframe'], ADD_ATTR: ['frameborder', 'allow', 'allowfullscreen']}) + '</div>', 'text/html'); 4408 let content_new = doc.querySelector('div'); 4409 content.innerHTML = ''; 4410 content.appendChild(content_new); 4411 } 4412 } catch (err) { 4413 console.log(err); 4414 } 4415 }); 4416 } 4417 }); 4418 } 4419 } 4420 4421 else if (matchDomain('stocknews.com')) { 4422 let hideme = document.querySelector('div#hideme'); 4423 removeDOMElement(hideme); 4424 let blurmes = document.querySelectorAll('div[id^="blurme"]'); 4425 for (let i = 0; i < blurmes.length; i++) 4426 blurmes[i].setAttribute('id', 'blurmenot' + i); 4427 } 4428 4429 else if (matchDomain('studocu.com')) { 4430 window.setTimeout(function () { 4431 let paywall = document.querySelector('button[data-test-selector^="preview-banner-"]'); 4432 if (paywall) { 4433 let paywall_banner = document.querySelector('#document-wrapper > div:not([style])'); 4434 let banners = document.querySelectorAll('div.pf > :not(.page-content), div#premium-page-header'); 4435 removeDOMElement(paywall_banner, ...banners); 4436 window.setTimeout(function () { 4437 let blurred_pages = document.querySelectorAll('div.page-content[style]'); 4438 for (let blurred_page of blurred_pages) { 4439 let page = document.createElement('span'); 4440 page.setAttribute('class', 'page-content'); 4441 page.appendChild(blurred_page.firstChild); 4442 blurred_page.parentNode.replaceChild(page, blurred_page); 4443 } 4444 }, 2000); 4445 } 4446 }, 1000); 4447 } 4448 4449 else if (matchDomain('swarajyamag.com')) { 4450 let paywall = document.querySelector('div#story-notification'); 4451 if (paywall) { 4452 removeDOMElement(paywall); 4453 let non_subscriber_text = document.querySelector('div#non-subscriber-text'); 4454 if (non_subscriber_text) 4455 non_subscriber_text.removeAttribute('id'); 4456 let subscriber_text = document.querySelectorAll('div.subscriber-text'); 4457 for (let elem of subscriber_text) 4458 elem.removeAttribute('class'); 4459 } 4460 } 4461 4462 else if (matchDomain('techinasia.com')) { 4463 let paywall = document.querySelector('.paywall-content'); 4464 if (paywall && dompurify_loaded) { 4465 paywall.classList.remove('paywall-content'); 4466 let url = window.location.href; 4467 let url_xhr = url.replace('.com/', '.com/wp-json/techinasia/2.0/posts/').replace('/visual-story/', '/'); 4468 fetch(url_xhr) 4469 .then(response => { 4470 if (response.ok) { 4471 response.json().then(json => { 4472 let json_text = json.posts[0].content; 4473 json_text = json_text.replace(/width\=\"(\d){3,}\"/g, 'width="100%"').replace(/height\=\"(\d){3,}\"/g, 'height="100%"'); 4474 let content = document.querySelector('div.content'); 4475 if (json_text && content) { 4476 let parser = new DOMParser(); 4477 let doc = parser.parseFromString('<div class="jsx-1794864983 content">' + DOMPurify.sanitize(json_text) + '</div>', 'text/html'); 4478 let content_new = doc.querySelector('div.content'); 4479 content.parentNode.replaceChild(content_new, content); 4480 } 4481 }); 4482 } 4483 }); 4484 } 4485 let splash_subscribe = document.querySelector('.splash-subscribe'); 4486 let paywall_hard = document.querySelector('.paywall-hard'); 4487 removeDOMElement(splash_subscribe, paywall_hard); 4488 } 4489 4490 else if (matchDomain(['techtarget.com', 'computerweekly.com', 'lemagit.fr'])) { 4491 let paywall = document.querySelector('div.paywall'); 4492 if (paywall) { 4493 paywall.classList.remove('paywall'); 4494 let banners = document.querySelectorAll('p#firstP, div#inlineRegistrationWrapper'); 4495 removeDOMElement(...banners); 4496 } 4497 } 4498 4499 else if (matchDomain('the-american-interest.com')) { 4500 let counter = document.getElementById('article-counter'); 4501 removeDOMElement(counter); 4502 } 4503 4504 else if (matchDomain('theathletic.com')) { 4505 if (!(window.location.search.match(/(\?|&)amp/) && !document.querySelector('link[rel="amphtml"]'))) { 4506 function theathletic_func(node) { 4507 removeDOMElement(node); 4508 let overlays = document.querySelectorAll('div[id*="overlay"], div:empty:not([data-rjs])'); 4509 hideDOMElement(...overlays); 4510 let body = document.querySelector('body'); 4511 if (body) { 4512 body.style.overflow = 'visible'; 4513 body.style.position = 'relative'; 4514 } 4515 } 4516 waitDOMElement('div[id^="slideup-"]', 'DIV', theathletic_func); 4517 csDoneOnce = true; 4518 } else { 4519 amp_unhide_subscr_section(); 4520 amp_unhide_access_hide('', '*="NOT granted"'); 4521 } 4522 let apron = document.querySelector('div#free-apron-cta, div.slideup-free-apron-container'); 4523 let ads = document.querySelectorAll('div.ad-container'); 4524 removeDOMElement(apron, ...ads); 4525 } 4526 4527 else if (matchDomain('theatlantic.com')) { 4528 let lazy_images = document.querySelectorAll('img.Image_lazy__tutlP'); 4529 for (let elem of lazy_images) 4530 elem.classList.remove('Image_lazy__tutlP'); 4531 let banners = document.querySelectorAll('.c-nudge__container, .c-non-metered-nudge, div[class^="ArticleInjector_"]'); 4532 hideDOMElement(...banners); 4533 } 4534 4535 else if (matchDomain('thebulletin.org')) { 4536 let url = window.location.href; 4537 let paywall = document.querySelector('div.article--cropped'); 4538 if (paywall) { 4539 removeDOMElement(paywall); 4540 csDoneOnce = true; 4541 let url_cache = 'https://webcache.googleusercontent.com/search?q=cache:' + url.split('?')[0]; 4542 replaceDomElementExt(url_cache, true, false, 'div#body-copy'); 4543 } 4544 } 4545 4546 else if (matchDomain('thedailybeast.com')) { 4547 let paywall = document.querySelector('div.Body__paywall-container'); 4548 if (paywall) { 4549 removeDOMElement(paywall); 4550 let json_script = document.querySelector('script[displayName="initialState"]'); 4551 if (json_script) { 4552 let json_str = json_script.text.substring(json_script.textContent.indexOf('{')); 4553 try { 4554 let json = JSON.parse(json_str); 4555 if (json.body) { 4556 let pars = json.body.sections; 4557 let cards = json.body.cards; 4558 if (pars) { 4559 let mobile_doc = document.querySelector('div.Mobiledoc'); 4560 if (mobile_doc) { 4561 let mobile_doc_text = mobile_doc.innerText.replace(/(\r|\n)/g, ''); 4562 for (let elem of pars) { 4563 let par_elem = ''; 4564 if (elem[0] === 1) { 4565 if (elem[1] === 'p') { 4566 let par = ''; 4567 for (let part of elem[2]) 4568 par += part[3]; 4569 if (par && !mobile_doc_text.includes(par)) { 4570 par_elem = document.createElement('p'); 4571 par_elem.innerText = par; 4572 } 4573 } 4574 } else if (elem[0] === 10) { 4575 if (cards && cards[elem[1]]) { 4576 let card = cards[elem[1]]; 4577 if (card[0] === 'pt-image') { 4578 par_elem = document.createElement('p'); 4579 let par_fig = document.createElement('figure'); 4580 let par_img = document.createElement('img'); 4581 par_img.src = card[1].url; 4582 par_fig.appendChild(par_img); 4583 par_elem.appendChild(par_fig); 4584 let par_cap = document.createElement('figcaption'); 4585 par_cap.innerText = card[1].title + ' ' + card[1].credit; 4586 par_elem.appendChild(par_cap); 4587 } else if (card[0] === 'pt-fancy-links-card') { 4588 par_elem = document.createElement('p'); 4589 let par_link = document.createElement('a'); 4590 par_link.href = card[1].links; 4591 par_link.innerText = card[1].linksData[0].long_headline; 4592 par_elem.appendChild(par_link); 4593 } 4594 } 4595 } 4596 if (par_elem) 4597 mobile_doc.appendChild(par_elem); 4598 } 4599 } 4600 } 4601 } 4602 csDoneOnce = true; 4603 } catch (err) { 4604 console.log(err); 4605 } 4606 } 4607 } 4608 } 4609 4610 else if (matchDomain('thediplomat.com')) { 4611 let preview = document.querySelector('.dpl-preview'); 4612 if (preview) 4613 preview.classList.remove('dpl-preview'); 4614 } 4615 4616 else if (matchDomain('theglobeandmail.com')) { 4617 if (!window.location.search.startsWith('?rel=premium')) { 4618 let paywall = document.querySelector('div.c-paywall'); 4619 if (paywall) { 4620 removeDOMElement(paywall); 4621 window.location.href = window.location.pathname + '?rel=premium'; 4622 } 4623 } else { 4624 let header_hidden = document.querySelectorAll('div.o-primary-header, div.c-article-meta'); 4625 for (let elem of header_hidden) 4626 elem.setAttribute('style', 'display: block !important;'); 4627 } 4628 let lazy_images = document.querySelectorAll('img[src^="data:image/"][data-src]'); 4629 for (let elem of lazy_images) 4630 elem.src = elem.getAttribute('data-src'); 4631 let banners = document.querySelectorAll('div.c-ad, div#subscription-pencil-area, div.marketing-container-wrapper, div[class^="BaseAd__"]'); 4632 hideDOMElement(...banners); 4633 } 4634 4635 else if (matchDomain(['thehindu.com', 'thehindubusinessline.com'])) { 4636 if (!window.location.pathname.endsWith('/amp/')) { 4637 let counter = document.querySelector('#test'); 4638 let ads = document.querySelectorAll('.ad, .article-ad, .dfp-ad'); 4639 removeDOMElement(counter, ...ads); 4640 } else { 4641 let ads = document.querySelectorAll('amp-ad, amp-embed, [class^="height"], [class^="advt"], [id^="piano"]'); 4642 removeDOMElement(...ads); 4643 } 4644 function hindu_main() { 4645 if (window) { 4646 window.Adblock = false; 4647 window.isNonSubcribed = false; 4648 } 4649 } 4650 insert_script(hindu_main); 4651 } 4652 4653 else if (matchDomain('theinitium.com')) { 4654 let paywall = document.querySelector('section.c-wall'); 4655 removeDOMElement(paywall); 4656 } 4657 4658 else if (matchDomain(['thejuggernaut.com', 'jgnt.co'])) { 4659 let paywall = pageContains('div.font-mono', /\Read this article and many more by subscribing today/); 4660 if (paywall.length) { 4661 removeDOMElement(paywall[0].parentNode); 4662 let json_script = document.querySelector('script#__NEXT_DATA__'); 4663 if (json_script) { 4664 try { 4665 let json = JSON.parse(json_script.innerText); 4666 if (json && json.props.pageProps.post) { 4667 let url_next = json.query.slug; 4668 if (url_next && !window.location.pathname.includes(url_next)) 4669 refreshCurrentTab(); 4670 let pars = json.props.pageProps.post.fields.textEssay.fields.body.content; 4671 let article = document.querySelector('div.opacity-50'); 4672 if (article) { 4673 article.innerHTML = ''; 4674 article.removeAttribute('class'); 4675 let par_first = true; 4676 function attach_text(sub_item, elem) { 4677 if (sub_item.value) { 4678 let sub_elem = document.createElement('span'); 4679 sub_elem.innerText = sub_item.value; 4680 if (sub_item.marks && sub_item.marks.length) { 4681 let style = ''; 4682 for (let mark of sub_item.marks) { 4683 if (mark.type === 'bold') 4684 style += 'font-weight: bold;'; 4685 else if (mark.type === 'italic') 4686 style += 'font-style: italic;'; 4687 else if (mark.type === 'underline') 4688 style += 'text-decoration: underline;'; 4689 } 4690 sub_elem.style = style; 4691 } 4692 elem.appendChild(sub_elem); 4693 } 4694 } 4695 function attach_hyperlink(sub_item, elem) { 4696 if (sub_item.content && sub_item.content[0] && sub_item.content[0].value && sub_item.data && sub_item.data.uri) { 4697 let sub_elem = document.createElement('a'); 4698 sub_elem.href = sub_item.data.uri; 4699 sub_elem.innerText = sub_item.content[0].value; 4700 if (!matchUrlDomain(['thejuggernaut.com', 'jgnt.co'], sub_item.data.uri)) 4701 sub_elem.target = '_blank'; 4702 sub_elem.style = 'text-decoration: underline;'; 4703 elem.appendChild(sub_elem); 4704 } 4705 } 4706 function attach_paragraph(par, elem) { 4707 if (par.content && par.content.length) { 4708 let span_elem = document.createElement('span'); 4709 for (let item of par.content) { 4710 if (item.nodeType === 'text') { 4711 attach_text(item, span_elem); 4712 } else if (item.nodeType === 'hyperlink') { 4713 attach_hyperlink(item, span_elem); 4714 } else 4715 console.log(item); 4716 } 4717 elem.appendChild(span_elem); 4718 } 4719 } 4720 for (let par of pars) { 4721 let elem = document.createElement('p'); 4722 if (['paragraph', 'heading-1'].includes(par.nodeType)) { 4723 attach_paragraph(par, elem); 4724 } else if (['blockquote'].includes(par.nodeType)) { 4725 if (par.content && par.content.length) { 4726 for (let item of par.content) { 4727 if (item.nodeType === 'paragraph') { 4728 elem.style = 'margin: 0px 20px; font-style: italic;'; 4729 attach_paragraph(item, elem); 4730 } else 4731 console.log(item); 4732 } 4733 } 4734 } else if (par.nodeType === 'hr') { 4735 elem.appendChild(document.createElement('hr')); 4736 } else if (par.nodeType === 'embedded-asset-block') { 4737 if (!par_first) { 4738 if (par.data && par.data.target && par.data.target.fields) { 4739 if (par.data.target.fields.file && par.data.target.fields.file.url) { 4740 let figure = document.createElement('figure'); 4741 let img = document.createElement('img'); 4742 img.src = par.data.target.fields.file.url; 4743 figure.appendChild(img); 4744 if (par.data.target.fields.description) { 4745 let caption = document.createElement('figcaption'); 4746 caption.innerText = par.data.target.fields.description; 4747 figure.appendChild(caption); 4748 } 4749 elem.appendChild(figure); 4750 } 4751 } 4752 } else 4753 par_first = false; 4754 } else if (par.nodeType === 'unordered-list') { 4755 if (par.content && par.content.length) { 4756 let ul = document.createElement('ul'); 4757 for (let item of par.content) { 4758 if (item.nodeType === 'list-item') { 4759 if (item.content) { 4760 for (let sub_item_par of item.content) { 4761 if (sub_item_par.nodeType === 'paragraph') { 4762 let li = document.createElement('li'); 4763 attach_paragraph(sub_item_par, li); 4764 ul.appendChild(li); 4765 } 4766 } 4767 } 4768 } else 4769 console.log(item); 4770 } 4771 elem.appendChild(ul); 4772 } 4773 } else { 4774 console.log(par); 4775 } 4776 if (elem.hasChildNodes) { 4777 article.appendChild(document.createElement('br')); 4778 article.appendChild(elem); 4779 } 4780 } 4781 } 4782 } else 4783 refreshCurrentTab(); 4784 } catch (err) { 4785 console.log(err); 4786 } 4787 } 4788 } 4789 } 4790 4791 else if (matchDomain('thelawyersdaily.ca')) { 4792 if (window.location.pathname.startsWith('/amp/')) { 4793 ampToHtml(); 4794 } else { 4795 let modal = document.querySelectorAll('#NewsletterModal, .modal-backdrop'); 4796 removeDOMElement(...modal); 4797 } 4798 } 4799 4800 else if (matchDomain('thenewatlantis.com')) { 4801 let article_gated = document.querySelector('.article-gated'); 4802 if (article_gated) 4803 article_gated.classList.remove('article-gated'); 4804 } 4805 4806 else if (matchDomain('thepointmag.com')) { 4807 let overlay = document.querySelectorAll('div.overlay, div#tpopup-'); 4808 removeDOMElement(...overlay); 4809 } 4810 4811 else if (matchDomain('thequint.com')) { 4812 let paywall = document.querySelector('div.zsqcu'); 4813 if (paywall) { 4814 removeDOMElement(paywall); 4815 let body_hidden = document.querySelector('div#story-body-wrapper'); 4816 if (body_hidden) 4817 body_hidden.removeAttribute('class'); 4818 function thequint_unhide(node) { 4819 node.removeAttribute('class'); 4820 } 4821 waitDOMAttribute('div#story-body-wrapper', 'DIV', 'class', thequint_unhide, true); 4822 } 4823 } 4824 4825 else if (matchDomain('theverge.com')) { 4826 let paywall = document.querySelector('div.bg-paywall-fade'); 4827 if (paywall && dompurify_loaded) { 4828 removeDOMElement(paywall); 4829 let json_script = document.querySelector('script#__NEXT_DATA__'); 4830 if (json_script) { 4831 try { 4832 let json = JSON.parse(json_script.text); 4833 let article = document.querySelector('div.duet--article--article-body-component-container'); 4834 if (json && article) { 4835 let json_pars = json.props.pageProps.hydration.responses[0].data.entryRevision.body.components; 4836 article.innerHTML = ''; 4837 let parser = new DOMParser(); 4838 for (let par of json_pars) { 4839 let elem = document.createElement('p'); 4840 elem.style = 'margin: 20px 0px;'; 4841 let type = par.__typename; 4842 if (['EntryBodyParagraph', 'EntryBodyHeading'].includes(type)) { 4843 if (par.contents && par.contents.html) { 4844 if (type === 'EntryBodyHeading') 4845 elem.style = 'font-weight: bold;'; 4846 let doc = parser.parseFromString('<div>' + DOMPurify.sanitize(par.contents.html) + '</div>', 'text/html'); 4847 elem.appendChild(doc.querySelector('div')); 4848 } 4849 } else if (type === 'EntryBodyHorizontalRule') { 4850 elem.appendChild(document.createElement('hr')); 4851 } else if (type === 'EntryBodyImage') { 4852 if (par.image && par.image.url) { 4853 let figure = document.createElement('figure'); 4854 if (par.image.asset && par.image.asset.title) 4855 figure.appendChild(document.createTextNode(par.image.asset.title)); 4856 let img = document.createElement('img'); 4857 img.src = par.image.url; 4858 figure.appendChild(img); 4859 if (par.image.caption && par.image.caption.html) { 4860 let caption = document.createElement('figcaption'); 4861 caption.innerText = par.image.caption.html; 4862 if (par.image.credit && par.image.credit.html) 4863 caption.innerText += ' - ' + par.image.credit.html; 4864 figure.appendChild(caption); 4865 } 4866 elem.appendChild(figure); 4867 } 4868 } else if (type === 'EntryBodyPullquote') { 4869 if (par.quote && par.quote.html) { 4870 let doc = parser.parseFromString('<div>' + DOMPurify.sanitize(par.quote.html) + '</div>', 'text/html'); 4871 elem.appendChild(doc.querySelector('div')); 4872 } 4873 } else if (type === 'EntryBodyBlockquote') { 4874 if (par.paragraphs) { 4875 for (let quote_par of par.paragraphs) { 4876 if (quote_par.contents && quote_par.contents.html) { 4877 let doc = parser.parseFromString('<div>' + DOMPurify.sanitize(quote_par.contents.html) + '</div>', 'text/html'); 4878 elem.appendChild(doc.querySelector('div')); 4879 } 4880 } 4881 } 4882 } else if (type === 'EntryBodyList') { 4883 if (par.items) { 4884 let ul = document.createElement('ul'); 4885 for (let item of par.items) { 4886 if (item.line && item.line.html) { 4887 let li = document.createElement('li'); 4888 let doc = parser.parseFromString('<div>' + DOMPurify.sanitize(item.line.html) + '</div>', 'text/html'); 4889 li.appendChild(doc.querySelector('div')); 4890 ul.appendChild(li); 4891 } 4892 } 4893 elem.appendChild(ul); 4894 } 4895 } else 4896 console.log(par); 4897 if (elem.hasChildNodes) 4898 article.appendChild(elem); 4899 } 4900 } 4901 } catch (err) { 4902 console.log(err); 4903 } 4904 } 4905 } 4906 } 4907 4908 else if (matchDomain('thewrap.com')) { 4909 let paywall = document.querySelector('.wrappro-paywall'); 4910 if (paywall) 4911 paywall.classList.remove('wrappro-paywall'); 4912 } 4913 4914 else if (matchDomain('timeshighereducation.com')) { 4915 let paywall_cta = document.querySelector('div.paywall-cta'); 4916 if (paywall_cta) { 4917 paywall_cta.removeAttribute('style'); 4918 let hidden_divs = document.querySelectorAll('div[style="display: none;"]'); 4919 for (let hidden_div of hidden_divs) 4920 hidden_div.removeAttribute('style'); 4921 let paywall_fade = document.querySelector('div.paywall-fade'); 4922 if (paywall_fade) 4923 paywall_fade.classList.remove('paywall-fade'); 4924 } 4925 let hidden_images = document.querySelectorAll('img.b-lazy[src^="data:image/"][data-src]'); 4926 for (let hidden_image of hidden_images) { 4927 hidden_image.setAttribute('src', hidden_image.getAttribute('data-src')); 4928 hidden_image.classList.remove('b-lazy'); 4929 hidden_image.parentElement.classList.remove('media--loading'); 4930 } 4931 let ads = document.querySelectorAll('div[id^="div-gpt-in-article-ad-"], div[class^="the-dfp__in-article-ATD"]'); 4932 removeDOMElement(...ads); 4933 } 4934 4935 else if (matchDomain(timesofindia_domains)) { 4936 let url = window.location.href; 4937 let region_block = document.querySelector('div.plan-popup.active'); 4938 if (region_block) { 4939 removeDOMElement(region_block); 4940 let overflow = document.querySelector('html[style]'); 4941 if (overflow) 4942 overflow.removeAttribute('style'); 4943 } 4944 if (!window.location.pathname.includes('/amp_')) { 4945 let paywall = document.querySelector('div#story-blocker'); 4946 let amphtml = document.querySelector('link[rel="amphtml"]'); 4947 if (!amphtml) 4948 amphtml = {href: url.replace('/timesofindia.indiatimes.com/', '/m.timesofindia.com/').replace('/articleshow/', '/amp_articleshow/')}; 4949 if (paywall && amphtml) { 4950 removeDOMElement(paywall); 4951 window.location.href = amphtml.href; 4952 } 4953 } else { 4954 let amp_images = document.querySelectorAll('div.inline-image > div.inline-imgecontent > amp-img[src]'); 4955 for (let amp_image of amp_images) { 4956 amp_image.parentNode.removeAttribute('class'); 4957 amp_image.parentNode.parentNode.removeAttribute('class'); 4958 let elem = document.createElement('img'); 4959 Object.assign(elem, { 4960 src: amp_image.getAttribute('src'), 4961 alt: amp_image.getAttribute('alt') 4962 }); 4963 amp_image.parentNode.replaceChild(elem, amp_image); 4964 } 4965 } 4966 } 4967 4968 else if (matchDomain(no_nhst_media_domains)) { 4969 let url = window.location.href; 4970 if (url.includes('.tradewindsnews.com/markets/')) { 4971 let paywall = document.querySelector('iframe[src]'); 4972 removeDOMElement(paywall); 4973 let overflow = document.querySelector('body[style]'); 4974 if (overflow) 4975 overflow.removeAttribute('style'); 4976 let blurred = document.querySelector('body > div[style]'); 4977 if (blurred) 4978 blurred.removeAttribute('style'); 4979 } else { 4980 window.setTimeout(function () { 4981 let paywall = document.querySelector('iframe#paywall-iframe'); 4982 if (paywall && dompurify_loaded) { 4983 let intro = document.querySelector('div.global-article-selector'); 4984 let article = paywall.parentNode; 4985 removeDOMElement(paywall, intro); 4986 fetch(url) 4987 .then(response => { 4988 if (response.ok) { 4989 response.text().then(html => { 4990 let split1 = html.split('window.__INITIAL_STATE__=')[1]; 4991 let state = (split1.split('};')[0] + '}').split('</script>')[0]; 4992 if (state) { 4993 let json = JSON.parse(state); 4994 if (json) { 4995 let json_text = json.article.body; 4996 let parser = new DOMParser(); 4997 let doc = parser.parseFromString('<div>' + DOMPurify.sanitize(json_text, {ADD_ATTR: ['itemprop'], ADD_TAGS: ['link']}) + '</div>', 'text/html'); 4998 let article_new = doc.querySelector('div'); 4999 if (article && article_new) 5000 article.appendChild(article_new); 5001 let promo = document.querySelectorAll('div[data-ah5-type="promobox"], div.dn-relation-block'); 5002 removeDOMElement(...promo); 5003 } 5004 } 5005 }) 5006 } 5007 }) 5008 } 5009 }, 500); 5010 } 5011 } 5012 5013 else if (matchDomain(usa_conde_nast_domains)) { 5014 if (window.location.pathname.endsWith('/amp')) { 5015 amp_unhide_subscr_section('amp-ad, amp-embed, .ad'); 5016 } else { 5017 let banners = document.querySelectorAll('.paywall-bar, div[class^="MessageBannerWrapper-"'); 5018 removeDOMElement(...banners); 5019 } 5020 } 5021 5022 else if (matchDomain(usa_craincomm_domains)) { 5023 let body_hidden = document.querySelector('body[class]'); 5024 if (body_hidden) 5025 body_hidden.removeAttribute('class'); 5026 let lazy_images = document.querySelectorAll('img.lazy[data-src]'); 5027 for (let lazy_image of lazy_images) { 5028 lazy_image.src = lazy_image.getAttribute('data-src'); 5029 lazy_image.removeAttribute('class'); 5030 } 5031 let lazy_sources = document.querySelectorAll('source[srcset^="data:image"]'); 5032 removeDOMElement(...lazy_sources); 5033 let sponsored_article = document.querySelector('div.sponsored-article'); 5034 if (sponsored_article) 5035 sponsored_article.classList.remove('sponsored-article'); 5036 } 5037 5038 else if (matchDomain(usa_genomeweb_domains)) { 5039 let banners = document.querySelectorAll('div.footer__ads-footer'); 5040 removeDOMElement(...banners); 5041 } 5042 5043 else if (matchDomain(usa_outside_mag_domains)) { 5044 let paywall = document.querySelector('div.o-membership-overlay'); 5045 if (paywall) { 5046 let is_gated = document.querySelectorAll('[class*="is-gated"]'); 5047 for (let elem of is_gated) 5048 removeClassesByPrefix(elem, 'is-gated'); 5049 removeDOMElement(paywall); 5050 } 5051 if (matchDomain('cyclingtips.com')) { 5052 localStorage.removeItem('av'); 5053 let ads = document.querySelectorAll('div[data-block-name="ads"], div#takeover'); 5054 removeDOMElement(...ads); 5055 } 5056 } 5057 5058 else if (matchDomain(usa_tribune_domains)) { 5059 let overlay = document.querySelector('div#zephr-overlay'); 5060 removeDOMElement(overlay); 5061 } 5062 5063 else if (matchDomain('usatoday.com')) { 5064 if (window.location.hostname.startsWith('amp.')) { 5065 amp_unhide_access_hide('="gup.hasAssetAccess"', '', 'div[class*="ad-"]'); 5066 } else { 5067 let roadblock = document.querySelector('.roadblock-container'); 5068 if (roadblock) { 5069 removeDOMElement(roadblock); 5070 article_next = document.querySelector('article.next-in-depth-story > div.article-inner'); 5071 if (article_next) { 5072 let url = article_next.getAttribute('data-url'); 5073 let weblink = document.createElement('a'); 5074 weblink.href = url; 5075 weblink.innerText = 'open next in-depth story'; 5076 article_next.appendChild(weblink); 5077 } 5078 } 5079 } 5080 } 5081 5082 else if (matchDomain('venturebeat.com')) { 5083 window.setTimeout(function () { 5084 let paywall = document.querySelector('div.paywall'); 5085 if (paywall) 5086 paywall.classList.remove('paywall'); 5087 }, 500); 5088 } 5089 5090 else if (matchDomain('washingtonpost.com')) { 5091 let leaderboard = document.querySelector('#leaderboard-wrapper'); 5092 let adverts = document.querySelectorAll('div[data-qa$="-ad"]'); 5093 removeDOMElement(leaderboard, ...adverts); 5094 } 5095 5096 else if (matchDomain('winnipegfreepress.com')) { 5097 let ads = document.querySelectorAll('.billboard-ad-space, .ad, .article-ad, .fixed-sky'); 5098 removeDOMElement(...ads); 5099 } 5100 5101 else if (matchDomain('wsj.com')) { 5102 let url = window.location.href; 5103 if (location.href.includes('/articles/')) { 5104 let close_button = document.querySelector('div.close-btn[role="button"]'); 5105 if (close_button) 5106 close_button.click(); 5107 } 5108 let wsj_ads = document.querySelectorAll('div.wsj-ad, div.adWrapper'); 5109 removeDOMElement(...wsj_ads); 5110 if (url.includes('/amp/')) { 5111 let masthead_link = document.querySelector('div.masthead > a[href*="/articles/"]'); 5112 if (masthead_link) 5113 masthead_link.href = 'https://www.wsj.com'; 5114 amp_unhide_subscr_section(); 5115 } else { 5116 let snippet = document.querySelector('.snippet-promotion, div#cx-snippet-overlay'); 5117 let wsj_pro = document.querySelector('meta[name="page.site"][content="wsjpro"]'); 5118 if (snippet || wsj_pro) { 5119 removeDOMElement(snippet, wsj_pro); 5120 window.location.href = url.replace('wsj.com', 'wsj.com/amp'); 5121 } 5122 } 5123 } 5124 5125 else if (matchDomain('zerohedge.com')) { 5126 window.setTimeout(function () { 5127 let paywall = document.querySelector('div[class^="PremiumOverlay_container__"]'); 5128 if (paywall && dompurify_loaded) { 5129 removeDOMElement(paywall); 5130 let json_script = document.querySelector('script#__NEXT_DATA__'); 5131 if (json_script) { 5132 try { 5133 let json = JSON.parse(json_script.innerText); 5134 if (json && json.props.pageProps.node.body) { 5135 let article_new = parseHtmlEntities(decode_utf8(atob(json.props.pageProps.node.body.substring(21)))); 5136 let article = document.querySelector('div[class^="NodeContent_mainContent__"'); 5137 if (article) { 5138 article.innerHTML = ''; 5139 let parser = new DOMParser(); 5140 let doc = parser.parseFromString('<div>' + DOMPurify.sanitize(article_new) + '</div>', 'text/html'); 5141 let content_new = doc.querySelector('div'); 5142 article.appendChild(content_new); 5143 } 5144 } 5145 } catch (err) { 5146 console.log(err); 5147 } 5148 } 5149 } 5150 }, 1000); 5151 } 5152 5153 else if (matchDomain(usa_gannett_domains) || document.querySelector('img[srcset^="https://www.gannett-cdn.com/"], link[href*=".gannett-cdn.com/"]')) { 5154 if (window.location.pathname.endsWith('/restricted/') && window.location.search.startsWith('?return=')) 5155 window.location.href = decodeURIComponent(window.location.href.split('?return=')[1]); 5156 } 5157 5158 else if ((domain = matchDomain(usa_lee_ent_domains)) || matchDomain(ca_torstar_domains) || document.querySelector('script[src*=".townnews.com/"][src*="/tncms/"]')) { 5159 if (window.location.pathname.endsWith('.amp.html')) { 5160 amp_unhide_access_hide('="hasAccess"', '="NOT hasAccess"', 'amp-ad, amp-embed, .amp-ads-container'); 5161 let elem_hidden = document.querySelectorAll('html[class], body[class]'); 5162 for (let elem of elem_hidden) 5163 elem.removeAttribute('class'); 5164 let amp_images = document.querySelectorAll('div.main-content amp-img[src^="https://"]'); 5165 for (let amp_image of amp_images) { 5166 let elem = document.createElement('img'); 5167 Object.assign(elem, { 5168 src: amp_image.getAttribute('src'), 5169 alt: amp_image.getAttribute('alt'), 5170 height: '400' 5171 }); 5172 amp_image.parentNode.replaceChild(elem, amp_image); 5173 } 5174 } else { 5175 if (!domain) { 5176 function unscramble(t) { 5177 for (var n = "", i = 0, r = t.length; i < r; i++) { 5178 var s = t.charCodeAt(i); 5179 if (s >= 33 && s <= 126) { 5180 var sTmp = String.fromCharCode(33 + (s - 33 + 47) % 94); 5181 n += sTmp; 5182 } else 5183 n += t.charAt(i); 5184 } 5185 return n; 5186 } 5187 let subscriber_only = document.querySelectorAll('div.subscriber-only'); 5188 for (let elem of subscriber_only) { 5189 if (elem.classList.contains('encrypted-content') && dompurify_loaded) { 5190 let parser = new DOMParser(); 5191 let doc = parser.parseFromString('<div>' + DOMPurify.sanitize(unscramble(elem.innerText)) + '</div>', 'text/html'); 5192 let content_new = doc.querySelector('div'); 5193 elem.parentNode.replaceChild(content_new, elem); 5194 } 5195 elem.removeAttribute('style'); 5196 elem.removeAttribute('class'); 5197 } 5198 let banners = document.querySelectorAll('div.subscription-required, div.redacted-overlay'); 5199 removeDOMElement(...banners); 5200 } 5201 let ads = document.querySelectorAll('div.tnt-ads-container'); 5202 removeDOMElement(...ads); 5203 } 5204 } 5205 5206 else if ((domain = matchDomain(usa_mcc_domains)) || 5207 (window.location.hostname.startsWith('account.') && document.querySelector('script[src*=".mcclatchyinteractive.com/"]')) || 5208 (window.location.href.match(/\/\/amp\..+\.com\/(.+\/)?article(\d){8,}\.html/) && document.querySelector('a[href^="https://classifieds.mcclatchy.com/"]'))) { 5209 let url = window.location.href; 5210 let hostname = window.location.hostname; 5211 if (!domain) 5212 domain = hostname.replace(/^(account|amp)\./, ''); 5213 if (hostname.startsWith('account.') && window.location.search.startsWith('?resume=')) { 5214 window.setTimeout(function () { 5215 window.location.href = 'https://amp.' + domain + '/article' + url.split('resume=')[1].split(/[#&]/)[0] + '.html'; 5216 }, 500); 5217 } else if (url.includes('amp.' + domain + '/')) { 5218 amp_unhide_subscr_section('amp-ad, amp-embed', false); 5219 let subscriptions_action = document.querySelector('div[subscriptions-action][subscriptions-display="NOT data.hasError"]'); 5220 if (subscriptions_action) 5221 subscriptions_action.removeAttribute('subscriptions-action'); 5222 let subscr_tag = document.querySelector('div#subscriber-exclusive-tag'); 5223 let amp_players = document.querySelectorAll('amp-connatix-player'); 5224 removeDOMElement(subscr_tag, ...amp_players); 5225 } 5226 let premium_svgs = document.querySelectorAll('h3 > a > svg'); 5227 let premium_link; 5228 for (let premium_svg of premium_svgs) { 5229 premium_link = premium_svg.parentElement; 5230 if (premium_link.href.includes('www.')) 5231 premium_link.href = premium_link.href.replace('www.', 'amp.'); 5232 } 5233 let ads = document.querySelectorAll('div[id^="zone-el-"]'); 5234 removeDOMElement(...ads); 5235 } 5236 5237 else if (matchDomain(usa_mng_domains) || (window.location.href.match(/\.com\/(\d){4}\/(\d){2}\/(\d){2}\/.+\/amp\//) && document.querySelector('amp-img#paywall[src*=".com/wp-content/plugins/dfm-amp-mods/"]'))) { 5238 if (window.location.pathname.endsWith('/amp/')) { 5239 amp_unhide_subscr_section('amp-ad, amp-embed, div.ampWrapperInside'); 5240 } 5241 } 5242 5243 else if (document.querySelector('script[src*=".axate.io/"]')) { 5244 let premium = document.querySelector('.premium, div[class*="-premium"]'); 5245 if (premium) 5246 premium.removeAttribute('class'); 5247 } 5248 5249 else 5250 csDone = true; 5251 } 5252 5253 } // end bpc_done 5254 5255 // General Functions 5256 function removeDOMElement(...elements) { 5257 for (let element of elements) { 5258 if (element) 5259 element.remove(); 5260 } 5261 } 5262 5263 function hideDOMElement(...elements) { 5264 for (let element of elements) { 5265 if (element) 5266 element.style = 'display:none !important;'; 5267 } 5268 } 5269 5270 function waitDOMElement(selector, tagName = '', callback, multiple = false) { 5271 new window.MutationObserver(function (mutations) { 5272 for (let mutation of mutations) { 5273 for (let node of mutation.addedNodes) { 5274 if (!tagName || (node.tagName === tagName)) { 5275 if (node.matches(selector)) { 5276 callback(node); 5277 if (!multiple) 5278 this.disconnect(); 5279 } 5280 } 5281 } 5282 } 5283 }).observe(document, { 5284 subtree: true, 5285 childList: true 5286 }); 5287 } 5288 5289 function waitDOMAttribute(selector, tagName = '', attributeName = '', callback, multiple = false) { 5290 let targetNode = document.querySelector(selector); 5291 if (!targetNode) 5292 return; 5293 new window.MutationObserver(function (mutations) { 5294 for (let mutation of mutations) { 5295 if (mutation.target.attributes[attributeName]) { 5296 callback(mutation.target); 5297 if (!multiple) 5298 this.disconnect(); 5299 } 5300 } 5301 }).observe(targetNode, { 5302 attributes: true, 5303 attributeFilter: [attributeName] 5304 }); 5305 } 5306 5307 function matchDomain(domains, hostname = window.location.hostname) { 5308 let matched_domain = false; 5309 if (typeof domains === 'string') 5310 domains = [domains]; 5311 domains.some(domain => (hostname === domain || hostname.endsWith('.' + domain)) && (matched_domain = domain)); 5312 return matched_domain; 5313 } 5314 5315 function urlHost(url) { 5316 if (/^http/.test(url)) { 5317 try { 5318 return new URL(url).hostname; 5319 } catch (e) { 5320 console.log(`url not valid: ${url} error: ${e}`); 5321 } 5322 } 5323 return url; 5324 } 5325 5326 function matchUrlDomain(domains, url) { 5327 return matchDomain(domains, urlHost(url)); 5328 } 5329 5330 function header_nofix(header) { 5331 if (header) { 5332 let nofix_div = document.createElement('div'); 5333 nofix_div.setAttribute('style', 'margin: 20px; font-weight: bold; color: red;'); 5334 nofix_div.innerText = 'BPC > no fix'; 5335 header.appendChild(nofix_div); 5336 } 5337 } 5338 5339 function replaceDomElementExt(url, proxy, base64, selector, text_fail = '', selector_source = selector) { 5340 if (proxy) { 5341 if (!text_fail) { 5342 if (url.includes('webcache.googleusercontent.com')) 5343 text_fail = 'BPC > failed to load from Google webcache: ' 5344 } 5345 ext_api.runtime.sendMessage({request: 'getExtSrc', data: {url: url, selector: selector, selector_source: selector_source, base64: base64, text_fail: text_fail}}); 5346 } else { 5347 let options = {}; 5348 if (matchUrlDomain('espn.com', url)) 5349 options.headers = { 5350 'X-Forwarded-For': randomIP(185, 185) 5351 }; 5352 fetch(url, options) 5353 .then(response => { 5354 let article = document.querySelector(selector); 5355 if (response.ok) { 5356 response.text().then(html => { 5357 replaceDomElementExtSrc(url, html, false, base64, selector, text_fail, selector_source); 5358 }); 5359 } else { 5360 replaceTextFail(url, article, proxy, text_fail); 5361 } 5362 }).catch(function (err) { 5363 false; 5364 }); 5365 } 5366 } 5367 5368 function replaceDomElementExtSrc(url, html, proxy, base64, selector, text_fail = '', selector_source = selector) { 5369 let article = document.querySelector(selector); 5370 if (html) { 5371 if (base64) { 5372 html = decode_utf8(atob(html)); 5373 selector_source = 'body'; 5374 } 5375 let parser = new DOMParser(); 5376 window.setTimeout(function () { 5377 let doc = parser.parseFromString(DOMPurify.sanitize(html, {ADD_ATTR: ['layout', 'itemprop'], ADD_TAGS: ['amp-img', 'iframe']}), 'text/html'); 5378 //console.log(DOMPurify.removed); 5379 let article_new = doc.querySelector(selector_source); 5380 if (article_new) { 5381 if (article && article.parentNode) 5382 article.parentNode.replaceChild(article_new, article); 5383 } 5384 }, 200); 5385 } else { 5386 replaceTextFail(url, article, proxy, text_fail); 5387 } 5388 } 5389 5390 function replaceTextFail(url, article, proxy, text_fail) { 5391 if (text_fail && article) { 5392 let text_fail_div = document.createElement('div'); 5393 text_fail_div.setAttribute('style', 'margin: 0px 50px; font-weight: bold; color: red;'); 5394 text_fail_div.appendChild(document.createTextNode(text_fail)); 5395 if (proxy) { 5396 let a_link = document.createElement('a'); 5397 a_link.innerText = url; 5398 a_link.href = url; 5399 a_link.target = '_blank'; 5400 text_fail_div.appendChild(a_link); 5401 } 5402 article.firstChild.before(text_fail_div); 5403 } 5404 } 5405 5406 function amp_iframes_replace(weblink = false, source = '') { 5407 let amp_iframes = document.querySelectorAll('amp-iframe' + (source ? '[src*="'+ source + '"]' : '')); 5408 let par, elem; 5409 for (let amp_iframe of amp_iframes) { 5410 if (!weblink) { 5411 elem = document.createElement('iframe'); 5412 Object.assign(elem, { 5413 src: amp_iframe.getAttribute('src'), 5414 sandbox: amp_iframe.getAttribute('sandbox'), 5415 height: amp_iframe.getAttribute('height'), 5416 width: 'auto', 5417 style: 'border: 0px;' 5418 }); 5419 amp_iframe.parentNode.replaceChild(elem, amp_iframe); 5420 } else { 5421 par = document.createElement('p'); 5422 elem = document.createElement('a'); 5423 elem.innerText = 'Media-link'; 5424 elem.setAttribute('href', amp_iframe.getAttribute('src')); 5425 elem.setAttribute('target', '_blank'); 5426 par.appendChild(elem); 5427 amp_iframe.parentNode.replaceChild(par, amp_iframe); 5428 } 5429 } 5430 } 5431 5432 function amp_unhide_subscr_section(amp_ads_sel = 'amp-ad, .ad', replace_iframes = true, amp_iframe_link = false, source = '') { 5433 let preview = document.querySelectorAll('[subscriptions-section="content-not-granted"]'); 5434 removeDOMElement(...preview); 5435 let subscr_section = document.querySelectorAll('[subscriptions-section="content"]'); 5436 for (let elem of subscr_section) 5437 elem.removeAttribute('subscriptions-section'); 5438 let amp_ads = document.querySelectorAll(amp_ads_sel); 5439 removeDOMElement(...amp_ads); 5440 if (replace_iframes) 5441 amp_iframes_replace(amp_iframe_link, source); 5442 } 5443 5444 function amp_unhide_access_hide(amp_access = '', amp_access_not = '', amp_ads_sel = 'amp-ad, .ad', replace_iframes = true, amp_iframe_link = false, source = '') { 5445 let access_hide = document.querySelectorAll('[amp-access' + amp_access + '][amp-access-hide]:not([amp-access="error"], [amp-access^="message"], .piano)'); 5446 for (let elem of access_hide) 5447 elem.removeAttribute('amp-access-hide'); 5448 if (amp_access_not) { 5449 let amp_access_not_dom = document.querySelectorAll('[amp-access' + amp_access_not + ']'); 5450 removeDOMElement(...amp_access_not_dom); 5451 } 5452 let amp_ads = document.querySelectorAll(amp_ads_sel); 5453 removeDOMElement(...amp_ads); 5454 if (replace_iframes) 5455 amp_iframes_replace(amp_iframe_link, source); 5456 } 5457 5458 function ampToHtml() { 5459 window.setTimeout(function () { 5460 let canonical = document.querySelector('link[rel="canonical"]'); 5461 window.location.href = canonical.href; 5462 }, 1000); 5463 } 5464 5465 function refreshCurrentTab() { 5466 ext_api.runtime.sendMessage({request: 'refreshCurrentTab'}); 5467 } 5468 5469 function archiveLink(url, text_fail = 'BPC > Try for full article text (only report issue if not working for over a week):\r\n') { 5470 return externalLink(['archive.today', 'archive.is'], 'https://{domain}?run=1&url={url}', url, text_fail); 5471 } 5472 5473 function googleWebcacheLink(url, text_fail = 'BPC > Try for full article text:\r\n') { 5474 return externalLink(['webcache.googleusercontent.com'], 'https://{domain}/search?q=cache:{url}', url, text_fail); 5475 } 5476 5477 function ext_12ftLink(url, text_fail = 'BPC > Try for full article text:\r\n') { 5478 return externalLink(['12ft.io'], 'https://{domain}/{url}', url, text_fail); 5479 } 5480 5481 function externalLink(domains, ext_url_templ, url, text_fail = 'BPC > Full article text:\r\n') { 5482 let text_fail_div = document.createElement('div'); 5483 text_fail_div.id = 'bpc_archive'; 5484 text_fail_div.setAttribute('style', 'margin: 20px; font-weight: bold; color: red;'); 5485 let parser = new DOMParser(); 5486 text_fail = text_fail.replace(/\[([^\]]+)\]/g, "<a href='$1' target='_blank' style='color: red'>$1</a>"); 5487 let doc = parser.parseFromString('<span>' + text_fail + '</span>', 'text/html'); 5488 let elem = doc.querySelector('span'); 5489 text_fail_div.appendChild(elem); 5490 for (let domain of domains) { 5491 let ext_url = ext_url_templ.replace('{domain}', domain).replace('{url}', url.split('?')[0]); 5492 let a_link = document.createElement('a'); 5493 a_link.innerText = domain; 5494 a_link.href = ext_url; 5495 a_link.target = '_blank'; 5496 text_fail_div.appendChild(document.createTextNode(' | ')); 5497 text_fail_div.appendChild(a_link); 5498 } 5499 return text_fail_div; 5500 } 5501 5502 function removeClassesByPrefix(el, prefix) { 5503 let el_classes = el.classList; 5504 for (let el_class of el_classes) { 5505 if (el_class.startsWith(prefix)) 5506 el_classes.remove(el_class); 5507 } 5508 } 5509 5510 function removeClassesList(list) { 5511 for (let class_item of list) { 5512 let elems = document.querySelectorAll('.' + class_item); 5513 for (let elem of elems) 5514 elem.classList.remove(class_item); 5515 } 5516 } 5517 5518 function cookieExists(name) { 5519 return document.cookie.split(';').some(function (item) { 5520 return item.trim().indexOf(name + '=') === 0 5521 }) 5522 } 5523 5524 function setCookie(name, value, domain, path, days) { 5525 let max_age = days * 24 * 60 * 60; 5526 document.cookie = name + "=" + (value || "") + "; domain=" + domain + "; path=" + path + "; max-age=" + max_age; 5527 } 5528 5529 function insert_script(func, insertAfterDom) { 5530 let bpc_script = document.querySelector('script#bpc_script'); 5531 if (!bpc_script) { 5532 let script = document.createElement('script'); 5533 script.setAttribute('id', 'bpc_script'); 5534 script.appendChild(document.createTextNode('(' + func + ')();')); 5535 let insertAfter = insertAfterDom ? insertAfterDom : (document.body || document.head || document.documentElement); 5536 insertAfter.appendChild(script); 5537 } 5538 } 5539 5540 function getArticleJsonScript() { 5541 let scripts = document.querySelectorAll('script[type="application/ld+json"]'); 5542 let json_script; 5543 for (let script of scripts) { 5544 if (script.innerText.match(/"(articlebody|text)":/i)) { 5545 json_script = script; 5546 break; 5547 } 5548 } 5549 return json_script; 5550 } 5551 5552 function findKeyJson(json, keys, min_val_len = 0) { 5553 let source = ''; 5554 if (Array.isArray(json)) { 5555 for (let elem of json) 5556 source = source || findKeyJson(json[elem], keys, min_val_len); 5557 } else if (typeof json === 'object') { 5558 for (let elem in json) { 5559 let json_elem = json[elem]; 5560 if (typeof json_elem === 'string' && keys.includes(elem)) { 5561 if (json_elem.length > min_val_len) 5562 return json_elem; 5563 } else 5564 source = source || findKeyJson(json_elem, keys, min_val_len); 5565 } 5566 } 5567 return source; 5568 } 5569 5570 function genHexString(len) { 5571 let output = ''; 5572 for (let i = 0; i < len; i++) 5573 output += (Math.floor(Math.random() * 16)).toString(16); 5574 return output; 5575 } 5576 5577 function makeRandomNumber(len) { 5578 let result = ''; 5579 let characters = '123456789'; 5580 let charactersLength = characters.length; 5581 for (let i = 0; i < len; i++) 5582 result += characters.charAt(Math.floor(Math.random() * charactersLength)); 5583 return result; 5584 } 5585 5586 function randomInt(max) { 5587 return Math.floor(Math.random() * Math.floor(max)); 5588 } 5589 5590 function randomIP(range_low = 0, range_high = 223) { 5591 let rndmIP = []; 5592 for (let n = 0; n < 4; n++) { 5593 if (n === 0) 5594 rndmIP.push(range_low + randomInt(range_high - range_low + 1)); 5595 else 5596 rndmIP.push(randomInt(255) + 1); 5597 } 5598 return rndmIP.join('.'); 5599 } 5600 5601 function pageContains(selector, text) { 5602 let elements = document.querySelectorAll(selector); 5603 return Array.prototype.filter.call(elements, function (element) { 5604 return RegExp(text).test(element.textContent); 5605 }); 5606 } 5607 5608 function breakText(str) { 5609 str = str.replace(/(?:^|[A-Za-z\"\“\)])(\.|\?|!)(?=[A-ZÖÜ\„\d][A-Za-zÀ-ÿ\„\d]{1,})/gm, "$&\n\n"); 5610 str = str.replace(/(([a-z]{2,}|[\"\“]))(?=[A-Z](?=[A-Za-zÀ-ÿ]+))/gm, "$&\n\n"); 5611 // exceptions: names with alternating lower/uppercase (no general fix) 5612 let str_rep_arr = ['AstraZeneca', 'BaFin', 'BerlHG', 'BfArM', 'BilMoG', 'BioNTech', 'DiGA', 'EuGH', 'FinTechRat', 'GlaxoSmithKline', 'IfSG', 'medRxiv', 'mmHg', 'PlosOne', 'StVO']; 5613 let str_rep_split, 5614 str_rep_src; 5615 for (let str_rep of str_rep_arr) { 5616 str_rep_split = str_rep.split(/([a-z]+)(?=[A-Z](?=[A-Za-z]+))/); 5617 str_rep_src = str_rep_split.reduce(function (accumulator, currentValue) { 5618 return accumulator + currentValue + ((currentValue !== currentValue.toUpperCase()) ? '\n\n' : ''); 5619 }); 5620 if (str_rep_src.endsWith('\n\n')) 5621 str_rep_src = str_rep_src.slice(0, -2); 5622 str = str.replace(new RegExp(str_rep_src, "g"), str_rep); 5623 } 5624 str = str.replace(/De\n\n([A-Z])/g, "De$1"); 5625 str = str.replace(/La\n\n([A-Z])/g, "La$1"); 5626 str = str.replace(/Le\n\n([A-Z])/g, "Le$1"); 5627 str = str.replace(/Mc\n\n([A-Z])/g, "Mc$1"); 5628 return str; 5629 } 5630 5631 function parseHtmlEntities(encodedString) { 5632 let parser = new DOMParser(); 5633 let doc = parser.parseFromString('<textarea>' + encodedString + '</textarea>', 'text/html'); 5634 let dom = doc.querySelector('textarea'); 5635 return dom.value; 5636 } 5637 5638 function encode_utf8(str) { 5639 return unescape(encodeURIComponent(str)); 5640 } 5641 5642 function decode_utf8(str) { 5643 return decodeURIComponent(escape(str)); 5644 }