mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-12-19 06:22:09 +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;
|
|
}
|