diff --git a/chat.html b/chat.html index b481ea0..e1cec97 100644 --- a/chat.html +++ b/chat.html @@ -45,10 +45,11 @@ - -
-
- +
+
+
+ +
diff --git a/css/app.css b/css/app.css index f2ea802..e2e74b1 100644 --- a/css/app.css +++ b/css/app.css @@ -20,22 +20,44 @@ html { body { + height: 100%; overflow: hidden; } -.wrapper { - position: absolute; - width: 100%; + +#container { height: 100%; + display: flex; + flex-direction: column; +} +.wrapper { + flex: 1; + display: flex; + flex-direction: column; + overflow: hidden; +} +#chat { + flex: 1; + display: flex; + flex-direction: column-reverse; /* conteúdo começa no fundo */ + overflow-y: auto; + padding: 10px; + scrollbar-color: #555 #1e1e1e; } -#chat { - position: absolute; - width: 100%; - bottom: 0px; - padding: 10px; +#chat.noscrollbar { + overflow-y: hidden; } +#chat::-webkit-scrollbar { width: 8px; } +#chat::-webkit-scrollbar-track { background: #1e1e1e; } +#chat::-webkit-scrollbar-thumb { background-color: #555; border-radius: 4px; border: 2px solid #1e1e1e; } +#chat::-webkit-scrollbar-thumb:hover { background-color: #777; } + + + + + #chat .message { color: #FFF; font-size: 18px; @@ -134,7 +156,7 @@ body { display: block; text-shadow: none; font-size: 14px; - margin: 2px 0 -5px 0; + margin: 10px 0 -5px 0; color: #999; } @@ -163,7 +185,9 @@ body { align-items: flex-start; } - +#chat .message:not(.event) > div { + margin-top: -10px; +} #chat .message.twitch .shared span { diff --git a/index.html b/index.html index 1c77766..d6bfde8 100644 --- a/index.html +++ b/index.html @@ -63,6 +63,8 @@
+
+
`); - chatContainer.insertAdjacentHTML('beforeend', html); + chatContainer.insertAdjacentHTML('afterbegin', html); const messageElement = document.getElementById(messageID); @@ -148,7 +150,7 @@ async function addEventToChat(userID, messageID, platform, data) {
`); - chatContainer.insertAdjacentHTML('beforeend', html); + chatContainer.insertAdjacentHTML('afterbegin', html); const messageElement = document.getElementById(messageID); @@ -178,15 +180,20 @@ const whatTimeIsIt = () => { function removeExtraChatMessages() { - const chatMessages = chatContainer.querySelectorAll('div.message').length; - if (chatMessages >= chatThreshhold) { - for (let i = 0; i < Math.floor(chatThreshhold/2); i++) { - chatContainer.removeChild(chatContainer.firstElementChild); + const chatMessages = chatContainer.querySelectorAll('div.message'); + const total = chatMessages.length; + + if (total >= chatThreshhold) { + const toRemove = Math.floor(total * 0.25); // 25% do total + for (let i = 0; i < toRemove; i++) { + const last = chatContainer.lastElementChild; + if (last) chatContainer.removeChild(last); } } } + // Function to format large numbers (e.g., 1000 => '1K') function formatNumber(num) { if (num >= 1000000) { diff --git a/js/tiktok/module.js b/js/tiktok/module.js index 6481ea5..4a61f8f 100644 --- a/js/tiktok/module.js +++ b/js/tiktok/module.js @@ -148,7 +148,6 @@ async function tiktokLikesMessage(data) { if (showTikTokLikes == false) return; - const { userId: userID, msgId: messageID, @@ -281,4 +280,4 @@ async function tiktokUpdateStatistics(data, type) { } -} +} \ No newline at end of file diff --git a/js/twitch/module.js b/js/twitch/module.js index 21a946f..6c0cee8 100644 --- a/js/twitch/module.js +++ b/js/twitch/module.js @@ -263,7 +263,7 @@ async function twitchAnnouncementMessage(data) { data.message = { - message: await getTwitchAnnouncementEmotes(data) + message: await getTwitchEmotesOnParts(data) }; @@ -366,6 +366,7 @@ async function twitchReSubMessage(data) { } = data; const messageID = createRandomString(40); + const messagetext = await getTwitchEmotesOnParts(data); const [avatar, message] = await Promise.all([ '', @@ -373,7 +374,7 @@ async function twitchReSubMessage(data) { months : data.cumulativeMonths, isPrime : data.isPrime, tier : data.subTier, - message : text + message : messagetext }) ]); @@ -452,7 +453,11 @@ async function twitchGiftSubsMessage(data) { const [avatar, message] = await Promise.all([ '', - currentLang.twitch.giftedbomb({ count : data.total, tier : data.sub_tier, total : data.cumulative_total }) + currentLang.twitch.giftedbomb({ + count : data.total, + tier : data.sub_tier, + total : data.cumulative_total + }) ]); const classes = 'sub'; @@ -542,7 +547,7 @@ async function getTwitchEmotes(data) { } -async function getTwitchAnnouncementEmotes(data) { +/*async function getTwitchAnnouncementEmotes(data) { const message = data.text; const emotes = data.parts; const words = message.split(" "); @@ -555,8 +560,23 @@ async function getTwitchAnnouncementEmotes(data) { }); } return words.join(" "); -} +}*/ +async function getTwitchEmotesOnParts(data) { + const parts = data?.parts; + + if (!Array.isArray(parts)) { + return data.text; + } + + return parts.map(part => { + if (part.type === 'text') { + return part.text; + } else if (part.type === 'emote') { + return `${part.text}`; + } + }).join(''); +} async function getTwitchBadges(data) { const badges = data.message.badges; diff --git a/js/youtube/module.js b/js/youtube/module.js index d0b6d18..932d988 100644 --- a/js/youtube/module.js +++ b/js/youtube/module.js @@ -140,12 +140,13 @@ async function youTubeSuperChatMessage(data) { } = data; var money = amount; + var messagewithemotes = await getYouTubeEmotes(textmessage); const [avatar, message] = await Promise.all([ ``, currentLang.youtube.superchat({ money : money, - message : textmessage + message : messagewithemotes }) ]); @@ -223,12 +224,14 @@ async function youTubeNewSponsorMessage(data) { message: messagetext, } = data; + var messagewithemotes = await getYouTubeEmotes(messagetext); + const [avatar, message] = await Promise.all([ ``, currentLang.youtube.member({ months : months, tier : levelName, - message: messagetext + message: messagewithemotes }) ]); @@ -357,7 +360,7 @@ async function getYouTubeEmotes(data) { emoteMap.set(emote.code, { html: emoteElement, raw: emote.code }); } - // YouTube emotes (ex: :vortisLaugh:) + // YouTube emotes (ex: :hand-pink-waving:) if (data.emotes) { for (const emote of data.emotes) { const emoteElement = `${emote.name}`;