diff --git a/.common/utils/helpers.js b/.common/utils/helpers.js index 3998ca6..983261e 100644 --- a/.common/utils/helpers.js +++ b/.common/utils/helpers.js @@ -325,7 +325,7 @@ function RandomHex(str) { } // Used to construct a message from "parts" variable commonly found in Streamer.bot chat messages -function ConstructMessageFromParts(parts, isHorizontalChat = false) { +function ConstructMessageFromParts(parts, isHorizontalChat = false, twitchGIFsEnabled = false) { return parts.map(part => { if (part.emoji) return ` ${EscapeHTML(part.text)} `; @@ -358,10 +358,15 @@ function ConstructMessageFromParts(parts, isHorizontalChat = false) { case "mention": return part.text; case "gif": - if (!isHorizontalChat) - return ``; + if (twitchGIFsEnabled) + { + if (!isHorizontalChat) + return ``; + else + return ``; + } else - return ``; + return `${EscapeHTML(part.text)}`; default: return `${EscapeHTML(part.text)}`; } diff --git a/horizontal-chat/script.js b/horizontal-chat/script.js index a709951..d08138f 100644 --- a/horizontal-chat/script.js +++ b/horizontal-chat/script.js @@ -51,6 +51,7 @@ const showTwitchPowerUpRedemptions = GetBooleanParam("showTwitchPowerUpRedemptio const showTwitchRaids = GetBooleanParam("showTwitchRaids", true); const showTwitchWatchStreaks = GetBooleanParam("showTwitchWatchStreaks", true); const showTwitchSharedChat = GetBooleanParam("showTwitchSharedChat", true); +const showTwitchGIFs = GetBooleanParam("showTwitchGIFs", false); const showKickMessages = GetBooleanParam("showKickMessages", true); const showKickFollows = GetBooleanParam("showKickFollows", false); @@ -588,7 +589,7 @@ async function TwitchChatMessage(data) { } // Set the message data - let message = ConstructMessageFromParts(data.parts, isHorizontalChat = true); + let message = ConstructMessageFromParts(data.parts, true, showTwitchGIFs); const messageColor = data.user.color; const role = data.user.role; @@ -693,7 +694,7 @@ async function TwitchAnnouncement(data) { break; } - let message = ConstructMessageFromParts(data.parts, isHorizontalChat = true); + let message = ConstructMessageFromParts(data.parts, true, showTwitchGIFs); ShowAlert(message, background); } @@ -949,7 +950,7 @@ function YouTubeMessage(data) { // Set the message data //let message = RenderMessageWithEmotesHTML(data.message, data.emotes); - let message = ConstructMessageFromParts(data.parts, isHorizontalChat = true); + let message = ConstructMessageFromParts(data.parts, true, showTwitchGIFs); // Set furry mode if (furryMode) @@ -1394,7 +1395,7 @@ async function KickChatMessage(data) { } // Set the message data - let message = ConstructMessageFromParts(data.parts, isHorizontalChat = true); + let message = ConstructMessageFromParts(data.parts, true, showTwitchGIFs); // Set furry mode if (furryMode) diff --git a/horizontal-chat/settings/settings.json b/horizontal-chat/settings/settings.json index fe23d26..25a9c93 100644 --- a/horizontal-chat/settings/settings.json +++ b/horizontal-chat/settings/settings.json @@ -226,6 +226,14 @@ "defaultValue": true, "group": "Which Twitch messages do you want to see?" }, + { + "id": "showTwitchGIFs", + "label": "GIFs", + "description": "Tier 2/3 subs only", + "type": "checkbox", + "defaultValue": false, + "group": "Which Twitch messages do you want to see?" + }, { "id": "showYouTubeMessages", "label": "Chat Messages", diff --git a/multichat-overlay/script.js b/multichat-overlay/script.js index 3d3a891..e436fca 100644 --- a/multichat-overlay/script.js +++ b/multichat-overlay/script.js @@ -57,6 +57,7 @@ const showTwitchPowerUpRedemptions = GetBooleanParam("showTwitchPowerUpRedemptio const showTwitchRaids = GetBooleanParam("showTwitchRaids", true); const showTwitchWatchStreaks = GetBooleanParam("showTwitchWatchStreaks", true); const showTwitchSharedChat = GetIntParam("showTwitchSharedChat", 2); +const showTwitchGIFs = GetBooleanParam("showTwitchGIFs", true); const showKickMessages = GetBooleanParam("showKickMessages", true); const showKickFollows = GetBooleanParam("showKickFollows", false); @@ -687,7 +688,7 @@ async function TwitchChatMessage(data) { } // Set the message data - let message = ConstructMessageFromParts(data.parts); + let message = ConstructMessageFromParts(data.parts, false, showTwitchGIFs); const messageColor = data.user.color; const role = data.user.role; @@ -939,7 +940,7 @@ async function TwitchAnnouncement(data) { else content.querySelector("#username").innerText = `${data.user.name} (${data.user.login})`; content.querySelector("#username").style.color = data.user.color; - content.querySelector("#message").innerHTML = ConstructMessageFromParts(data.parts); + content.querySelector("#message").innerHTML = ConstructMessageFromParts(data.parts, false, showTwitchGIFs); // Remove the line break content.querySelector("#colon-separator").style.display = `inline`; @@ -1322,7 +1323,7 @@ async function TwitchWatchStreak(data) { const watchStreak = data.watchStreak ?? data.streak_count ?? data.streakCount; titleDiv.innerText = `${displayName} is currently on a ${watchStreak} stream streak! `; - contentDiv.innerHTML = ConstructMessageFromParts(data.parts); + contentDiv.innerHTML = ConstructMessageFromParts(data.parts, false, showTwitchGIFs); AddMessageItem(instance, data.messageId); } @@ -1439,7 +1440,7 @@ async function YouTubeMessage(data) { // Set the message data //let message = RenderMessageWithEmotesHTML(data.message, data.emotes); - let message = ConstructMessageFromParts(data.parts); + let message = ConstructMessageFromParts(data.parts, false, showTwitchGIFs); // Highlight mentions const mentionRgx = new RegExp(`(^|\\s)@${youtubeUsername}(\\s|$)`, 'i'); @@ -2484,7 +2485,7 @@ async function KickChatMessage(data) { } // Set the message data - let message = ConstructMessageFromParts(data.parts); + let message = ConstructMessageFromParts(data.parts, false, showTwitchGIFs); // Highlight mentions const mentionRgx = new RegExp(`(^|\\s)@${kickUsername}(\\s|$)`, 'i'); diff --git a/multichat-overlay/settings/settings.json b/multichat-overlay/settings/settings.json index b738e4b..1ff85d3 100644 --- a/multichat-overlay/settings/settings.json +++ b/multichat-overlay/settings/settings.json @@ -355,6 +355,14 @@ "defaultValue": 2, "group": "Which Twitch messages do you want to see?" }, + { + "id": "showTwitchGIFs", + "label": "GIFs", + "description": "Tier 2/3 subs only", + "type": "checkbox", + "defaultValue": true, + "group": "Which Twitch messages do you want to see?" + }, { "id": "showYouTubeMessages", "label": "Chat Messages",