mirror of
https://github.com/nuttylmao/nutty.gg.git
synced 2026-09-19 04:00:59 -04:00
Added a global action + minor animation changes
This commit is contained in:
@@ -44,6 +44,7 @@ const hideAfter = GetIntParam("hideAfter", 8);
|
||||
const showAnimation = urlParams.get("showAnimation") || "";
|
||||
const hideAnimation = urlParams.get("hideAnimation") || "";
|
||||
const playSounds = GetBooleanParam("playSounds", true);
|
||||
const globalAction = urlParams.get("globalAction") || "";
|
||||
const showMesesages = GetBooleanParam("showMesesages", true);
|
||||
|
||||
// Which Twitch alerts do you want to see?
|
||||
@@ -84,6 +85,7 @@ const fourthwallAlertAction = urlParams.get("fourthwallAlertAction") || "";
|
||||
if (!showAvatar) {
|
||||
avatarElement.style.display = 'none';
|
||||
avatarSmallElement.style.display = 'none';
|
||||
alertBox.style.padding = '0.5em 1em';
|
||||
}
|
||||
|
||||
// Set fonts for the widget
|
||||
@@ -1187,7 +1189,7 @@ function GetWinnersList(gifts) {
|
||||
}
|
||||
}
|
||||
|
||||
async function UpdateAlertBox(platform, avatarURL, headerText, descriptionText, attributeText, username, message, sbAction, sbData) {
|
||||
function UpdateAlertBox(platform, avatarURL, headerText, descriptionText, attributeText, username, message, sbAction, sbData) {
|
||||
// Check if the widget is in the middle of an animation
|
||||
// If any alerts are requested while the animation is playing, it should be added to the alert queue
|
||||
if (widgetLocked) {
|
||||
@@ -1227,18 +1229,24 @@ async function UpdateAlertBox(platform, avatarURL, headerText, descriptionText,
|
||||
alertBox.style.height = theContentThatShowsFirstInsteadOfSecond.offsetHeight + "px";
|
||||
alertBox.style.animation = `${showAnimation} 0.5s ease-out forwards`;
|
||||
|
||||
// Run the Streamer.bot action if there is one
|
||||
if (sbAction) {
|
||||
console.debug('Running Streamer.bot action: ' + sbAction);
|
||||
await client.doAction({name: sbAction}, sbData);
|
||||
}
|
||||
|
||||
// Play sound effect
|
||||
if (playSounds) {
|
||||
const audio = new Audio('sfx/notification.mp3');
|
||||
audio.play();
|
||||
}
|
||||
|
||||
// Run the Streamer.bot action if there is one
|
||||
if (globalAction) {
|
||||
console.debug('Running Streamer.bot action: ' + globalAction);
|
||||
client.doAction({name: globalAction}, sbData);
|
||||
}
|
||||
|
||||
// Run the Streamer.bot action if there is one
|
||||
if (sbAction) {
|
||||
console.debug('Running Streamer.bot action: ' + sbAction);
|
||||
client.doAction({name: sbAction}, sbData);
|
||||
}
|
||||
|
||||
// (1) Set timeout (8 seconds by default)
|
||||
// (2) Set the message label
|
||||
// (3) Calculate the height of message label
|
||||
@@ -1248,6 +1256,8 @@ async function UpdateAlertBox(platform, avatarURL, headerText, descriptionText,
|
||||
alertBox.style.transition = 'all 0.5s ease-in-out';
|
||||
theContentThatShowsFirstInsteadOfSecond.style.opacity = 0;
|
||||
|
||||
if (message && showMesesages) {
|
||||
|
||||
theContentThatShowsLastInsteadOfFirst.style.display = 'inline-block';
|
||||
alertBox.style.height = theContentThatShowsLastInsteadOfFirst.offsetHeight + "px";
|
||||
theContentThatShowsLastInsteadOfFirst.style.opacity = 1;
|
||||
@@ -1256,7 +1266,6 @@ async function UpdateAlertBox(platform, avatarURL, headerText, descriptionText,
|
||||
alertBox.style.animation = `${hideAnimation} 0.5s ease-out forwards`;
|
||||
|
||||
setTimeout(() => {
|
||||
//alertBox.style.maxHeight = '0px';
|
||||
alertBox.style.height = '0px';
|
||||
theContentThatShowsFirstInsteadOfSecond.style.opacity = 1;
|
||||
theContentThatShowsLastInsteadOfFirst.style.opacity = 0;
|
||||
@@ -1268,7 +1277,25 @@ async function UpdateAlertBox(platform, avatarURL, headerText, descriptionText,
|
||||
UpdateAlertBox(data.platform, data.avatarURL, data.headerText, data.descriptionText, data.attributeText, data.username, data.message, data.sbAction, data.sbData);
|
||||
}
|
||||
}, 1000);
|
||||
}, (message && showMesesages) ? hideAfter * 1000 : 0);
|
||||
}, hideAfter * 1000);
|
||||
} else {
|
||||
alertBox.style.animation = `${hideAnimation} 0.5s ease-out forwards`;
|
||||
|
||||
setTimeout(() => {
|
||||
alertBox.style.height = '0px';
|
||||
|
||||
theContentThatShowsFirstInsteadOfSecond.style.opacity = 1;
|
||||
theContentThatShowsLastInsteadOfFirst.style.opacity = 0;
|
||||
theContentThatShowsLastInsteadOfFirst.style.display = 'none';
|
||||
widgetLocked = false;
|
||||
if (alertQueue.length > 0) {
|
||||
console.debug("Pulling next alert from the queue");
|
||||
let data = alertQueue.shift();
|
||||
UpdateAlertBox(data.platform, data.avatarURL, data.headerText, data.descriptionText, data.attributeText, data.username, data.message, data.sbAction, data.sbData);
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
}, hideAfter * 1000);
|
||||
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
"type": "number",
|
||||
"min": 1,
|
||||
"max": 120,
|
||||
"defaultValue": 30,
|
||||
"defaultValue": 20,
|
||||
"group": "Appearance"
|
||||
},
|
||||
{
|
||||
@@ -203,6 +203,14 @@
|
||||
"defaultValue": true,
|
||||
"group": "General"
|
||||
},
|
||||
{
|
||||
"id": "globalAction",
|
||||
"label": "Streamer.bot Action",
|
||||
"description": "Run this Streamer.bot Action on every alert",
|
||||
"type": "sb-actions",
|
||||
"defaultValue": "",
|
||||
"group": "General"
|
||||
},
|
||||
{
|
||||
"id": "showMesesages",
|
||||
"label": "Show Messages",
|
||||
|
||||
Reference in New Issue
Block a user