diff --git a/script.js b/script.js index 1b25f7b..6009dcb 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)}
${DOMPurify.sanitize(post.content)}
+${replaceEmojies(DOMPurify.sanitize(post.content), post.emojis)}
${post.spoiler_text ? `${DOMPurify.sanitize(post.spoiler_text)}
` : ''}${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)}