From 96f1c0df794ca330ee34d017e6d8c266c7a8df03 Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Fri, 13 Aug 2021 15:29:49 +0200 Subject: [PATCH] Fix The Daily Beast (members-only) --- README.md | 2 +- changelog.txt | 1 + contentScript.js | 39 ++++++++++++++++++++++++++++++++++++++- custom/manifest.json | 2 +- manifest.json | 2 +- sites.js | 2 +- 6 files changed, 43 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 859d360..7f86578 100755 --- a/README.md +++ b/README.md @@ -168,7 +168,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 fbd6e68..681b7c8 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 100755 --- 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/custom/manifest.json b/custom/manifest.json index f992a95..852153f 100644 --- a/custom/manifest.json +++ b/custom/manifest.json @@ -38,5 +38,5 @@ "webRequestBlocking", "" ], - "version": "2.3.2.3" + "version": "2.3.2.4" } \ No newline at end of file diff --git a/manifest.json b/manifest.json index af34c12..76fb066 100755 --- a/manifest.json +++ b/manifest.json @@ -533,5 +533,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 100755 --- 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",