From 654f3b15ead956288e9a20bd6c58fb16ec0e90ef Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Mon, 5 Jul 2021 19:45:08 +0200 Subject: [PATCH] Fix WaPo (amp) --- background.js | 3 ++- changelog.txt | 1 + contentScript.js | 17 +++++++++++------ manifest.json | 2 +- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/background.js b/background.js index 279baf4..bb4e715 100644 --- a/background.js +++ b/background.js @@ -401,6 +401,7 @@ var blockedRegexes = { 'variety.com': /cdn\.cxense\.com\//, 'velonews.com': /\.velonews\.com\/.+\/scripts\/contentGate.+\.js/, 'venturebeat.com': /\.wallkit\.net\/js\//, + 'washingtonpost.com': /cdn\.ampproject\.org\/.+\/v\d\/amp-((sticky-)?ad|subscriptions)-.+\.js/, 'wsj.com': /(cdn\.ampproject\.org\/v\d\/amp-(access|ad|consent)-.+\.js|cdn\.cxense\.com\/)/ }; @@ -1123,7 +1124,7 @@ ext_api.webRequest.onBeforeSendHeaders.addListener(function(details) { let usa_today_site = (matchUrlDomain('gannett-cdn.com', details.url) && matchUrlDomain(['usatoday.com'], header_referer)); allow_ext_source = allow_ext_source || inkl_site || cl_elmerc_site || es_elesp_site || it_repubblica_site || uk_nlr_site || usa_discmag_site || usa_mw_site || usa_natgeo_site || usa_today_site; - bpc_amp_site = (matchUrlDomain('cdn.ampproject.org', details.url) && matchUrlDomain(['asiatimes.com', 'augsburger-allgemeine.de', 'barrons.com', 'belfasttelegraph.co.uk', 'cicero.de', 'cmjornal.pt', 'elmundo.es', 'elpais.com', 'elperiodico.com', 'expansion.com', 'freiepresse.de', 'independent.ie', 'irishtimes.com', 'la-croix.com', 'marketwatch.com', 'nationalreview.com', 'noz.de', 'nwzonline.de', 'scmp.com', 'seekingalpha.com', 'shz.de', 'staradvertiser.com', 'sueddeutsche.de', 'svz.de', 'telegraph.co.uk'].concat(au_news_corp_domains, au_nine_domains, de_madsack_domains, es_epiberica_domains, es_grupo_vocento_domains, fr_groupe_ebra_domains, fr_groupe_la_depeche_domains, it_repubblica_domains, usa_mcc_domains, usa_theathletic_domains), header_referer)); + bpc_amp_site = (matchUrlDomain('cdn.ampproject.org', details.url) && matchUrlDomain(['asiatimes.com', 'augsburger-allgemeine.de', 'barrons.com', 'belfasttelegraph.co.uk', 'cicero.de', 'cmjornal.pt', 'elmundo.es', 'elpais.com', 'elperiodico.com', 'expansion.com', 'freiepresse.de', 'independent.ie', 'irishtimes.com', 'la-croix.com', 'marketwatch.com', 'nationalreview.com', 'noz.de', 'nwzonline.de', 'scmp.com', 'seekingalpha.com', 'shz.de', 'staradvertiser.com', 'sueddeutsche.de', 'svz.de', 'telegraph.co.uk', 'washingtonpost.com'].concat(au_news_corp_domains, au_nine_domains, de_madsack_domains, es_epiberica_domains, es_grupo_vocento_domains, fr_groupe_ebra_domains, fr_groupe_la_depeche_domains, it_repubblica_domains, usa_mcc_domains, usa_theathletic_domains), header_referer)); } if (!isSiteEnabled(details) && !allow_ext_source && !bpc_amp_site && !au_apn_site && !au_swm_site) { diff --git a/changelog.txt b/changelog.txt index 805fe0f..62e26f4 100644 --- a/changelog.txt +++ b/changelog.txt @@ -2,6 +2,7 @@ Changelog Bypass Paywalls Clean - Firefox Post-release +Fix WaPo (amp) * v2.2.8.0 (2021-07-04) Fix Le Parisien (Googlebot) diff --git a/contentScript.js b/contentScript.js index 50265a7..2977406 100644 --- a/contentScript.js +++ b/contentScript.js @@ -1315,7 +1315,7 @@ else if (matchDomain(nl_mediahuis_region_domains)) { par_elem = document.createElement('div'); let par_img = document.createElement('img'); par_img.src = par_key.url; - par_elem.appendChild(par_img) + par_elem.appendChild(par_img); par_div = document.createElement('div'); par_div.innerText = par[key].caption ? par[key].caption : ''; par_div.innerText += par[key].credit ? '\n' + par[key].credit : ''; @@ -2511,12 +2511,17 @@ else if (matchDomain('washingtonpost.com')) { } else { function wapo_main(node) { removeDOMElement(node); - let url = window.location.href; - if (!url.includes('outputType=amp')) - window.location.href = url.split('?')[0] + '?outputType=amp'; + window.location.href = url.split('?')[0] + '?outputType=amp'; + } + let url = window.location.href; + if (!url.includes('outputType=amp')) { + waitDOMElement('div[id^="paywall-"]', 'DIV', wapo_main, false); + csDoneOnce = true; + } else { + let subscr_sections = document.querySelectorAll('[subscriptions-section="content"]'); + for (let subscr_section of subscr_sections) + subscr_section.removeAttribute('subscriptions-section'); } - waitDOMElement('div[id^="paywall-"]', 'DIV', wapo_main, false); - csDoneOnce = true; } } diff --git a/manifest.json b/manifest.json index 4c6f8a3..d1f399c 100644 --- a/manifest.json +++ b/manifest.json @@ -536,5 +536,5 @@ "*://*.wallkit.net/*", "*://*.wsj.net/*" ], - "version": "2.2.8.0" + "version": "2.2.8.1" } \ No newline at end of file