From e15bc95ae41e7e63428be82c70ef55142f1988d3 Mon Sep 17 00:00:00 2001 From: Adam <36013816+iamadamdev@users.noreply.github.com> Date: Thu, 8 Sep 2022 11:20:53 -0700 Subject: [PATCH] Fix NY Times Cooking --- src/js/background.js | 3 ++- src/js/contentScript.js | 13 ++----------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/js/background.js b/src/js/background.js index 191f5bc..261242a 100755 --- a/src/js/background.js +++ b/src/js/background.js @@ -242,7 +242,8 @@ const blockedRegexes = { 'expansion.com': /cdn\.ampproject\.org\/v\d\/amp-(access|ad|consent)-.+\.js/, 'chicagobusiness.com': /(\.tinypass\.com\/|\.chicagobusiness\.com\/.+\/js\/js_.+\.js)/, 'dailytelegraph.com.au': /cdn\.ampproject\.org\/v\d\/amp-(access|ad|consent)-.+\.js/, - 'theglobeandmail.com': /(\.theglobeandmail\.com\/pf\/dist\/engine\/react\.js|smartwall\.theglobeandmail\.com\/)/ + 'theglobeandmail.com': /(\.theglobeandmail\.com\/pf\/dist\/engine\/react\.js|smartwall\.theglobeandmail\.com\/)/, + 'nytimes.com': /(meter-svc\.nytimes\.com\/meter\.js|mwcm\.nyt\.com\/.+\.js|cooking\.nytimes\.com\/api\/.+\/access)/ }; const userAgentDesktop = 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)'; diff --git a/src/js/contentScript.js b/src/js/contentScript.js index 82c4ff3..d069524 100755 --- a/src/js/contentScript.js +++ b/src/js/contentScript.js @@ -261,17 +261,8 @@ if (matchDomain('elmercurio.com')) { removeDOMElement(counter, coBanner, support); }); } else if (matchDomain('nytimes.com')) { - const previewButton = document.querySelector('.css-3s1ce0'); - if (previewButton) { previewButton.click(); } - blockElement('.css-3fbowa'); // Prevent bottom dock from appearing - blockElement('#gateway-content'); // Remove paywall - blockElement('.css-1bd8bfl'); // Remove filter - // Restore scrolling - document.onreadystatechange = function () { - if (document.readyState === 'complete') { - document.querySelector('.css-mcm29f').setAttribute('style', 'position:relative'); - } - }; + const banners = document.querySelectorAll('div[data-testid="inline-message"], div[id^="ad-"], div.expanded-dock'); + removeDOMElement(...banners); } else if (matchDomain('technologyreview.com')) { window.setTimeout(function () { const bodyObscured = document.querySelector('body[class*="body__obscureContent"]');