From fb7d2068d03abc47b9436b0a363a260deeaae7a5 Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Sun, 24 Jan 2021 10:25:55 +0100 Subject: [PATCH] Fix-update MarketWatch (premium) --- README.md | 6 ++++-- background.js | 10 ++++++---- changelog.txt | 1 + contentScript.js | 18 ++++++++++++++++++ manifest.json | 5 +++-- sites.js | 2 +- 6 files changed, 33 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index f5cbe0b..ea4646a 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,8 @@ Visit the [Chrome repository](https://gitlab.com/magnolia1234/bypass-paywalls-ch ### List of supported websites +_* free articles only._ + ##### World news [First Things](https://www.firstthings.com) - [Foreign Affairs](https://www.foreignaffairs.com) - @@ -64,7 +66,7 @@ Visit the [Chrome repository](https://gitlab.com/magnolia1234/bypass-paywalls-ch [Fortune](https://fortune.com) - [Harvard Business Review](https://www.hbr.org) - [Inc.com](https://www.inc.com) - -[MarketWatch](https://www.marketwatch.com)\* - +[MarketWatch](https://www.marketwatch.com)\ - [MIT Sloan Management Review](https://sloanreview.mit.edu) - [Modern Healthcare](https://www.modernhealthcare.com) - [Quartz](https://qz.com)* - @@ -473,7 +475,7 @@ For example: [El Comercio](https://elcomercio.pe) - [GestiĆ³n](https://gestion.pe) -_*free articles only._ +_* free articles only._ ### Sites with limited number of free articles The free article limit can normally be bypassed by removing cookies for the site. diff --git a/background.js b/background.js index c9ccc79..d8e0b47 100644 --- a/background.js +++ b/background.js @@ -4,7 +4,7 @@ var ext_api = (typeof browser === 'object') ? browser : chrome; var ext_name = ext_api.runtime.getManifest().name; -const cs_limit_except = ['afr.com', 'discovermagazine.com', 'elcomercio.pe', 'elpais.com', 'faz.net', 'gestion.pe', 'harpers.org', 'inkl.com', 'la-croix.com', 'lescienze.it', 'lne.es', 'newleftreview.org', 'prospectmagazine.co.uk', 'techinasia.com', 'thepointmag.com']; +const cs_limit_except = ['afr.com', 'discovermagazine.com', 'elcomercio.pe', 'elpais.com', 'faz.net', 'gestion.pe', 'harpers.org', 'inkl.com', 'la-croix.com', 'lescienze.it', 'lne.es', 'marketwatch.com', 'newleftreview.org', 'prospectmagazine.co.uk', 'techinasia.com', 'thepointmag.com']; var currentTabUrl = ''; var csDone = false; @@ -80,6 +80,7 @@ var allow_cookies_default = [ 'limesonline.com', 'lne.es', 'lrb.co.uk', + 'marketwatch.com', 'modernhealthcare.com', 'nationalgeographic.com', 'nationalpost.com', @@ -269,7 +270,7 @@ var blockedRegexes = { 'lne.es': /cdn\.ampproject\.org\/v\d\/amp-(access|consent)-.+\.js/, 'lopinion.fr': /.+\.poool\.fr\/.+/, 'lrb.co.uk': /\.tinypass\.com\/.+/, - 'marketwatch.com': /cdn\.cxense\.com\/.+/, + 'marketwatch.com': /(cdn\.cxense\.com\/|cdn\.ampproject\.org\/v\d\/amp-(access|ad)-.+\.js)/, 'mercuriovalpo.cl': /(.+\.mercuriovalpo\.cl\/impresa\/.+\/assets\/(vendor|\d)\.js|pram\.pasedigital\.cl\/API\/User\/Status\?)/, 'modernhealthcare.com': /\.tinypass\.com\/.+/, 'nationalgeographic.com': /.+\.blueconic\.net\/.+/, @@ -826,11 +827,12 @@ ext_api.webRequest.onBeforeSendHeaders.addListener(function(details) { let au_swm_site = (header_referer && urlHost(header_referer).endsWith('com.au') && details.url.includes('https://s.thewest.com.au/')); let uk_nlr_site = (matchUrlDomain('stripe.com', details.url) && matchUrlDomain('newleftreview.org', header_referer) && isSiteEnabled({url: header_referer})); let usa_discmag_site = (matchUrlDomain('ctfassets.net', details.url) && matchUrlDomain('discovermagazine.com', header_referer) && isSiteEnabled({url: header_referer})); + let usa_mw_site = (matchUrlDomain('wsj.net', details.url) && matchUrlDomain('marketwatch.com', header_referer) && isSiteEnabled({url: header_referer})); let bpc_amp_site = (matchUrlDomain('cdn.ampproject.org', details.url) && isSiteEnabled({url: header_referer}) && - matchUrlDomain(['barrons.com', 'belfasttelegraph.co.uk', 'cicero.de', 'cmjornal.pt', 'elmundo.es', 'elpais.com', 'elperiodico.com', 'expansion.com', 'freiepresse.de', 'fresnobee.com', 'gelocal.it', 'independent.ie', 'irishtimes.com', 'la-croix.com', 'lne.es', 'nationalreview.com', 'sacbee.com', 'seekingalpha.com', 'sueddeutsche.de', 'svz.de', 'telegraph.co.uk'].concat(au_nine_domains, es_grupo_vocento_domains, fr_groupe_ebra_domains, fr_groupe_la_depeche_domains), header_referer)); + matchUrlDomain(['barrons.com', 'belfasttelegraph.co.uk', 'cicero.de', 'cmjornal.pt', 'elmundo.es', 'elpais.com', 'elperiodico.com', 'expansion.com', 'freiepresse.de', 'fresnobee.com', 'gelocal.it', 'independent.ie', 'irishtimes.com', 'la-croix.com', 'lne.es', 'marketwatch.com', 'nationalreview.com', 'sacbee.com', 'seekingalpha.com', 'sueddeutsche.de', 'svz.de', 'telegraph.co.uk'].concat(au_nine_domains, es_grupo_vocento_domains, fr_groupe_ebra_domains, fr_groupe_la_depeche_domains), header_referer)); - if (!isSiteEnabled(details) && !inkl_site && !au_nc_amp_site && !au_apn_site && !au_swm_site && !uk_nlr_site && !usa_discmag_site && !bpc_amp_site) { + if (!isSiteEnabled(details) && !inkl_site && !au_nc_amp_site && !au_apn_site && !au_swm_site && !uk_nlr_site && !usa_discmag_site && !usa_mw_site && !bpc_amp_site) { return; } diff --git a/changelog.txt b/changelog.txt index 227863e..3c9edbd 100644 --- a/changelog.txt +++ b/changelog.txt @@ -12,6 +12,7 @@ Add Ruhr Nachrichten (Germany) Add The Point Magazine Fix-update El Pais (Spain) Fix-update Helsingin Sanomat (Finland) +Fix-update MarketWatch (premium) Fix-update MIT Sloan Management Review Update block TinyPass (all subdomains) Update excluded sites (no general block paywall scripts) diff --git a/contentScript.js b/contentScript.js index 46b1622..e2eab7b 100644 --- a/contentScript.js +++ b/contentScript.js @@ -1969,6 +1969,24 @@ else if (matchDomain('lne.es')) { } } +else if (matchDomain('marketwatch.com')) { + let premium = document.querySelector('div.article__exclusive'); + let url = window.location.href; + window.setTimeout(function () { + if (premium && !url.includes('/amp/')) { + window.location.href = url.replace('.marketwatch.com/', '.marketwatch.com/amp/'); + } + }, 500); // Delay (in milliseconds) + if (url.includes('/amp/')) { + let meter = document.querySelector('div.meter'); + let container_sponsored = document.querySelector('div.container--sponsored'); + let amp_ads = document.querySelectorAll('.display-ad'); + removeDOMElement(meter, container_sponsored, ...amp_ads); + } + let ads = document.querySelectorAll('div.element--ad, div.j-ad'); + removeDOMElement(...ads); +} + else if (!matchDomain(['belfasttelegraph.co.uk', 'independent.ie'])) csDone = true; diff --git a/manifest.json b/manifest.json index 73d0e55..d285520 100644 --- a/manifest.json +++ b/manifest.json @@ -438,7 +438,8 @@ "*://*.rcsobjects.it/*", "*://*.repstatic.it/*", "*://*.stripe.com/*", - "*://*.userzoom.com/*" + "*://*.userzoom.com/*", + "*://*.wsj.net/*" ], - "version": "2.0.4.7" + "version": "2.0.4.8" } \ No newline at end of file diff --git a/sites.js b/sites.js index 2745b4d..38fe51d 100644 --- a/sites.js +++ b/sites.js @@ -133,7 +133,7 @@ var defaultSites = "Los Angeles Business Journal": "labusinessjournal.com", "Los Angeles Times": "latimes.com", "Madsack Mediengruppe (Germany)": "###_de_madsack", - "MarketWatch (free articles only)": "marketwatch.com", + "MarketWatch": "marketwatch.com", "Medium (all sites)": "medium.com", "Mexico News Daily": "mexiconewsdaily.com", "Miami Herald": "miamiherald.com",