From 0703d4798585e9fcf74d91ed944bcb3076c70883 Mon Sep 17 00:00:00 2001 From: nuttylmao Date: Sun, 30 Mar 2025 12:29:39 +1100 Subject: [PATCH] Added support for Twitch Shared Chat --- horizontal-chat/script.js | 16 ++++++++--- horizontal-chat/settings/settings.json | 8 ++++++ horizontal-chat/style.css | 2 +- multichat-overlay/index.html | 3 +++ multichat-overlay/script.js | 34 +++++++++++++++++++----- multichat-overlay/settings/settings.json | 22 +++++++++++++++ multichat-overlay/style.css | 5 ++-- 7 files changed, 78 insertions(+), 12 deletions(-) diff --git a/horizontal-chat/script.js b/horizontal-chat/script.js index 3614937..8d9218d 100644 --- a/horizontal-chat/script.js +++ b/horizontal-chat/script.js @@ -29,7 +29,7 @@ const fontSize = urlParams.get("fontSize") || "18"; const background = urlParams.get("background") || "#000000"; const opacity = urlParams.get("opacity") || "0.5"; -const hideAfter = GetIntParam("hideAfter") || 0; +const hideAfter = GetIntParam("hideAfter", 0); const excludeCommands = GetBooleanParam("excludeCommands", true); const ignoreChatters = urlParams.get("ignoreChatters") || ""; @@ -38,6 +38,7 @@ const showTwitchAnnouncements = GetBooleanParam("showTwitchAnnouncements", true) const showTwitchSubs = GetBooleanParam("showTwitchSubs", true); const showTwitchChannelPointRedemptions = GetBooleanParam("showTwitchChannelPointRedemptions", true); const showTwitchRaids = GetBooleanParam("showTwitchRaids", true); +const showTwitchSharedChat = GetBooleanParam("showTwitchSharedChat", true); const showYouTubeMessages = GetBooleanParam("showYouTubeMessages", true); const showYouTubeSuperChats = GetBooleanParam("showYouTubeSuperChats", true); @@ -285,6 +286,15 @@ async function TwitchChatMessage(data) { const usernameDiv = instance.querySelector("#username"); const messageDiv = instance.querySelector("#message"); + // Set Shared Chat + // If the message is from Shared Chat AND the user indicated that they do NOT + // want shared chat messages, don't show it on screen + const isSharedChat = data.isSharedChat; + if (isSharedChat && !showTwitchSharedChat) { + if (!data.sharedChat.primarySource) + return; + } + // Set timestamp if (showTimestamps) { timestampDiv.classList.add("timestamp"); @@ -993,12 +1003,12 @@ function GetBooleanParam(paramName, defaultValue) { } } -function GetIntParam(paramName) { +function GetIntParam(paramName, defaultValue) { const urlParams = new URLSearchParams(window.location.search); const paramValue = urlParams.get(paramName); if (paramValue === null) { - return null; // or undefined, or a default value, depending on your needs + return defaultValue; // or undefined, or a default value, depending on your needs } const intValue = parseInt(paramValue, 10); // Parse as base 10 integer diff --git a/horizontal-chat/settings/settings.json b/horizontal-chat/settings/settings.json index 802496b..a730674 100644 --- a/horizontal-chat/settings/settings.json +++ b/horizontal-chat/settings/settings.json @@ -159,6 +159,14 @@ "defaultValue": true, "group": "Which Twitch messages do you want to see?" }, + { + "id": "showTwitchSharedChat", + "label": "Shared Chat Messages", + "description": "", + "type": "checkbox", + "defaultValue": true, + "group": "Which Twitch messages do you want to see?" + }, { "id": "showYouTubeMessages", "label": "Chat Messages", diff --git a/horizontal-chat/style.css b/horizontal-chat/style.css index e92d038..812921d 100644 --- a/horizontal-chat/style.css +++ b/horizontal-chat/style.css @@ -176,7 +176,7 @@ li { font-size: 0.7em; } */ -/* .firstMessageHighlight { +/* .highlightMessage { background: #adadad46; padding: 20px 40px; border-radius: var(--border-radius); diff --git a/multichat-overlay/index.html b/multichat-overlay/index.html index 2195660..75c8c38 100644 --- a/multichat-overlay/index.html +++ b/multichat-overlay/index.html @@ -25,6 +25,9 @@ ✨ First Time Chat from viewer +
+ +