From 1be0dd50ef885a1361c33482de5a38e87f594e00 Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Thu, 8 Sep 2022 22:19:27 +0800 Subject: [PATCH] Remove anchors class names that contain "tw-text-substack-secondary" as they are used for Substack subscription --- packages/readabilityjs/Readability.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/readabilityjs/Readability.js b/packages/readabilityjs/Readability.js index c486f6362..521983738 100644 --- a/packages/readabilityjs/Readability.js +++ b/packages/readabilityjs/Readability.js @@ -925,10 +925,12 @@ Readability.prototype = { // For example, this article (https://www.sciencedirect.com/science/article/abs/pii/S0047248498902196) // has a "View full text" anchor at the bottom of the page this._removeNodes(this._getAllNodesWithTag(articleContent, ["a"]), function (anchor) { - const possibleRedundantText = /view full|skip to content/ig; + const possibleRedundantText = /view full|skip to content|Open in browser/ig; const innerText = this._getInnerText(anchor); - - return possibleRedundantText.test(innerText) && innerText.length <= 30; + // also removes anchors class names that contain 'tw-text-substack-secondary' as they are used for Substack subscription + const possibleRedundantClassName = 'tw-text-substack-secondary' + const className = anchor.className; + return (possibleRedundantText.test(innerText) && innerText.length <= 30) || className.includes(possibleRedundantClassName); }); },