From 2c780d52e3c48dda03400647e7970b0a767434dd Mon Sep 17 00:00:00 2001 From: nuttylmao Date: Thu, 12 Jun 2025 03:33:36 +1000 Subject: [PATCH] Fixed issue where emotes didn't render properly --- horizontal-chat/script.js | 4 +- multichat-overlay/script.js | 189 +++++++++++++++++++++++++++++++++++- 2 files changed, 188 insertions(+), 5 deletions(-) diff --git a/horizontal-chat/script.js b/horizontal-chat/script.js index 48a2571..5c46101 100644 --- a/horizontal-chat/script.js +++ b/horizontal-chat/script.js @@ -368,7 +368,7 @@ async function TwitchChatMessage(data) { } else { // For non-word emotes, ensure they are surrounded by non-word characters or boundaries - regexPattern = `(?:^|[^\\w])${emoteName}(?:$|[^\\w])`; + regexPattern = `(?<=^|[^\\w])${emoteName}(?=$|[^\\w])`; } const regex = new RegExp(regexPattern, 'g'); @@ -447,7 +447,7 @@ async function TwitchAnnouncement(data) { } else { // For non-word emotes, ensure they are surrounded by non-word characters or boundaries - regexPattern = `(?:^|[^\\w])${emoteName}(?:$|[^\\w])`; + regexPattern = `(?<=^|[^\\w])${emoteName}(?=$|[^\\w])`; } const regex = new RegExp(regexPattern, 'g'); diff --git a/multichat-overlay/script.js b/multichat-overlay/script.js index eb52f58..269e76d 100644 --- a/multichat-overlay/script.js +++ b/multichat-overlay/script.js @@ -423,7 +423,7 @@ async function TwitchChatMessage(data) { } else { // For non-word emotes, ensure they are surrounded by non-word characters or boundaries - regexPattern = `(?:^|[^\\w])${emoteName}(?:$|[^\\w])`; + regexPattern = `(?<=^|[^\\w])${emoteName}(?=$|[^\\w])`; } const regex = new RegExp(regexPattern, 'g'); @@ -619,7 +619,7 @@ async function TwitchAnnouncement(data) { } else { // For non-word emotes, ensure they are surrounded by non-word characters or boundaries - regexPattern = `(?:^|[^\\w])${emoteName}(?:$|[^\\w])`; + regexPattern = `(?<=^|[^\\w])${emoteName}(?=$|[^\\w])`; } const regex = new RegExp(regexPattern, 'g'); @@ -2090,4 +2090,187 @@ function SetConnectionStatus(connected) { statusContainer.style.transition = ""; statusContainer.style.opacity = 1; } -} \ No newline at end of file +} + +let data = { + "message": { + "internal": false, + "msgId": "6d291dc3-349a-495e-aa20-7b8c45bd173b", + "clientNonce": "7837d3cc32ebbb0139dfa6e12036fbe7", + "userId": "54983562", + "username": "nutty", + "role": 4, + "subscriber": true, + "subscriptionTier": "3000", + "displayName": "nutty", + "color": "#FF69B4", + "channel": "nutty", + "message": ":D :D :D", + "isHighlighted": false, + "isMe": false, + "isCustomReward": false, + "isAnonymous": false, + "isReply": false, + "bits": 0, + "firstMessage": false, + "returningChatter": false, + "hasBits": false, + "emotes": [ + { + "id": "555555560", + "type": "Twitch", + "name": ":D", + "startIndex": 0, + "endIndex": 1, + "imageUrl": "https://static-cdn.jtvnw.net/emoticons/v2/555555560/default/dark/2.0" + }, + { + "id": "555555560", + "type": "Twitch", + "name": ":D", + "startIndex": 3, + "endIndex": 4, + "imageUrl": "https://static-cdn.jtvnw.net/emoticons/v2/555555560/default/dark/2.0" + }, + { + "id": "555555560", + "type": "Twitch", + "name": ":D", + "startIndex": 6, + "endIndex": 7, + "imageUrl": "https://static-cdn.jtvnw.net/emoticons/v2/555555560/default/dark/2.0" + } + ], + "cheerEmotes": [], + "badges": [ + { + "name": "broadcaster", + "version": "1", + "imageUrl": "https://static-cdn.jtvnw.net/badges/v1/5527c58c-fb7d-422d-b71b-f309dcb85cc1/3", + "info": "" + }, + { + "name": "subscriber", + "version": "3012", + "imageUrl": "https://static-cdn.jtvnw.net/badges/v1/d37c6ddc-7d3e-44c8-aad8-adfde6fb0462/3", + "info": "96" + }, + { + "name": "clips-leader", + "version": "2", + "imageUrl": "https://static-cdn.jtvnw.net/badges/v1/9eddf7ab-aa46-4798-abe2-710db1043254/3", + "info": "" + } + ], + "monthsSubscribed": 96, + "isTest": false, + "sharedChat": false, + "sourceBadges": [] + }, + "user": { + "role": 4, + "badges": [ + { + "name": "broadcaster", + "version": "1", + "imageUrl": "https://static-cdn.jtvnw.net/badges/v1/5527c58c-fb7d-422d-b71b-f309dcb85cc1/3", + "info": "" + }, + { + "name": "subscriber", + "version": "3012", + "imageUrl": "https://static-cdn.jtvnw.net/badges/v1/d37c6ddc-7d3e-44c8-aad8-adfde6fb0462/3", + "info": "96" + }, + { + "name": "clips-leader", + "version": "2", + "imageUrl": "https://static-cdn.jtvnw.net/badges/v1/9eddf7ab-aa46-4798-abe2-710db1043254/3", + "info": "" + } + ], + "color": "#FF69B4", + "subscribed": true, + "subscriptionTier": "3000", + "monthsSubscribed": 96, + "id": "54983562", + "login": "nutty", + "name": "nutty", + "type": "twitch" + }, + "messageId": "6d291dc3-349a-495e-aa20-7b8c45bd173b", + "meta": { + "internal": false, + "clientNonce": "7837d3cc32ebbb0139dfa6e12036fbe7", + "firstMessage": false, + "returningChatter": false, + "isHighlighted": false, + "isMe": false, + "isCustomReward": false, + "isTest": false + }, + "anonymous": false, + "text": ":D :D :D", + "emotes": [ + { + "id": "555555560", + "type": "Twitch", + "name": ":D", + "startIndex": 0, + "endIndex": 1, + "imageUrl": "https://static-cdn.jtvnw.net/emoticons/v2/555555560/default/dark/2.0" + }, + { + "id": "555555560", + "type": "Twitch", + "name": ":D", + "startIndex": 3, + "endIndex": 4, + "imageUrl": "https://static-cdn.jtvnw.net/emoticons/v2/555555560/default/dark/2.0" + }, + { + "id": "555555560", + "type": "Twitch", + "name": ":D", + "startIndex": 6, + "endIndex": 7, + "imageUrl": "https://static-cdn.jtvnw.net/emoticons/v2/555555560/default/dark/2.0" + } + ], + "parts": [ + { + "source": "Twitch", + "imageUrl": "https://static-cdn.jtvnw.net/emoticons/v2/555555560/default/dark/2.0", + "zeroWidth": false, + "type": "emote", + "text": ":D" + }, + { + "type": "text", + "text": " " + }, + { + "source": "Twitch", + "imageUrl": "https://static-cdn.jtvnw.net/emoticons/v2/555555560/default/dark/2.0", + "zeroWidth": false, + "type": "emote", + "text": ":D" + }, + { + "type": "text", + "text": " " + }, + { + "source": "Twitch", + "imageUrl": "https://static-cdn.jtvnw.net/emoticons/v2/555555560/default/dark/2.0", + "zeroWidth": false, + "type": "emote", + "text": ":D" + } + ], + "isReply": false, + "isSharedChat": false, + "isTest": false + } + + TwitchChatMessage(data); \ No newline at end of file