mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-03-21 13:19:22 +01:00
Only consider "stuffing" if there are more than 3 hashtags
This commit is contained in:
parent
7f54c7ae93
commit
338b556e34
1 changed files with 5 additions and 1 deletions
|
@ -139,6 +139,7 @@ function enhanceContent(content, opts = {}) {
|
||||||
// Get the <p> that contains a lot of hashtags, add a class to it
|
// Get the <p> that contains a lot of hashtags, add a class to it
|
||||||
const hashtagStuffedParagraph = Array.from(dom.querySelectorAll('p')).find(
|
const hashtagStuffedParagraph = Array.from(dom.querySelectorAll('p')).find(
|
||||||
(p) => {
|
(p) => {
|
||||||
|
let hashtagCount = 0;
|
||||||
for (let i = 0; i < p.childNodes.length; i++) {
|
for (let i = 0; i < p.childNodes.length; i++) {
|
||||||
const node = p.childNodes[i];
|
const node = p.childNodes[i];
|
||||||
|
|
||||||
|
@ -151,12 +152,15 @@ function enhanceContent(content, opts = {}) {
|
||||||
const linkText = node.textContent.trim();
|
const linkText = node.textContent.trim();
|
||||||
if (!linkText || !linkText.startsWith('#')) {
|
if (!linkText || !linkText.startsWith('#')) {
|
||||||
return false;
|
return false;
|
||||||
|
} else {
|
||||||
|
hashtagCount++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
// Only consider "stuffing" if there are more than 3 hashtags
|
||||||
|
return hashtagCount > 3;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
if (hashtagStuffedParagraph) {
|
if (hashtagStuffedParagraph) {
|
||||||
|
|
Loading…
Reference in a new issue