diff --git a/script.js b/script.js index fa94ffb..af3bfbc 100644 --- a/script.js +++ b/script.js @@ -104,6 +104,14 @@ const updateTimesOnPage = function() { }); }; +// replace certain emojies in some text with images +const replaceEmojies = (text, emojis) => { + emojis.forEach(emoji => { + text = text.replaceAll(`:${emoji.shortcode}:`, ``); + }); + return text; +}; + // displayPost creates and displays a post const displayPost = function(post) { if (existingPosts.includes(post.id) || (!includeReplies && post.in_reply_to_id !== null)) return 0; @@ -115,10 +123,10 @@ const displayPost = function(post) {
-

${DOMPurify.sanitize(post.account.display_name)} @${DOMPurify.sanitize(post.account.acct)}

+

${replaceEmojies(DOMPurify.sanitize(post.account.display_name), post.account.emojis)} @${DOMPurify.sanitize(post.account.acct)}

${post.media_attachments[0] ? `` : ''} -

${DOMPurify.sanitize(post.content)}

+

${replaceEmojies(DOMPurify.sanitize(post.content), post.emojis)}

${post.spoiler_text ? `

${DOMPurify.sanitize(post.spoiler_text)}

` : ''}

${timeAgo(secondsAgo(new Date(post.created_at)))}

@@ -185,16 +193,16 @@ const updateCarousel = function(slides, posts) { else { newHTML += `