Added YouTube Jewels Gifted events

This commit is contained in:
nutty
2026-09-14 13:29:09 +10:00
parent 7c31fc1b57
commit 216e78df30
6 changed files with 114 additions and 1 deletions
+42 -1
View File
@@ -68,6 +68,7 @@ const showKickGifts = GetBooleanParam("showKickGifts", true);
const showYouTubeMessages = GetBooleanParam("showYouTubeMessages", true);
const showYouTubeSuperChats = GetBooleanParam("showYouTubeSuperChats", true);
const showYouTubeSuperStickers = GetBooleanParam("showYouTubeSuperStickers", true);
const showYouTubeJewelsGifted = GetBooleanParam("showYouTubeJewelsGifted", true);
const showYouTubeSubscribers = GetBooleanParam("showYouTubeSubscribers", false);
const showYouTubeMemberships = GetBooleanParam("showYouTubeMemberships", true);
@@ -272,6 +273,11 @@ client.on('YouTube.SuperSticker', (response) => {
YouTubeSuperSticker(response.data);
})
client.on('YouTube.JewelsGifted', (response) => {
console.debug(response.data);
YouTubeJewelsGifted(response.data);
})
client.on('YouTube.NewSubscriber', (response) => {
console.debug(response.data);
YouTubeNewSubscriber(response.data);
@@ -1668,6 +1674,41 @@ function YouTubeSuperSticker(data) {
AddMessageItem(instance);
}
function YouTubeJewelsGifted(data) {
if (!showYouTubeJewelsGifted)
return;
// Get a reference to the template
const template = document.getElementById('cardTemplate');
// Create a new instance of the template
const instance = template.content.cloneNode(true);
// Get divs
const cardDiv = instance.querySelector("#card");
const headerDiv = instance.querySelector("#header");
const avatarDiv = instance.querySelector("#avatar");
const iconDiv = instance.querySelector("#icon");
const titleDiv = instance.querySelector("#title");
const contentDiv = instance.querySelector("#content");
// Set the card background colors
cardDiv.classList.add('youtube');
avatarDiv.style.width = 'auto';
// Set the text
const user = data.user.name;
const amount = data.jewelsAmount;
const jewelURL = data.url;
const jewelImage = `<img src="${jewelURL}" class="youtube-super-sticker"/>`;
avatarDiv.innerHTML = jewelImage;
titleDiv.innerHTML = `${user} gifted ${amount} Jewels`;
AddMessageItem(instance);
}
function YouTubeNewSubscriber(data) {
if (!showYouTubeSubscribers)
return;
@@ -1694,7 +1735,7 @@ function YouTubeNewSubscriber(data) {
titleDiv.innerText = `${username} subscribed`;
AddMessageItem(instance, JSON.stringify(data));
AddMessageItem(instance);
}
function YouTubeNewSponsor(data) {
+8
View File
@@ -379,6 +379,14 @@
"defaultValue": true,
"group": "Which YouTube messages do you want to see?"
},
{
"id": "showYouTubeJewelsGifted",
"label": "Jewels Gifted",
"description": "",
"type": "checkbox",
"defaultValue": true,
"group": "Which YouTube messages do you want to see?"
},
{
"id": "showYouTubeSubscribers",
"label": "New Subscribers",