From ffabd6188d94ead9bc6b1656f8c47299d48fe922 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Wed, 10 Jan 2024 01:48:20 +0800 Subject: [PATCH] Truncate URLs --- src/utils/getHTMLText.jsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/utils/getHTMLText.jsx b/src/utils/getHTMLText.jsx index 142f7e7d..9ad74a3c 100644 --- a/src/utils/getHTMLText.jsx +++ b/src/utils/getHTMLText.jsx @@ -9,6 +9,17 @@ function getHTMLText(html) { div.querySelectorAll('br').forEach((br) => { br.replaceWith('\n'); }); + + // MASTODON-SPECIFIC classes + // Remove .invisible + div.querySelectorAll('.invisible').forEach((el) => { + el.remove(); + }); + // Add … at end of .ellipsis + div.querySelectorAll('.ellipsis').forEach((el) => { + el.append('...'); + }); + return div.innerText.replace(/[\r\n]{3,}/g, '\n\n').trim(); }