From 3a837ab31272e8e1b86c61bfc7c4aa126bd39272 Mon Sep 17 00:00:00 2001 From: Adam <36013816+iamadamdev@users.noreply.github.com> Date: Mon, 11 Apr 2022 21:03:06 -0700 Subject: [PATCH] Add theathletic.com/co.uk --- README.md | 2 ++ manifest-ff.json | 8 ++++++-- src/js/contentScript.js | 26 ++++++++++++++++++++++++++ src/js/sites.js | 2 ++ 4 files changed, 36 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0cb84b3..73ba58c 100755 --- a/README.md +++ b/README.md @@ -143,6 +143,8 @@ [The Advocate](https://www.theadvocate.com.au)\ [The Age](https://www.theage.com.au)\ [The American Interest](https://www.the-american-interest.com)\ +[The Athletic](https://www.theathletic.com)\ +[The Athletic (UK)](https://www.theathletic.co.uk)\ [The Atlantic](https://www.theatlantic.com)\ [The Australian Financial Review](https://www.afr.com)\ [The Australian](https://www.theaustralian.com.au)\ diff --git a/manifest-ff.json b/manifest-ff.json index a6c7631..3bf329f 100755 --- a/manifest-ff.json +++ b/manifest-ff.json @@ -73,7 +73,9 @@ "*://*.time.com/*", "*://*.expansion.com/*", "*://*.foreignpolicy.com/*", - "*://*.bostonglobe.com/*" + "*://*.bostonglobe.com/*", + "*://*.theathletic.com/*", + "*://*.theathletic.co.uk/*" ], "js": ["src/js/contentScript.js"] } @@ -276,7 +278,9 @@ "*://*.zeit.de/*", "*://*.ampproject.org/*", "*://*.reuters.com/*", - "*://*.expansion.com/*" + "*://*.expansion.com/*", + "*://*.theathletic.com/*", + "*://*.theathletic.co.uk/*" ], "version": "1.7.9" } diff --git a/src/js/contentScript.js b/src/js/contentScript.js index 78ecaff..70d60ea 100755 --- a/src/js/contentScript.js +++ b/src/js/contentScript.js @@ -476,6 +476,21 @@ if (matchDomain('elmercurio.com')) { document.querySelectorAll('div[class*="fancybox"]').forEach(function (el) { removeDOMElement(el); }); +} else if (matchDomain(['theathletic.com', 'theathletic.co.uk'])) { + if (!window.location.href.includes('?amp')) { + const paywall = document.querySelectorAll('div#paywall-container, div[subscriptions-action="subscribe"], a.headline-paywall'); + const amphtml = document.querySelector('link[rel="amphtml"]'); + if (paywall.length && amphtml) { + removeDOMElement(...paywall); + window.setTimeout(function () { + window.location.href = amphtml.href; + }, 500); + } + } else { + ampUnhideSubscriptionsSection(); + const subscriptionsActions = document.querySelectorAll('[subscriptions-actions]'); + removeDOMElement(...subscriptionsActions); + } } else if (matchDomain('newyorker.com')) { blockElement('.paywall-bar', true); blockElement('.paywall-modal'); @@ -743,3 +758,14 @@ function blockElement (selector, blockAlways = false) { } }).observe(document, { subtree: true, childList: true }); } + +function ampUnhideSubscriptionsSection (ampAdsSel = 'amp-ad, .ad') { + const preview = document.querySelector('[subscriptions-section="content-not-granted"]'); + removeDOMElement(preview); + const subscriptionsSection = document.querySelectorAll('[subscriptions-section="content"]'); + for (const elem of subscriptionsSection) { + elem.removeAttribute('subscriptions-section'); + } + const ampAds = document.querySelectorAll(ampAdsSel); + removeDOMElement(...ampAds); +} diff --git a/src/js/sites.js b/src/js/sites.js index 7a4726b..46e053a 100755 --- a/src/js/sites.js +++ b/src/js/sites.js @@ -122,6 +122,8 @@ const defaultSites = { 'The Advocate': 'theadvocate.com.au', 'The Age': 'theage.com.au', 'The American Interest': 'the-american-interest.com', + 'The Athletic': 'theathletic.com', + 'The Athletic (UK)': 'theathletic.co.uk', 'The Atlantic': 'theatlantic.com', 'The Australian Financial Review': 'afr.com', 'The Australian': 'theaustralian.com.au',