//"use strict"; var ext_api = (typeof browser === 'object') ? browser : chrome; var domain; var csDone = false; var de_funke_media_domains = ['abendblatt.de', 'braunschweiger-zeitung.de', 'morgenpost.de', 'nrz.de', 'waz.de', 'wp.de', 'wr.de']; var de_madsack_domains = ['haz.de', 'kn-online.de', 'ln-online.de', 'lvz.de', 'maz-online.de', 'neuepresse.de', 'ostsee-zeitung.de']; var es_grupo_vocento_domains = ['diariosur.es', 'diariovasco.com', 'elcomercio.es', 'elcorreo.com', 'eldiariomontanes.es', 'elnortedecastilla.es', 'hoy.es', 'ideal.es', 'larioja.com', 'laverdad.es', 'lavozdigital.es']; var fr_groupe_ebra_domains = ['bienpublic.com', 'dna.fr', 'estrepublicain.fr', 'lalsace.fr', 'ledauphine.com', 'lejsl.com', 'leprogres.fr', 'republicain-lorrain.fr', 'vosgesmatin.fr']; var fr_groupe_la_depeche_domains = ['centrepresseaveyron.fr', 'ladepeche.fr', 'lindependant.fr', 'midi-olympique.fr', 'midilibre.fr', 'nrpyrenees.fr', 'petitbleu.fr']; // clean local storage of sites (with an exemption for hold-list) var arr_localstorage_hold = ['charliehebdo.fr', 'elmundo.es', 'kurier.at', 'nknews.org', 'seekingalpha.com', 'sfchronicle.com', 'thehindu.com', 'thetimes.co.uk']; arr_localstorage_hold = arr_localstorage_hold.concat(de_funke_media_domains, es_grupo_vocento_domains); if (!matchDomain(arr_localstorage_hold)){ window.localStorage.clear(); } // listen to responses from background script ext_api.runtime.onMessage.addListener(function (message, sender) { // setCookie opt-in if (message.optIn) { let hostname = window.location.hostname; if (hostname.endsWith(".com.au") || hostname.endsWith(".net.au")) { // Australian Provincial Newspapers domain = window.location.hostname.replace('www.', ''); let au_apn_script = document.querySelector('script[src^="https://media.apnarm.net.au/"]'); if (au_apn_script || (domain = matchDomain(['news-mail.com.au', 'frasercoastchronicle.com.au', 'gladstoneobserver.com.au', 'dailyexaminer.com.au', 'dailymercury.com.au', 'themorningbulletin.com.au', 'sunshinecoastdaily.com.au', 'gympietimes.com.au', 'northernstar.com.au', 'qt.com.au', 'thechronicle.com.au', 'warwickdailynews.com.au']))) if (!cookieExists('subscribed')) setCookie('subscribed', 'true', domain, '/', 14); } else { if (matchDomain('bostonglobe.com')) { if (!cookieExists('s_fid')) { let s_fid = genHexString(16) + '-' + genHexString(16); setCookie('s_fid', s_fid, 'bostonglobe.com', '/', 14); } } else if (domain = matchDomain(['independent.ie', 'belfasttelegraph.co.uk'])) { if (!cookieExists('subscriber')) setCookie('subscriber', '{"subscriptionStatus": true}', domain, '/', 14); } } } }); // ask for opt-in confirmation ext_api.runtime.sendMessage({request: 'optin'}); // Content workarounds/domain if (matchDomain("thesaturdaypaper.com.au")) { let paywall = document.querySelector('div.paywall-hard-always-show'); removeDOMElement(paywall); } else if (domain = matchDomain(["brisbanetimes.com.au", "smh.com.au", "theage.com.au", "watoday.com.au"])) { let url = window.location.href; let for_subscribers = document.querySelector('meta[content^="FOR SUBSCRIBERS"]'); if (for_subscribers) { window.setTimeout(function () { window.location.href = url.replace('www.', 'amp.'); }, 500); // Delay (in milliseconds) } else if (url.includes('amp.' + domain)) { let subscr_sections = document.querySelectorAll('div[subscriptions-section="content"]'); for (let subscr_section of subscr_sections) { subscr_section.removeAttribute('subscriptions-section'); } } } else if (window.location.hostname.endsWith(".com.au") || window.location.hostname.endsWith(".net.au")) { // Australian Community Media newspapers let au_cm_sites = ['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', 'portnews.com.au', 'standard.net.au', 'theadvocate.com.au', 'thecourier.com.au', 'westernadvocate.com.au']; let au_piano_script = document.querySelector('script[src="https://cdn-au.piano.io/api/tinypass.min.js"]'); if (matchDomain(au_cm_sites) || au_piano_script) { const subscribe_truncate = document.querySelector('.subscribe-truncate'); if (subscribe_truncate) subscribe_truncate.classList.remove('subscribe-truncate'); const subscriber_hiders = document.querySelectorAll('.subscriber-hider'); for (let subscriber_hider of subscriber_hiders) { subscriber_hider.classList.remove('subscriber-hider'); } let story_generic_iframe = document.querySelector('.story-generic__iframe'); removeDOMElement(story_generic_iframe); } else if (window.location.hostname.endsWith(".com.au")) { // Australia News Corp let au_nc_sites = ['adelaidenow.com.au', 'cairnspost.com.au', 'couriermail.com.au', 'dailytelegraph.com.au', 'geelongadvertiser.com.au', 'goldcoastbulletin.com.au', 'heraldsun.com.au', 'ntnews.com.au', 'theaustralian.com.au', 'themercury.com.au', 'townsvillebulletin.com.au', 'weeklytimesnow.com.au']; if (matchDomain(au_nc_sites)) { let header_ads = document.querySelector('.header_ads-container'); removeDOMElement(header_ads); if (window.location.hostname.startsWith('amp.')) { let div_hidden_all = document.querySelectorAll('div[amp-access="access AND subscriber"]'); for (let div_hidden of div_hidden_all) div_hidden.removeAttribute('amp-access-hide'); } else if (window.location.href.includes('?amp')) { //window.setTimeout(function () { let div_hidden = document.querySelector('div[amp-access="subscriber AND status=\'logged-in\'"]'); if (div_hidden) div_hidden.removeAttribute('amp-access-hide'); //}, 500); // Delay (in milliseconds) } let amp_iframes = document.querySelectorAll('amp-iframe'); let elem; for (let amp_iframe of amp_iframes) { elem = document.createElement('a'); elem.innerText = 'Video-link'; elem.setAttribute('href', amp_iframe.getAttribute('src')); elem.setAttribute('target', '_blank'); amp_iframe.parentElement.insertBefore(elem, amp_iframe); removeDOMElement(amp_iframe); } } else { // Australian Seven West Media let swm_script = document.querySelector('script[src^="https://s.thewest.com.au"]'); if (matchDomain("thewest.com.au") || swm_script) { window.setTimeout(function () { let breach_screen = document.querySelector('div[data-testid*="BreachScreen"]'); if (breach_screen) { let scripts = document.querySelectorAll('script'); let json_script; for (let script of scripts) { if (script.innerText.includes('window.PAGE_DATA =')) json_script = script; continue; } if (json_script) { let json_text = json_script.innerHTML.split('window.PAGE_DATA =')[1].split('' + par.text + '
'; } else if (par.kind === 'subhead') { article = article + '' + par.text + '
'; console.log(par.kind); } } let content = document.querySelector('div[class*="StyledArticleContent"]'); let parser = new DOMParser(); let par_html = parser.parseFromString('' + elem.text + '
' + par_key + '
', 'text/html'); par_elem = par_html.querySelector('p'); } else par_elem.innerText = par_key; if (key === 'subhead') par_elem.setAttribute('style', 'font-weight: bold;'); } else if (key === 'image') { par_elem = document.createElement("img"); par_elem.src = par_key.url; } else if (key === 'bullet_list') { par_elem = document.createElement('ul'); for (let bullet of par_key) { par_html = parser.parseFromString('' + par_key + '
', 'text/html'); par_elem = par_html.querySelector('p'); } if (!['streamone', 'legacy-ml'].includes(key)) par_elem.setAttribute('class', 'gva-3ee037ad_root gva-3ee037ad_paragraph gva-68d24f7d_none gva-ef7ba41a_system gva-6c6ea21_marginbottom5 gva-6c6ea21_margintop0 gva-21a3e72f_inherit'); div_content.appendChild(par_elem); } } } } }); window.setTimeout(function () { let overlay = document.querySelector('div.cj-root'); removeDOMElement(overlay); let noscroll = document.querySelector('html.is-dialog-active'); if (noscroll) noscroll.classList.remove('is-dialog-active'); }, 500); // Delay (in milliseconds) } else if (matchDomain('deutsche-wirtschafts-nachrichten.de')) { window.setTimeout(function () { let hardpay = document.querySelector('.hardpay'); if (hardpay) { window.location.reload(true); } }, 500); // Delay (in milliseconds) } else if (matchDomain("alternatives-economiques.fr")) { window.setTimeout(function () { let paywall = document.querySelector('#temp-paywall'); removeDOMElement(paywall); let data_ae_poool = document.querySelector('div[data-ae-poool]'); if (data_ae_poool) data_ae_poool.removeAttribute('style'); }, 500); // Delay (in milliseconds) } else if (matchDomain("hs.fi")) { let url = window.location.href; if (!url.includes('https://dynamic.hs.fi')) { let iframe = document.querySelector('iframe[src^="https://dynamic.hs.fi/a/"]'); if (iframe && url.includes('.html')) { window.setTimeout(function () { window.location.href = iframe.src; }, 500); // Delay (in milliseconds) } csDone = true; } else { let paywall = document.querySelector('.paywall-container'); if (paywall) { let scripts = document.querySelectorAll('script'); let json_script; for (let script of scripts) { if (script.innerText.includes('window.__NUXT__=')) json_script = script; continue; } let json_text = json_script.innerHTML.replace(/\r\n/g, '').split('amlData:[')[1].split('metaData')[0].split('paywallComponents:[')[1].slice(0, -4); let main = document.querySelector('main'); if (main) { let pars = json_text.split('{type:'); let type, value, slides, src, elem, img, caption, caption_text, par_html, par_text; let parser = new DOMParser(); for (let par of pars) { type = par.split(',')[0]; if (type === 'i') { // text value = par.split('value:')[1].split('}')[0]; par_html = parser.parseFromString('' + value + '
', 'text/html'); elem = par_html.querySelector('p'); elem.setAttribute('class', 'article-body px-16 mb-24'); main.appendChild(elem); } else if (type === 'j') { // quote value = par.split('text:')[1].split(',position:')[0]; par_html = parser.parseFromString('' + value + '
', 'text/html'); elem = par_html.querySelector('p'); elem.setAttribute('class', 'article-body px-16 mb-24'); elem.setAttribute('style', 'font-style: italic;'); main.appendChild(elem); } else if (type === 'h') { // image src = par.split('src:"')[1].split('",')[0]; elem = document.createElement('p'); elem.setAttribute('class', 'article-body px-16 mb-24'); img = document.createElement('img'); img.setAttribute('src', 'https://arkku.mediadelivery.fi/img/468/' + src); img.setAttribute('style', 'width:468px !important'); elem.appendChild(img); caption = document.createElement('figcaption'); caption_text = par.split('caption:')[1].split(',credits:')[0]; if (caption_text.length) caption_text = caption_text.slice(1, caption_text.length - 1); caption.innerText = caption_text; elem.appendChild(caption); main.appendChild(elem); } else if (type === 'r') { // slides slides = par.split('src:'); for (let slide of slides) { if (slide.includes('.jpg')) { src = slide.split(',')[0].replace(/"/g, ''); elem = document.createElement('p'); elem.setAttribute('class', 'article-body px-16 mb-24'); img = document.createElement('img'); img.setAttribute('src', 'https://arkku.mediadelivery.fi/img/468/' + src); img.setAttribute('style', 'width:468px !important'); elem.appendChild(img); caption = document.createElement('figcaption'); caption_text = slide.split('text:')[1].split(',"text-style"')[0]; if (caption_text.length) caption_text = caption_text.slice(1, caption_text.length - 1); caption.innerText = caption_text; elem.appendChild(caption); main.appendChild(elem); } } } else false; //console.log('type: ' + type + ' par: ' + par); } main.appendChild(document.createElement('br')); } removeDOMElement(paywall); csDone = true; } } } else if (matchDomain("latercera.com")) { let subscr_banner = document.querySelector('.empty'); removeDOMElement(subscr_banner); } else if (matchDomain(es_grupo_vocento_domains)) { let url = window.location.href; let content_exclusive_bg = document.querySelector('.content-exclusive-bg, #cierre_suscripcion'); let amphtml = document.querySelector('link[rel="amphtml"]'); if (content_exclusive_bg && amphtml) { window.setTimeout(function () { window.location.href = url.replace('.html', '_amp.html'); }, 500); // Delay (in milliseconds) } else if (url.includes('_amp.html')) { let voc_advers = document.querySelectorAll('.voc-adver, amp-embed'); removeDOMElement(...voc_advers); let container_wall_exclusive = document.querySelector('.container-wall-exclusive'); if (container_wall_exclusive) { let non_subscr_section = document.querySelector('[amp-access="result!=\'ALLOW_ACCESS\'"]'); removeDOMElement(container_wall_exclusive, non_subscr_section); let subscr_section = document.querySelector('[amp-access="result=\'ALLOW_ACCESS\'"]'); if (subscr_section) subscr_section.removeAttribute('amp-access-hide'); } //lavozdigital.es let paywall = document.querySelector('span[subscriptions-section="content"]'); if (paywall) { paywall.classList.remove('paywall'); paywall.removeAttribute('subscriptions-section'); } } } else if (matchDomain("corriere.it")) { let url = window.location.href; if (url.includes('_preview.shtml')) { window.setTimeout(function () { window.location.href = url.replace('_preview.shtml', '.shtml').split('?')[0]; }, 500); // Delay (in milliseconds) } } else if (matchDomain("elperiodico.com")) { let url = window.location.href; if (!url.includes('amp.elperiodico.com')) { let paywall = document.querySelector('.ep-masPeriodico-info-login'); if (paywall) { window.setTimeout(function () { window.location.href = url.replace('www.', 'amp.'); }, 500); // Delay (in milliseconds) } } else { let not_logged = document.querySelector('.ep-masPeriodico-info-login'); if (not_logged) { let non_subscr_section = document.querySelector('div[amp-access="NOT logged"]'); removeDOMElement(not_logged, non_subscr_section); let subscr_section = document.querySelector('div[amp-access="logged"]'); if (subscr_section) subscr_section.removeAttribute('amp-access-hide'); csDone = true; } } } else if (matchDomain('la-croix.com')) { let url = window.location.href; if (!url.includes('la-croix.com/amp/')) { let paywall_host_param = document.querySelector('#paywall-host-param'); removeDOMElement(paywall_host_param); if (paywall_host_param) csDone = true; } else { let paywall_block = document.querySelector('#paywall_block'); removeDOMElement(paywall_block); } } else if (matchDomain('lasegunda.com')) { let url = window.location.href; if (url.includes('digital.lasegunda.com/mobile')) { let lessreadmore = document.querySelectorAll('article.lessreadmore'); for (let article of lessreadmore) article.classList.remove('lessreadmore'); let bt_readmore = document.querySelectorAll('div[id*="bt_readmore_"]'); removeDOMElement(...bt_readmore); } } else if (matchDomain("telegraph.co.uk")) { let url = window.location.href; if (new URL(url).pathname.endsWith('/amp/')) { let paywall = document.querySelector('.premium-paywall'); if (paywall) { let truncated_content = document.querySelector('.truncated-content'); removeDOMElement(paywall, truncated_content); let subscr_section = document.querySelector('.notAccessibleForFree'); if (subscr_section) subscr_section.removeAttribute('amp-access-hide'); } } } else if (matchDomain('esprit.presse.fr')) { let paywall = document.querySelector('.panel-popup-paywall'); removeDOMElement(paywall); } else if ((domain = matchDomain(fr_groupe_ebra_domains)) && window.location.href.match(/\/\d{4}\/\d{2}\/\d{2}\//)) { let url = window.location.href; let url_new = url.replace(domain + '/', domain + '/amp/'); if (!url.includes(domain + '/amp/')) { let free = document.querySelector('[class^="paywall"]'); if (!free) { window.setTimeout(function () { window.location.href = url_new; }, 500); // Delay (in milliseconds) } } else { let amp_access_hide = document.querySelector('[amp-access-hide]'); if (amp_access_hide) { let not_access_section = document.querySelector('section[amp-access="NOT access"]'); removeDOMElement(not_access_section); amp_access_hide.removeAttribute('amp-access-hide'); } } } else if (matchDomain(de_funke_media_domains)) { let obfuscated_elems = document.querySelectorAll('.obfuscated'); let parser = new DOMParser(); for (let obfuscated_elem of obfuscated_elems) { let html = parser.parseFromString('