mirror of
https://github.com/nuttylmao/nutty.gg.git
synced 2026-09-18 19:50:58 -04:00
Added basic support for Twitch Custom Power Ups
This commit is contained in:
@@ -189,6 +189,54 @@ async function CustomEvent(data) {
|
|||||||
SetPlatformIcon(iconEl, 'twitch');
|
SetPlatformIcon(iconEl, 'twitch');
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case ('TwitchCustomPowerUpRedemption'):
|
||||||
|
{
|
||||||
|
avatarEl.src = await GetAvatar(data.userName, 'twitch');
|
||||||
|
titleEl.innerText = `${data["customPowerUp.bitsCost"]} BITS`;
|
||||||
|
subtitleEl.innerText = `${data.user}`;
|
||||||
|
|
||||||
|
const messageEl = document.createElement('div');
|
||||||
|
messageEl.innerHTML = data.rawInput;
|
||||||
|
|
||||||
|
// // Render emotes
|
||||||
|
// for (i in data.emotes) {
|
||||||
|
// const emoteElement = `<img src="${data.emotes[i].imageUrl}" class="emote"/>`;
|
||||||
|
// const emoteName = EscapeRegExp(data.emotes[i].name);
|
||||||
|
// function EscapeRegExp(string) {
|
||||||
|
// return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
|
||||||
|
// }
|
||||||
|
|
||||||
|
// let regexPattern = emoteName;
|
||||||
|
|
||||||
|
// // Check if the emote name consists only of word characters (alphanumeric and underscore)
|
||||||
|
// if (/^\w+$/.test(emoteName)) {
|
||||||
|
// regexPattern = `\\b${emoteName}\\b`;
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// // For non-word emotes, ensure they are surrounded by non-word characters or boundaries
|
||||||
|
// regexPattern = `(?<=^|[^\\w])${emoteName}(?=$|[^\\w])`;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// const regex = new RegExp(regexPattern, 'g');
|
||||||
|
// messageEl.innerHTML = messageEl.innerHTML.replace(regex, emoteElement);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // Render cheermotes
|
||||||
|
// for (i in data.cheerEmotes) {
|
||||||
|
// const bits = data.cheerEmotes[i].bits;
|
||||||
|
// const imageUrl = data.cheerEmotes[i].imageUrl;
|
||||||
|
// const name = data.cheerEmotes[i].name;
|
||||||
|
// const cheerEmoteElement = `<img src="${imageUrl}" class="emote"/>`;
|
||||||
|
// const bitsElements = `<span class="bits">${bits}</span>`
|
||||||
|
// messageEl.innerHTML = messageEl.innerHTML.replace(new RegExp(`\\b${name}${bits}\\b`, 'i'), cheerEmoteElement + bitsElements);
|
||||||
|
// }
|
||||||
|
|
||||||
|
contentEl.appendChild(messageEl);
|
||||||
|
|
||||||
|
// Set the platform icon
|
||||||
|
SetPlatformIcon(iconEl, 'twitch');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
// YouTube Events
|
// YouTube Events
|
||||||
case ('YouTubeNewSponsor'):
|
case ('YouTubeNewSponsor'):
|
||||||
|
|||||||
Reference in New Issue
Block a user