mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-01-22 16:46:28 +01:00
Slightly more accurate content length
This commit is contained in:
parent
4c7c518d4d
commit
ec4320d53e
1 changed files with 5 additions and 0 deletions
|
@ -2,5 +2,10 @@ const div = document.createElement('div');
|
||||||
export default function htmlContentLength(html) {
|
export default function htmlContentLength(html) {
|
||||||
if (!html) return 0;
|
if (!html) return 0;
|
||||||
div.innerHTML = html;
|
div.innerHTML = html;
|
||||||
|
// .invisible spans for links
|
||||||
|
// e.g. <span class="invisible">https://</span>mastodon.social
|
||||||
|
div.querySelectorAll('.invisible').forEach((el) => {
|
||||||
|
el.remove();
|
||||||
|
});
|
||||||
return div.innerText.length;
|
return div.innerText.length;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue