From f5ae3abd074e99a8c6c1da52be8685f1dc0a573a Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Fri, 13 Aug 2021 15:29:59 +0200 Subject: [PATCH] Fix The Daily Beast (members-only) --- README.md | 2 +- changelog.txt | 1 + contentScript.js | 39 ++++++++++++++++++++++++++++++++++++++- manifest.json | 2 +- sites.js | 2 +- 5 files changed, 42 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 83f031e..9d1a324 100644 --- a/README.md +++ b/README.md @@ -134,7 +134,7 @@ NHST Media Group sites like (opt-in to custom sites) [Sports Illustrated](https://www.si.com) - [The Art Newspaper](https://www.theartnewspaper.com) - [The Athletic](https://theathletic.com) - -[The Daily Beast](https://www.thedailybeast.com)* - +[The Daily Beast](https://www.thedailybeast.com) - [The New Atlantis](https://www.thenewatlantis.com) - [The Point Magazine](https://thepointmag.com) - [The Wrap](https://www.thewrap.com) - diff --git a/changelog.txt b/changelog.txt index 023eae9..be3d858 100644 --- a/changelog.txt +++ b/changelog.txt @@ -5,6 +5,7 @@ Post-release Fix group McClatchy (unlisted sites) Fix MediaNama (modal) Fix The Athletic +Fix The Daily Beast (members-only) * v2.3.2.0 (2021-08-08) Add Inc42 (India) diff --git a/contentScript.js b/contentScript.js index 125242c..68f818a 100644 --- a/contentScript.js +++ b/contentScript.js @@ -1688,7 +1688,7 @@ else if (matchDomain('bloomberg.com')) { if (url.includes('/articles/')) { let leaderboard = document.querySelector('div[id^="leaderboard"], div.leaderboard-wrapper'); let shimmering_content = document.querySelectorAll('div[class^="shimmering-"]'); - let page_ad = document.querySelectorAll('div.page-ad'); + let page_ad = document.querySelectorAll('div.page-ad, div[data-ad-placeholder]'); removeDOMElement(leaderboard, ...shimmering_content, ...page_ad); let hidden_images = document.querySelectorAll('img.lazy-img__image[src][data-native-src]'); for (let hidden_image of hidden_images) { @@ -2506,6 +2506,43 @@ else if (matchDomain('theatlantic.com')) { removeDOMElement(banner); } +else if (matchDomain('thedailybeast.com')) { + let paywall = document.querySelector('div.Body__paywall-container'); + if (paywall) { + removeDOMElement(paywall); + let json_script = document.querySelector('script[displayName="initialState"]'); + if (json_script) { + let json_text = json_script.innerText.includes('"sections":') ? json_script.innerText.split('"sections":')[1].split('},"')[0] : ''; + if (json_text) { + let pars = json_text.split('"').filter(function (value) { + return (value.split('[').length < 2 && value.split(']').length < 2); + }); + let mobile_doc = document.querySelector('div.Mobiledoc'); + if (mobile_doc) { + let mobile_doc_text = mobile_doc.innerText.replace(/(\r|\n)/g, ''); + let par, par_elem; + for (let elem of pars) { + if (elem === 'p') { + if (par && !mobile_doc_text.includes(par)) { + par_elem = document.createElement('p'); + par_elem.innerText = par; + mobile_doc.appendChild(par_elem); + } + par = ''; + } else + par += elem; + } + if (par && !mobile_doc_text.includes(par)) { + par_elem = document.createElement('p'); + par_elem.innerText = par; + mobile_doc.appendChild(par_elem); + } + } + } + } + } +} + else if (matchDomain('thediplomat.com')) { let preview = document.querySelector('.dpl-preview'); if (preview) diff --git a/manifest.json b/manifest.json index c428a50..693c8a7 100644 --- a/manifest.json +++ b/manifest.json @@ -545,5 +545,5 @@ "*://*.wallkit.net/*", "*://*.wsj.net/*" ], - "version": "2.3.2.3" + "version": "2.3.2.4" } \ No newline at end of file diff --git a/sites.js b/sites.js index 7c1f964..74056bc 100644 --- a/sites.js +++ b/sites.js @@ -246,7 +246,7 @@ var defaultSites = "The Business Journals": "bizjournals.com", "The Business of Fashion": "businessoffashion.com", "The Christian Science Monitor": "csmonitor.com", - "The Daily Beast (free articles only)": "thedailybeast.com", + "The Daily Beast": "thedailybeast.com", "The Dallas Morning News": "dallasnews.com", "The Denver Post": "denverpost.com", "The Diplomat": "thediplomat.com",