Added more Fourthwall alerts (donations, memberships, giveaways)

This commit is contained in:
nuttylmao
2025-03-30 10:03:23 +11:00
parent 4a6d72177d
commit 60f5eb6e0d
2 changed files with 245 additions and 25 deletions
+230 -10
View File
@@ -69,8 +69,7 @@ document.body.style.background = `${background}${hexOpacity}`;
const ignoreUserList = ignoreChatters.split(',').map(item => item.trim().toLowerCase()) || []; const ignoreUserList = ignoreChatters.split(',').map(item => item.trim().toLowerCase()) || [];
// Set the scroll direction // Set the scroll direction
switch (scrollDirection) switch (scrollDirection) {
{
case 1: case 1:
document.getElementById('messageList').classList.add('normalScrollDirection'); document.getElementById('messageList').classList.add('normalScrollDirection');
break; break;
@@ -257,9 +256,9 @@ client.on('Fourthwall.GiftDrawStarted', (response) => {
FourthwallGiftDrawStarted(response.data); FourthwallGiftDrawStarted(response.data);
}) })
client.on('Fourthwall.GiftDrawEnd', (response) => { client.on('Fourthwall.GiftDrawEnded', (response) => {
console.debug(response.data); console.debug(response.data);
FourthwallGiftDrawEnd(response.data); FourthwallGiftDrawEnded(response.data);
}) })
@@ -1393,7 +1392,7 @@ function FourthwallOrderPlaced(data) {
contents += fourthwallProductImage; contents += fourthwallProductImage;
contents += "<br><br>" contents += "<br><br>";
// If there user did not provide a username, just say "Someone" // If there user did not provide a username, just say "Someone"
if (user == undefined) if (user == undefined)
@@ -1408,9 +1407,9 @@ function FourthwallOrderPlaced(data) {
if (orderTotal == 0) if (orderTotal == 0)
contents += ``; contents += ``;
else if (currency == "USD") else if (currency == "USD")
contents = ` ($${orderTotal})`; contents += ` ($${orderTotal})`;
else else
contents = ` (${orderTotal} ${currency})`; contents += ` (${orderTotal} ${currency})`;
titleDiv.innerHTML = contents; titleDiv.innerHTML = contents;
@@ -1427,12 +1426,92 @@ function FourthwallDonation(data) {
if (!showFourthwallAlerts) if (!showFourthwallAlerts)
return; 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('fourthwall');
// Set the text
let user = data.username;
const amount = data.amount;
const currency = data.currency;
const message = data.message;
let contents = "";
// If the user ordered more than one item, write how many items they ordered
contents += `<span style="background: #0042ff; padding: 0px 0.5em">${user}</span> donated`;
// If the user spent money, put the order total
if (currency == "USD")
contents += ` $${amount}`;
else
contents += ` ${currency}${amount}`;
titleDiv.innerHTML = contents;
// Add the custom message from the user
if (message.trim() != "")
contentDiv.innerHTML = `${message}`;
else
contentDiv.style.display = 'none'
AddMessageItem(instance, data.id);
} }
function FourthwallSubscriptionPurchased(data) { function FourthwallSubscriptionPurchased(data) {
if (!showFourthwallAlerts) if (!showFourthwallAlerts)
return; 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('fourthwall');
// Set the text
let user = data.nickname;
const amount = data.amount;
const currency = data.currency;
let contents = "";
// If the user ordered more than one item, write how many items they ordered
contents += `<span style="background: #0042ff; padding: 0px 0.5em">${user}</span> subscribed`;
// If the user spent money, put the order total
if (currency == "USD")
contents += ` ($${amount})`;
else
contents += ` (${currency}${amount})`;
titleDiv.innerHTML = contents;
contentDiv.style.display = 'none'
AddMessageItem(instance, data.id);
} }
function FourthwallGiftPurchase(data) { function FourthwallGiftPurchase(data) {
@@ -1440,18 +1519,143 @@ function FourthwallGiftPurchase(data) {
if (!showFourthwallAlerts) if (!showFourthwallAlerts)
return; 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('blank');
titleDiv.classList.add('centerThatShitHomie');
contentDiv.classList.add('centerThatShitHomie');
// Set the text
let user = data.username;
const total = data.total;
const currency = data.currency;
const gifts = data.gifts.length;
const itemName = data.offer.name;
const itemImageUrl = data.offer.imageUrl;
const fourthwallProductImage = `<img src="${itemImageUrl}" class="productImage"/>`;
const message = DecodeHTMLString(data.statmessageus);
let contents = "";
contents += fourthwallProductImage;
contents += "<br><br>";
// If the user ordered more than one item, write how many items they ordered
contents += `${user} gifted`;
// If there is more than one gifted item, display the number of gifts
if (gifts > 1)
contents += ` ${gifts} x `;
// The name of the item to be given away
contents += ` ${itemName}`;
// If the user spent money, put the order total
if (currency == "USD")
contents += ` ($${total})`;
else
contents += ` (${currency}${total})`;
titleDiv.innerHTML = contents;
// Add the custom message from the user
if (message.trim() != "")
contentDiv.innerHTML = `${message}`;
else
contentDiv.style.display = 'none'
AddMessageItem(instance, data.id);
} }
function FourthwallGiftDrawStarted(data) { function FourthwallGiftDrawStarted(data) {
if (!showFourthwallAlerts) if (!showFourthwallAlerts)
return; 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('fourthwall');
titleDiv.classList.add('centerThatShitHomie');
contentDiv.classList.add('centerThatShitHomie');
// Set the text
let durationSeconds = data.durationSeconds;
const itemName = data.offer.name;
let contents = "";
// If the user ordered more than one item, write how many items they ordered
contents += `<h2>${itemName} Giveaway!</h2>`;
titleDiv.innerHTML = contents;
contentDiv.innerHTML = `Type !join in the next ${durationSeconds} seconds for your chance to win!`;
AddMessageItem(instance, data.id);
} }
function FourthwallGiftDrawEnd(data) { function FourthwallGiftDrawEnded(data) {
if (!showFourthwallAlerts) if (!showFourthwallAlerts)
return; 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('fourthwall');
titleDiv.classList.add('centerThatShitHomie');
contentDiv.classList.add('centerThatShitHomie');
// Set the text
let durationSeconds = data.durationSeconds;
const itemName = data.offer.name;
let contents = "";
// If the user ordered more than one item, write how many items they ordered
contents += `<h2>GIVEAWAY ENDED</h2>`;
contents += `Congratulations ${GetWinnersList(data.gifts)}!`
titleDiv.innerHTML = contents;
contentDiv.innerHTML = `Click the link to redeem your ${itemName}!`;
AddMessageItem(instance, data.id);
} }
@@ -1587,8 +1791,7 @@ function AddMessageItem(element, elementID, platform, userId) {
tempDiv.innerHTML = ''; tempDiv.innerHTML = '';
if (hideAfter > 0) if (hideAfter > 0) {
{
setTimeout(function () { setTimeout(function () {
lineItem.style.opacity = 0; lineItem.style.opacity = 0;
setTimeout(function () { setTimeout(function () {
@@ -1672,6 +1875,23 @@ function GetPermissionLevel(data, platform) {
} }
} }
function GetWinnersList(gifts) {
const winners = gifts.map(gift => gift.winner);
const numWinners = winners.length;
if (numWinners === 0) {
return "";
} else if (numWinners === 1) {
return winners[0];
} else if (numWinners === 2) {
return `${winners[0]} and ${winners[1]}`;
} else {
const lastWinner = winners.pop();
const secondLastWinner = winners.pop();
return `${winners.join(", ")}, ${secondLastWinner} and ${lastWinner}`;
}
}
/////////////////////////////////// ///////////////////////////////////
+4 -4
View File
@@ -220,19 +220,19 @@ li {
} }
.patreon { .patreon {
background: linear-gradient(#c76633, #fd5e0a) !important; background: linear-gradient(#c76633bf, #fd5e0abf) !important;
} }
.kofi { .kofi {
background: linear-gradient(#54c7ee, #08c2ff) !important; background: linear-gradient(#54c7eebf, #08c2ffbf) !important;
} }
.tipeeeStream { .tipeeeStream {
background: linear-gradient(#120e23, #5d192a) !important; background: linear-gradient(#120e23bf, #5d192abf) !important;
} }
.fourthwall { .fourthwall {
background: linear-gradient(#405eb3, #0d3cb9) !important; background: linear-gradient(#181712bf, #10110dbf) !important;
} }
.blank { .blank {