From 633c45016519b0ec72d56efd6a39731f255ed08f Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Tue, 21 Mar 2023 18:12:34 +0100 Subject: [PATCH] Fix Valor Economico (amp-redirect) --- changelog.txt | 1 + contentScript.js | 33 +++++++++++++++++++-------------- custom/manifest.json | 2 +- manifest.json | 2 +- sites.js | 4 ++-- 5 files changed, 24 insertions(+), 18 deletions(-) diff --git a/changelog.txt b/changelog.txt index 6f36b9b..485484b 100644 --- a/changelog.txt +++ b/changelog.txt @@ -4,6 +4,7 @@ Updates: https://gitlab.com/magnolia1234/bypass-paywalls-firefox-clean/-/release Post-release Fix Faz.net (json) +Fix Valor Economico (amp-redirect) * v3.1.0.0 (2023-03-19) Add Defector diff --git a/contentScript.js b/contentScript.js index 224ad45..180b975 100644 --- a/contentScript.js +++ b/contentScript.js @@ -44,7 +44,7 @@ var usa_outside_mag_domains = ["backpacker.com", "betamtb.com", "betternutrition var usa_tribune_domains = ['baltimoresun.com', 'chicagotribune.com', 'courant.com', 'dailypress.com', 'mcall.com', 'nydailynews.com', 'orlandosentinel.com', 'pilotonline.com', 'sun-sentinel.com']; // clean local storage of sites (with an exemption for hold-list) -var arr_localstorage_hold = ['aachener-nachrichten.de', 'aachener-zeitung.de', 'allgaeuer-zeitung.de', 'augsburger-allgemeine.de', 'barrons.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', 'ilfoglio.it', 'inc42.com', 'indianexpress.com', 'ksta.de', 'kurier.at', 'lanouvellerepublique.fr', 'latimes.com', 'lc.nl', 'lesechos.fr', 'livemint.com', 'mid-day.com', 'nationalreview.com', 'nknews.org', 'nw.de', 'nytimes.com', 'nzherald.co.nz', 'record.pt', '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(ca_gcm_domains, de_funke_medien_domains, de_lv_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); +var arr_localstorage_hold = ['aachener-nachrichten.de', 'aachener-zeitung.de', 'allgaeuer-zeitung.de', 'augsburger-allgemeine.de', 'barrons.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', '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', 'nationalreview.com', 'nknews.org', 'nw.de', 'nytimes.com', 'nzherald.co.nz', 'record.pt', '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(ca_gcm_domains, de_funke_medien_domains, de_lv_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); if (!matchDomain(arr_localstorage_hold)) { window.localStorage.clear(); } @@ -2670,22 +2670,27 @@ else if (matchDomain('lasegunda.com')) { else if (matchDomain('valor.globo.com')) { let url = window.location.href; - let paywall = document.querySelector('div.paywall'); - if (paywall) { - removeDOMElement(paywall); - csDoneOnce = true; - let url_cache = 'https://webcache.googleusercontent.com/search?q=cache:' + url; - replaceDomElementExt(url_cache, true, false, 'div.protected-content'); - } - window.setTimeout(function () { - let skeleton_box = document.querySelectorAll('div.glb-skeleton-box'); - for (let elem of skeleton_box) { - elem.classList.remove('glb-skeleton-box'); - elem.removeAttribute('style'); + if (!window.location.pathname.startsWith('/google/amp/')) { + let paywall = document.querySelector('div.paywall'); + let amphtml = document.querySelector('link[rel="amphtml"]'); + if (paywall && amphtml) { + removeDOMElement(paywall); + window.location.href = amphtml.href; } let ads = document.querySelectorAll('[id^="ad-container"], .content-ads'); removeDOMElement(...ads); - }, 1000); + } else { + amp_unhide_subscr_section('amp-ad, amp-embed'); + let mobile = window.navigator.userAgent.toLowerCase().includes('mobile'); + let amp_images = document.querySelectorAll('figure > amp-img[src^="https://"]'); + for (let amp_image of amp_images) { + let elem = document.createElement('img'); + elem.src = amp_image.getAttribute('src'); + elem.alt = amp_image.getAttribute('alt'); + elem.style = mobile ? 'width: 320px;' : 'margin: 0px 250px; display:block;'; + amp_image.parentNode.replaceChild(elem, amp_image); + } + } } else if (window.location.hostname.endsWith('.cl') && document.querySelector('meta[property="og:image"][content*="://impresa.soy-chile.cl/"]')) { diff --git a/custom/manifest.json b/custom/manifest.json index c6c6ab7..759d7bf 100644 --- a/custom/manifest.json +++ b/custom/manifest.json @@ -51,5 +51,5 @@ "webRequestBlocking", "*://*/*" ], - "version": "3.1.0.1" + "version": "3.1.0.2" } diff --git a/manifest.json b/manifest.json index 4a4b8e3..77b506b 100644 --- a/manifest.json +++ b/manifest.json @@ -740,5 +740,5 @@ "*://*.wallkit.net/*", "*://webcache.googleusercontent.com/*" ], - "version": "3.1.0.1" + "version": "3.1.0.2" } diff --git a/sites.js b/sites.js index 7340ee2..7482754 100644 --- a/sites.js +++ b/sites.js @@ -1469,9 +1469,9 @@ var defaultSites = { domain: "estadao.com.br", block_regex: /(acesso\.estadao\.com\.br\/paywall\/.+\/.+\.js|cdn\.ampproject\.org\/v\d\/amp-(access|subscriptions)-.+\.js)/ }, - "O Globo (& Valor Econômico; cached articles only)": { + "O Globo (& Valor Econômico)": { domain: "globo.com", - block_regex: /\.tinypass\.com\// + block_regex: /(\.tinypass\.com\/|cdn\.cxense\.com\/|cdn\.ampproject\.org\/v\d\/amp-subscriptions-.+\.js)/ }, "Observador.pt": { domain: "observador.pt",