From 338b556e3478fc95c9cb0abc70384a7454cfd49c Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Sun, 23 Apr 2023 22:00:32 +0800 Subject: [PATCH] Only consider "stuffing" if there are more than 3 hashtags --- src/utils/enhance-content.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils/enhance-content.js b/src/utils/enhance-content.js index 6012f377..bf0ef916 100644 --- a/src/utils/enhance-content.js +++ b/src/utils/enhance-content.js @@ -139,6 +139,7 @@ function enhanceContent(content, opts = {}) { // Get the

that contains a lot of hashtags, add a class to it const hashtagStuffedParagraph = Array.from(dom.querySelectorAll('p')).find( (p) => { + let hashtagCount = 0; for (let i = 0; i < p.childNodes.length; i++) { const node = p.childNodes[i]; @@ -151,12 +152,15 @@ function enhanceContent(content, opts = {}) { const linkText = node.textContent.trim(); if (!linkText || !linkText.startsWith('#')) { return false; + } else { + hashtagCount++; } } else { return false; } } - return true; + // Only consider "stuffing" if there are more than 3 hashtags + return hashtagCount > 3; }, ); if (hashtagStuffedParagraph) {