From aaa32209a145b1e6ab2fa632e0d83cdcad5ff28f Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Thu, 28 Apr 2022 17:52:06 +0200 Subject: [PATCH] Fix Medium custom domains --- README.md | 8 ++++++-- background.js | 13 ++++++------- changelog.txt | 1 + contentScript.js | 3 ++- custom/manifest.json | 2 +- manifest.json | 3 ++- sites.js | 15 +++++++-------- sites_updated.json | 32 -------------------------------- 8 files changed, 25 insertions(+), 52 deletions(-) diff --git a/README.md b/README.md index dcf8f2e..6dfc478 100755 --- a/README.md +++ b/README.md @@ -154,7 +154,6 @@ Grouped in options:\ [Science](https://www.science.org)* - [Scientific American](https://www.scientificamerican.com)* - [Times Higher Education](https://www.timeshighereducation.com) - -[Towards Data Science](https://www.towardsdatascience.com) - [VentureBeat](https://venturebeat.com) ##### Encyclopedia/Book library/Knowledge base @@ -170,6 +169,12 @@ Grouped in options:\ [Study.com (no videos)](https://study.com) ##### Magazines/Blogs +[Medium](https://www.medium.com)*\ +Grouped in options:\ +*Medium custom domains* like (opt-in to custom sites for unlisted):\ +[Better Programming](https://betterprogramming.pub) - +[Towards Data Science](https://towardsdatascience.com) + [Apollo Magazine](https://www.apollo-magazine.com) - [Artnet](https://www.artnet.com) - [Atavist Magazine](https://magazine.atavist.com) - @@ -177,7 +182,6 @@ Grouped in options:\ [Commentary Magazine](https://www.commentary.org) - [ESPN USA](https://www.espn.com) - [First Things](https://www.firstthings.com) - -[Medium](https://www.medium.com/topics)* (for custom domains enable custom sites) - [National Review](https://www.nationalreview.com) - [Rolling Stone](https://www.rollingstone.com) - [RugbyPass](https://www.rugbypass.com) - diff --git a/background.js b/background.js index 24492c9..07e1bd3 100755 --- a/background.js +++ b/background.js @@ -763,10 +763,9 @@ ext_api.webRequest.onBeforeSendHeaders.addListener(function(details) { if (!matchUrlDomain(excludedSites, header_referer)) { // remove cookies for sites medium platform (custom domains) - var medium_custom_domains = []; - var medium_custom_domain = (matchUrlDomain('cdn-client.medium.com', details.url) && ['script'].includes(details.type) && !matchUrlDomain(medium_custom_domains.concat(['medium.com', 'towardsdatascience.com']), header_referer) && enabledSites.includes('###_medium_custom')); + var medium_custom_domain = (matchUrlDomain('cdn-client.medium.com', details.url) && ['script'].includes(details.type) && !matchUrlDomain(medium_custom_domains.concat(['medium.com']), header_referer) && enabledSites.includes('###_medium_custom')); if (medium_custom_domain) - medium_custom_domains = customAddRules(medium_custom_domains, '', '', '', 'twitter'); + medium_custom_domains = customAddRules(medium_custom_domains); else { let header_referer_hostname = urlHost(header_referer); if (header_referer_hostname.endsWith('.com.au')) { @@ -1272,12 +1271,12 @@ function remove_cookies_fn(domainVar, exclusions = false) { // remove cookies after page load ext_api.webRequest.onCompleted.addListener(function (details) { - let domainVar = matchUrlDomain(remove_cookies, details.url); + let domain = matchUrlDomain(remove_cookies, details.url); let types = ['main_frame', 'sub_frame', 'xmlhttprequest', 'other']; - if (domainVar === 'medium.com') + if (['medium.com'].concat(medium_custom_domains).includes(domain)) types = ['main_frame', 'image']; - if (domainVar && types.includes(details.type) && enabledSites.includes(domainVar)) { - remove_cookies_fn(domainVar, true); + if (domain && types.includes(details.type) && enabledSites.includes(domain)) { + remove_cookies_fn(domain, true); } }, { urls: [""] diff --git a/changelog.txt b/changelog.txt index 237677b..0f71f3f 100644 --- a/changelog.txt +++ b/changelog.txt @@ -6,6 +6,7 @@ Add Diari de Girona & Emporda Fix El Espectador Fix eNotes Fix Lequipe.fr (json) +Fix Medium custom domains Update badge (site with no fix; X) * v2.6.6.0 (2022-04-24) diff --git a/contentScript.js b/contentScript.js index 274a33c..5084a98 100755 --- a/contentScript.js +++ b/contentScript.js @@ -19,6 +19,7 @@ var fr_groupe_nice_matin_domains = ['monacomatin.mc', 'nicematin.com', 'varmatin var it_ilmessaggero_domains = ['corriereadriatico.it', 'ilgazzettino.it', 'ilmattino.it', 'ilmessaggero.it', 'quotidianodipuglia.it']; var it_repubblica_domains = ['gelocal.it', 'ilsecoloxix.it', 'italian.tech', 'lanuovasardegna.it', 'lastampa.it', 'repubblica.it']; var it_quotidiano_domains = ['ilgiorno.it', 'ilrestodelcarlino.it', 'iltelegrafolivorno.it', 'lanazione.it', 'quotidiano.net']; +var medium_custom_domains = ['betterprogramming.pub', 'towardsdatascience.com']; var nl_mediahuis_region_domains = ['gooieneemlander.nl', 'haarlemsdagblad.nl', 'ijmuidercourant.nl', 'leidschdagblad.nl', 'noordhollandsdagblad.nl']; var no_nhst_media_domains = ['intrafish.com', 'rechargenews.com', 'tradewindsnews.com', 'upstreamonline.com']; var pe_grupo_elcomercio_domains = ['diariocorreo.pe', 'elcomercio.pe', 'gestion.pe']; @@ -209,7 +210,7 @@ if ((bg2csData !== undefined) && bg2csData.cs_code) { // Content workarounds/domain -if (matchDomain(['medium.com', 'towardsdatascience.com']) || document.querySelector('script[src^="https://cdn-client.medium.com/"]')) { +if (matchDomain('medium.com') || matchDomain(medium_custom_domains) || document.querySelector('script[src^="https://cdn-client.medium.com/"]')) { let paywall = document.querySelector('div#paywall-background-color'); removeDOMElement(paywall); if (paywall) { diff --git a/custom/manifest.json b/custom/manifest.json index b5923b0..4be9030 100644 --- a/custom/manifest.json +++ b/custom/manifest.json @@ -42,5 +42,5 @@ "webRequestBlocking", "" ], - "version": "2.6.6.3" + "version": "2.6.6.4" } diff --git a/manifest.json b/manifest.json index 057673f..9d4827e 100755 --- a/manifest.json +++ b/manifest.json @@ -80,6 +80,7 @@ "*://*.berlingske.dk/*", "*://*.betamtb.com/*", "*://*.betternutrition.com/*", + "*://*.betterprogramming.pub/*", "*://*.bicycling.com/*", "*://*.bienpublic.com/*", "*://*.billboard.com/*", @@ -663,5 +664,5 @@ "*://*.wsj.net/*", "*://webcache.googleusercontent.com/*" ], - "version": "2.6.6.3" + "version": "2.6.6.4" } diff --git a/sites.js b/sites.js index 1d82aca..b55c491 100755 --- a/sites.js +++ b/sites.js @@ -1145,11 +1145,14 @@ var defaultSites = { "Medium (free articles only)": { domain: "medium.com", allow_cookies: 1, - remove_cookies: 1, - referer: "twitter" + remove_cookies: 1 }, "Medium custom domains (free articles only; opt-in to custom sites)": { - domain: "###_medium_custom" + domain: "###_medium_custom", + "group": [ + "betterprogramming.pub", + "towardsdatascience.com" + ] }, "Mexico News Daily": { domain: "mexiconewsdaily.com", @@ -1809,11 +1812,6 @@ var defaultSites = { } ] }, - "Towards Data Science": { - domain: "towardsdatascience.com", - allow_cookies: 1, - referer: "twitter" - }, "TownNews sites (Blox CMS)": { domain: "###_usa_townnews" }, @@ -2081,6 +2079,7 @@ var au_comm_media_domains = grouped_sites['###_au_comm_media']; var au_news_corp_domains = grouped_sites['###_au_news_corp']; var fr_groupe_sud_ouest_domains = grouped_sites['###_fr_groupe_sud_ouest']; var it_repubblica_domains = defaultSites['###_gr_it_repubblica_domains']['group_rule_domains']; +var medium_custom_domains = grouped_sites['###_medium_custom']; var nl_mediahuis_region_domains = grouped_sites['###_nl_mediahuis_region']; var no_nhst_media_domains = grouped_sites['###_no_nhst_media']; var usa_theathletic_domains = grouped_sites['###_usa_theathletic']; diff --git a/sites_updated.json b/sites_updated.json index 949e985..8373523 100644 --- a/sites_updated.json +++ b/sites_updated.json @@ -1,16 +1,4 @@ { - "ABC.es": { - "domain": "abc.es", - "allow_cookies": 1, - "block_regex": "(\\.evolok\\.net\\/|cdn\\.ampproject\\.org\\/v\\d\\/amp-access-.+\\.js)", - "useragent": "googlebot", - "amp_redirect": ".cierre-suscripcion:not([style=\"display: none;\"]" - }, - "Aftonbladet": { - "domain": "aftonbladet.se", - "allow_cookies": 1, - "useragent": "googlebot" - }, "Automobilwoche": { "domain": "automobilwoche.de", "allow_cookies": 1, @@ -62,23 +50,12 @@ "domain": "gymclimber.com", "group_rule": "###_gr_usa_outside_mag_domains" }, - "Investors' Chronicle": { - "allow_cookies": 1, - "domain": "investorschronicle.co.uk", - "referer": "google" - }, "Italia Oggi": { "domain": "italiaoggi.it", "allow_cookies": 1, "ld_json": "div.boxAbb|div.article-locked", "new_site": 1 }, - "Outlook India": { - "domain": "outlookindia.com", - "allow_cookies": 1, - "ld_json": "div.paywall|div#articleBody", - "new_site": 1 - }, "Peloton": { "domain": "pelotonmagazine.com", "group_rule": "###_gr_usa_outside_mag_domains" @@ -91,15 +68,6 @@ "domain": "rockandice.com", "group_rule": "###_gr_usa_outside_mag_domains" }, - "Vogue Business": { - "allow_cookies": 1, - "domain": "voguebusiness.com", - "useragent": "googlebot", - "block_regex": "cdn\\.ampproject\\.org\\/v\\d\\/amp-subscriptions-.+\\.js", - "amp_redirect": "div[class*=\"PaywallInlineBarrier\"]", - "amp_unhide": 1, - "new_site": 1 - }, "###_gr_usa_outside_mag_domains": { "group_rule_domains": ["betternutrition.com", "gymclimber.com", "pelotonmagazine.com", "podiumrunner.com", "rockandice.com"], "allow_cookies": 1,