Only consider "stuffing" if there are more than 3 hashtags

This commit is contained in:
Lim Chee Aun 2023-04-23 22:00:32 +08:00
parent 7f54c7ae93
commit 338b556e34

View file

@ -139,6 +139,7 @@ function enhanceContent(content, opts = {}) {
// Get the <p> 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) {