mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-12-22 07:24:23 +03:00
11 lines
348 B
JavaScript
11 lines
348 B
JavaScript
const div = document.createElement('div');
|
|
export default function htmlContentLength(html) {
|
|
if (!html) return 0;
|
|
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;
|
|
}
|