mirror of
https://github.com/nuttylmao/nutty.gg.git
synced 2026-09-18 19:50:58 -04:00
Merge branch 'beta' into revert-13-revert-11-main
This commit is contained in:
@@ -12,7 +12,7 @@
|
|||||||
<body>
|
<body>
|
||||||
<!-- Header -->
|
<!-- Header -->
|
||||||
<div id="header">
|
<div id="header">
|
||||||
<img src="../../.resources/logo.png" style="height: 40px;" />
|
<img src="../../resources/logo.png" style="height: 40px;" />
|
||||||
<button id="membershipsButton" onclick="OpenMembershipPage()">Check out my member exclusive widgets!</button>
|
<button id="membershipsButton" onclick="OpenMembershipPage()">Check out my member exclusive widgets!</button>
|
||||||
<div id="widgetUrlInputWrapper">
|
<div id="widgetUrlInputWrapper">
|
||||||
<span id="urlLabel">Click to copy URL</span>
|
<span id="urlLabel">Click to copy URL</span>
|
||||||
@@ -64,4 +64,5 @@
|
|||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
<script src="../../../.common/utils/helpers.js"></script>
|
||||||
<script src="script.js"></script>
|
<script src="script.js"></script>
|
||||||
@@ -460,45 +460,6 @@ function OpenLoadSettingsPopup() {
|
|||||||
// HELPER FUNCTIONS //
|
// HELPER FUNCTIONS //
|
||||||
//////////////////////
|
//////////////////////
|
||||||
|
|
||||||
function GetBooleanParam(paramName, defaultValue) {
|
|
||||||
const urlParams = new URLSearchParams(window.location.search);
|
|
||||||
const paramValue = urlParams.get(paramName);
|
|
||||||
|
|
||||||
if (paramValue === null) {
|
|
||||||
return defaultValue; // Parameter not found
|
|
||||||
}
|
|
||||||
|
|
||||||
const lowercaseValue = paramValue.toLowerCase(); // Handle case-insensitivity
|
|
||||||
|
|
||||||
if (lowercaseValue === 'true') {
|
|
||||||
return true;
|
|
||||||
} else if (lowercaseValue === 'false') {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return paramValue; // Return original string if not 'true' or 'false'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function GetIntParam(paramName, defaultValue) {
|
|
||||||
const urlParams = new URLSearchParams(window.location.search);
|
|
||||||
const paramValue = urlParams.get(paramName);
|
|
||||||
|
|
||||||
if (paramValue === null) {
|
|
||||||
return defaultValue; // or undefined, or a default value, depending on your needs
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(paramValue);
|
|
||||||
|
|
||||||
const intValue = parseInt(paramValue, 10); // Parse as base 10 integer
|
|
||||||
|
|
||||||
if (isNaN(intValue)) {
|
|
||||||
return null; // or handle the error in another way, e.g., throw an error
|
|
||||||
}
|
|
||||||
|
|
||||||
return intValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Handle first window interaction
|
// Handle first window interaction
|
||||||
window.addEventListener('message', (event) => {
|
window.addEventListener('message', (event) => {
|
||||||
if (event.origin === new URL(widgetPreview.src).origin && event.data === 'iframe-interacted') {
|
if (event.origin === new URL(widgetPreview.src).origin && event.data === 'iframe-interacted') {
|
||||||
@@ -0,0 +1,222 @@
|
|||||||
|
//////////////////////
|
||||||
|
// GLOBAL VARIABLES //
|
||||||
|
//////////////////////
|
||||||
|
|
||||||
|
const avatarMap = new Map();
|
||||||
|
const pronounMap = new Map();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////
|
||||||
|
// HELPER FUNCTIONS //
|
||||||
|
//////////////////////
|
||||||
|
|
||||||
|
function GetBooleanParam(paramName, defaultValue) {
|
||||||
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
|
const paramValue = urlParams.get(paramName);
|
||||||
|
|
||||||
|
if (paramValue === null) {
|
||||||
|
return defaultValue; // Parameter not found
|
||||||
|
}
|
||||||
|
|
||||||
|
const lowercaseValue = paramValue.toLowerCase(); // Handle case-insensitivity
|
||||||
|
|
||||||
|
if (lowercaseValue === 'true') {
|
||||||
|
return true;
|
||||||
|
} else if (lowercaseValue === 'false') {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return paramValue; // Return original string if not 'true' or 'false'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function GetIntParam(paramName, defaultValue) {
|
||||||
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
|
const paramValue = urlParams.get(paramName);
|
||||||
|
|
||||||
|
if (paramValue === null) {
|
||||||
|
return defaultValue; // or undefined, or a default value, depending on your needs
|
||||||
|
}
|
||||||
|
|
||||||
|
const intValue = parseInt(paramValue, 10); // Parse as base 10 integer
|
||||||
|
|
||||||
|
if (isNaN(intValue)) {
|
||||||
|
return null; // or handle the error in another way, e.g., throw an error
|
||||||
|
}
|
||||||
|
|
||||||
|
return intValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function GetKickIds(username) {
|
||||||
|
// First attempt with the original username
|
||||||
|
let url = `https://kick.com/api/v2/channels/${username}`;
|
||||||
|
|
||||||
|
try {
|
||||||
|
let response = await fetch(url);
|
||||||
|
if (!response.ok) {
|
||||||
|
// Retry with underscores replaced by dashes
|
||||||
|
const altUsername = username.replace(/_/g, "-");
|
||||||
|
url = `https://kick.com/api/v2/channels/${altUsername}`;
|
||||||
|
response = await fetch(url);
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(`HTTP error ${response.status}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = await response.json();
|
||||||
|
if (data.chatroom && data.chatroom.id) {
|
||||||
|
return { chatroomId: data.chatroom.id, channelId: data.chatroom.channel_id };
|
||||||
|
} else {
|
||||||
|
throw new Error("Chatroom ID not found in response.");
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Failed to fetch chatroom ID:", error.message);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function GetKickSubBadges(username) {
|
||||||
|
let url = `https://kick.com/api/v2/channels/${username}`;
|
||||||
|
|
||||||
|
try {
|
||||||
|
let response = await fetch(url);
|
||||||
|
if (!response.ok) {
|
||||||
|
// Retry with underscores replaced by dashes
|
||||||
|
const altUsername = username.replace(/_/g, "-");
|
||||||
|
url = `https://kick.com/api/v2/channels/${altUsername}`;
|
||||||
|
response = await fetch(url);
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(`HTTP error ${response.status}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = await response.json();
|
||||||
|
return data.subscriber_badges || [];
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Failed to fetch subscriber badges:", error.message);
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function GetAvatar(username, platform) {
|
||||||
|
// First, check if the username is hashed already
|
||||||
|
if (avatarMap.has(`${username}-${platform}`)) {
|
||||||
|
console.debug(`Avatar found for ${username} (${platform}). Retrieving from hash map.`);
|
||||||
|
return avatarMap.get(`${username}-${platform}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If code reaches this point, the username hasn't been hashed, so retrieve avatar
|
||||||
|
switch (platform) {
|
||||||
|
case 'twitch': {
|
||||||
|
console.debug(`No avatar found for ${username} (${platform}). Retrieving from Decapi.`);
|
||||||
|
let response = await fetch('https://decapi.me/twitch/avatar/' + username);
|
||||||
|
let data = await response.text();
|
||||||
|
avatarMap.set(`${username}-${platform}`, data);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
case 'kick': {
|
||||||
|
console.debug(`No avatar found for ${username} (${platform}). Retrieving from Kick.`);
|
||||||
|
|
||||||
|
let url = `https://kick.com/api/v2/channels/${username}`;
|
||||||
|
try {
|
||||||
|
let response = await fetch(url);
|
||||||
|
if (!response.ok) {
|
||||||
|
// Retry with underscores replaced by dashes
|
||||||
|
const altUsername = username.replace(/_/g, "-");
|
||||||
|
url = `https://kick.com/api/v2/channels/${altUsername}`;
|
||||||
|
response = await fetch(url);
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(`HTTP error ${response.status}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let data = await response.json();
|
||||||
|
let avatarURL = data.user?.profile_pic || 'https://kick.com/img/default-profile-pictures/default2.jpeg';
|
||||||
|
avatarMap.set(`${username}-${platform}`, avatarURL);
|
||||||
|
return avatarURL;
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Failed to fetch avatar:", error.message);
|
||||||
|
return 'https://kick.com/img/default-profile-pictures/default2.jpeg';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function GetPronouns(platform, username) {
|
||||||
|
if (pronounMap.has(username)) {
|
||||||
|
console.debug(`Pronouns found for ${username}. Retrieving from hash map.`)
|
||||||
|
return pronounMap.get(username);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
console.debug(`No pronouns found for ${username}. Retrieving from alejo.io.`)
|
||||||
|
const response = await client.getUserPronouns(platform, username);
|
||||||
|
const userFound = response.pronoun.userFound;
|
||||||
|
const pronouns = userFound ? `${response.pronoun.pronounSubject}/${response.pronoun.pronounObject}` : '';
|
||||||
|
|
||||||
|
pronounMap.set(username, pronouns);
|
||||||
|
|
||||||
|
return pronouns;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function GetCurrentTimeFormatted() {
|
||||||
|
const now = new Date();
|
||||||
|
let hours = now.getHours();
|
||||||
|
const minutes = String(now.getMinutes()).padStart(2, '0');
|
||||||
|
const ampm = hours >= 12 ? 'PM' : 'AM';
|
||||||
|
|
||||||
|
hours = hours % 12;
|
||||||
|
hours = hours ? hours : 12; // the hour '0' should be '12'
|
||||||
|
|
||||||
|
const formattedTime = `${hours}:${minutes} ${ampm}`;
|
||||||
|
return formattedTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
function DecodeHTMLString(html) {
|
||||||
|
var txt = document.createElement("textarea");
|
||||||
|
txt.innerHTML = html;
|
||||||
|
return txt.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
function TranslateToFurry(sentence) {
|
||||||
|
const words = sentence.toLowerCase().split(/\b/);
|
||||||
|
|
||||||
|
const furryWords = words.map(word => {
|
||||||
|
if (/\w+/.test(word)) {
|
||||||
|
let newWord = word;
|
||||||
|
|
||||||
|
// Common substitutions
|
||||||
|
newWord = newWord.replace(/l/g, 'w');
|
||||||
|
newWord = newWord.replace(/r/g, 'w');
|
||||||
|
newWord = newWord.replace(/th/g, 'f');
|
||||||
|
newWord = newWord.replace(/you/g, 'yous');
|
||||||
|
newWord = newWord.replace(/my/g, 'mah');
|
||||||
|
newWord = newWord.replace(/me/g, 'meh');
|
||||||
|
newWord = newWord.replace(/am/g, 'am');
|
||||||
|
newWord = newWord.replace(/is/g, 'is');
|
||||||
|
newWord = newWord.replace(/are/g, 'are');
|
||||||
|
newWord = newWord.replace(/very/g, 'vewy');
|
||||||
|
newWord = newWord.replace(/pretty/g, 'pwetty');
|
||||||
|
newWord = newWord.replace(/little/g, 'wittle');
|
||||||
|
newWord = newWord.replace(/nice/g, 'nyce');
|
||||||
|
|
||||||
|
// Random additions
|
||||||
|
if (Math.random() < 0.15) {
|
||||||
|
newWord += ' nya~';
|
||||||
|
} else if (Math.random() < 0.1) {
|
||||||
|
newWord += ' >w<';
|
||||||
|
} else if (Math.random() < 0.05) {
|
||||||
|
newWord += ' owo';
|
||||||
|
}
|
||||||
|
|
||||||
|
return newWord;
|
||||||
|
}
|
||||||
|
return word;
|
||||||
|
});
|
||||||
|
|
||||||
|
return furryWords.join('');
|
||||||
|
}
|
||||||
|
|
||||||
|
function EscapeRegExp(string) {
|
||||||
|
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
|
||||||
|
}
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 207 KiB |
@@ -2,7 +2,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<link rel="stylesheet" href="../.common/styles/global.css" />
|
<link rel="stylesheet" href="../.common/styles/global.css" />
|
||||||
<link rel="icon" href="../../.resources/logo.png" type="image/png">
|
<link rel="icon" href="../../.common/resources/logo.png" type="image/png">
|
||||||
<title>nutty</title>
|
<title>nutty</title>
|
||||||
<style>
|
<style>
|
||||||
#dock-wrapper {
|
#dock-wrapper {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<link rel="icon" href="../../.resources/logo.png" type="image/png">
|
<link rel="icon" href="../../.common/resources/logo.png" type="image/png">
|
||||||
<title>nutty</title>
|
<title>nutty</title>
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
const widgetContainer = document.getElementById('widgetContainer');
|
const widgetContainer = document.getElementById('widgetContainer');
|
||||||
|
|
||||||
const settingsPageURL = '../../.utilities/settings-page-builder';
|
const settingsPageURL = '../../.common/core/settings-core';
|
||||||
|
|
||||||
const currentURL = window.location.href;
|
const currentURL = window.location.href;
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 5.3 KiB |
@@ -38,4 +38,5 @@
|
|||||||
</template>
|
</template>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
<script src="../.common/utils/helpers.js"></script>
|
||||||
<script src="./script.js"></script>
|
<script src="./script.js"></script>
|
||||||
+21
-177
@@ -8,8 +8,6 @@ const urlParams = new URLSearchParams(queryString);
|
|||||||
const sbServerAddress = urlParams.get("address") || "127.0.0.1";
|
const sbServerAddress = urlParams.get("address") || "127.0.0.1";
|
||||||
const sbServerPort = urlParams.get("port") || "8080";
|
const sbServerPort = urlParams.get("port") || "8080";
|
||||||
const minimumRole = 2; // 1 - Viewer, 2 - VIP, 3 - Moderator, 4 - Broadcaster
|
const minimumRole = 2; // 1 - Viewer, 2 - VIP, 3 - Moderator, 4 - Broadcaster
|
||||||
const avatarMap = new Map();
|
|
||||||
const pronounMap = new Map();
|
|
||||||
const animationDuration = 8000;
|
const animationDuration = 8000;
|
||||||
let widgetLocked = false; // Needed to lock animation from overlapping
|
let widgetLocked = false; // Needed to lock animation from overlapping
|
||||||
let alertQueue = [];
|
let alertQueue = [];
|
||||||
@@ -52,12 +50,13 @@ const showTwitchChannelPointRedemptions = GetBooleanParam("showTwitchChannelPoin
|
|||||||
const showTwitchRaids = GetBooleanParam("showTwitchRaids", true);
|
const showTwitchRaids = GetBooleanParam("showTwitchRaids", true);
|
||||||
const showTwitchSharedChat = GetBooleanParam("showTwitchSharedChat", true);
|
const showTwitchSharedChat = GetBooleanParam("showTwitchSharedChat", true);
|
||||||
|
|
||||||
let kickUsername = urlParams.get("kickUsername") || "";
|
const kickUsername = urlParams.get("kickUsername") || "";
|
||||||
const showKickMessages = GetBooleanParam("showKickMessages", true);
|
const showKickMessages = GetBooleanParam("showKickMessages", true);
|
||||||
// const showKickFollows = GetBooleanParam("showKickFollows", false);
|
// const showKickFollows = GetBooleanParam("showKickFollows", false);
|
||||||
const showKickSubs = GetBooleanParam("showKickSubs", true);
|
const showKickSubs = GetBooleanParam("showKickSubs", true);
|
||||||
const showKickChannelPointRedemptions = GetBooleanParam("showKickChannelPointRedemptions", true);
|
const showKickChannelPointRedemptions = GetBooleanParam("showKickChannelPointRedemptions", true);
|
||||||
const showKickHosts = GetBooleanParam("showKickHosts", true);
|
const showKickHosts = GetBooleanParam("showKickHosts", true);
|
||||||
|
const showKickGifts = GetBooleanParam("showKickGifts", true);
|
||||||
|
|
||||||
const showYouTubeMessages = GetBooleanParam("showYouTubeMessages", true);
|
const showYouTubeMessages = GetBooleanParam("showYouTubeMessages", true);
|
||||||
const showYouTubeSuperChats = GetBooleanParam("showYouTubeSuperChats", true);
|
const showYouTubeSuperChats = GetBooleanParam("showYouTubeSuperChats", true);
|
||||||
@@ -81,9 +80,6 @@ const furryMode = GetBooleanParam("furryMode", false);
|
|||||||
|
|
||||||
const animationSpeed = GetIntParam("animationSpeed", 0.5);
|
const animationSpeed = GetIntParam("animationSpeed", 0.5);
|
||||||
|
|
||||||
// Kick is stupid and turns underscores into dashes which fuck everything up, therefore do a find/replace to make it work good
|
|
||||||
kickUsername = kickUsername.replace(/_/g, "-");
|
|
||||||
|
|
||||||
// Set fonts for the widget
|
// Set fonts for the widget
|
||||||
document.body.style.fontFamily = font;
|
document.body.style.fontFamily = font;
|
||||||
document.body.style.fontSize = `${fontSize}px`;
|
document.body.style.fontSize = `${fontSize}px`;
|
||||||
@@ -301,7 +297,9 @@ async function KickConnect() {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Channel to subscribe to (you'll need the correct channel name here)
|
// Channel to subscribe to (you'll need the correct channel name here)
|
||||||
const chatroomId = await GetKickChatroomId(kickUsername);
|
const kickIds = await GetKickIds(kickUsername);
|
||||||
|
const chatroomId = kickIds.chatroomId;
|
||||||
|
const channelId = kickIds.channelId;
|
||||||
|
|
||||||
// Cache subscriber badges
|
// Cache subscriber badges
|
||||||
kickSubBadges = await GetKickSubBadges(kickUsername);
|
kickSubBadges = await GetKickSubBadges(kickUsername);
|
||||||
@@ -334,6 +332,7 @@ async function KickConnect() {
|
|||||||
websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `chatrooms.${chatroomId}` } }));
|
websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `chatrooms.${chatroomId}` } }));
|
||||||
websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `chatrooms.${chatroomId}.v2` } }));
|
websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `chatrooms.${chatroomId}.v2` } }));
|
||||||
websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `predictions-channel-${chatroomId}` } }));
|
websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `predictions-channel-${chatroomId}` } }));
|
||||||
|
websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `channel_${channelId}` } }));
|
||||||
console.log(`[Pusher] Sent subscription request to channel: ${chatroomId}`);
|
console.log(`[Pusher] Sent subscription request to channel: ${chatroomId}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -365,6 +364,9 @@ async function KickConnect() {
|
|||||||
case 'UserBannedEvent':
|
case 'UserBannedEvent':
|
||||||
KickUserBanned(eventArgs);
|
KickUserBanned(eventArgs);
|
||||||
break;
|
break;
|
||||||
|
case 'KicksGifted':
|
||||||
|
KickKicksGifted(eventArgs);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
@@ -1425,6 +1427,18 @@ function KickUserBanned(data) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function KickKicksGifted(data) {
|
||||||
|
if (!showKickGifts)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const kicksImg = `<img src=icons/badges/kick-kicks.svg class="platform"/>`;
|
||||||
|
const giftImg = `<img src=https://files.kick.com/kicks/gifts/${data.gift.gift_id.replace('_', '-')}.webp class="platform"/>`;
|
||||||
|
|
||||||
|
const message = ` ${giftImg} ${data.sender.username} sent ${data.gift.name} ${kicksImg} ${data.gift.amount}`;
|
||||||
|
|
||||||
|
ShowAlert(message, 'kick');
|
||||||
|
}
|
||||||
|
|
||||||
async function TikTokChat(data) {
|
async function TikTokChat(data) {
|
||||||
if (!showTikTokMessages)
|
if (!showTikTokMessages)
|
||||||
return;
|
return;
|
||||||
@@ -1572,105 +1586,6 @@ function TikTokSubscribe(data) {
|
|||||||
// HELPER FUNCTIONS //
|
// HELPER FUNCTIONS //
|
||||||
//////////////////////
|
//////////////////////
|
||||||
|
|
||||||
function GetBooleanParam(paramName, defaultValue) {
|
|
||||||
const urlParams = new URLSearchParams(window.location.search);
|
|
||||||
const paramValue = urlParams.get(paramName);
|
|
||||||
|
|
||||||
if (paramValue === null) {
|
|
||||||
return defaultValue; // Parameter not found
|
|
||||||
}
|
|
||||||
|
|
||||||
const lowercaseValue = paramValue.toLowerCase(); // Handle case-insensitivity
|
|
||||||
|
|
||||||
if (lowercaseValue === 'true') {
|
|
||||||
return true;
|
|
||||||
} else if (lowercaseValue === 'false') {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return paramValue; // Return original string if not 'true' or 'false'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function GetIntParam(paramName, defaultValue) {
|
|
||||||
const urlParams = new URLSearchParams(window.location.search);
|
|
||||||
const paramValue = urlParams.get(paramName);
|
|
||||||
|
|
||||||
if (paramValue === null) {
|
|
||||||
return defaultValue; // or undefined, or a default value, depending on your needs
|
|
||||||
}
|
|
||||||
|
|
||||||
const intValue = parseInt(paramValue, 10); // Parse as base 10 integer
|
|
||||||
|
|
||||||
if (isNaN(intValue)) {
|
|
||||||
return null; // or handle the error in another way, e.g., throw an error
|
|
||||||
}
|
|
||||||
|
|
||||||
return intValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
function GetCurrentTimeFormatted() {
|
|
||||||
const now = new Date();
|
|
||||||
let hours = now.getHours();
|
|
||||||
const minutes = String(now.getMinutes()).padStart(2, '0');
|
|
||||||
const ampm = hours >= 12 ? 'PM' : 'AM';
|
|
||||||
|
|
||||||
hours = hours % 12;
|
|
||||||
hours = hours ? hours : 12; // the hour '0' should be '12'
|
|
||||||
|
|
||||||
const formattedTime = `${hours}:${minutes} ${ampm}`;
|
|
||||||
return formattedTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function GetAvatar(username, platform) {
|
|
||||||
|
|
||||||
// First, check if the username is hashed already
|
|
||||||
if (avatarMap.has(`${username}-${platform}`)) {
|
|
||||||
console.debug(`Avatar found for ${username} (${platform}). Retrieving from hash map.`)
|
|
||||||
return avatarMap.get(`${username}-${platform}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If code reaches this point, the username hasn't been hashed, so retrieve avatar
|
|
||||||
switch (platform) {
|
|
||||||
case 'twitch':
|
|
||||||
{
|
|
||||||
console.debug(`No avatar found for ${username} (${platform}). Retrieving from Decapi.`)
|
|
||||||
let response = await fetch('https://decapi.me/twitch/avatar/' + username);
|
|
||||||
let data = await response.text();
|
|
||||||
avatarMap.set(`${username}-${platform}`, data);
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
case 'kick':
|
|
||||||
{
|
|
||||||
console.debug(`No avatar found for ${username} (${platform}). Retrieving from Kick.`)
|
|
||||||
let response = await fetch('https://kick.com/api/v2/channels/' + username);
|
|
||||||
console.log('https://kick.com/api/v2/channels/' + username)
|
|
||||||
let data = await response.json();
|
|
||||||
let avatarURL = data.user.profile_pic;
|
|
||||||
if (!avatarURL)
|
|
||||||
avatarURL = 'https://kick.com/img/default-profile-pictures/default2.jpeg';
|
|
||||||
avatarMap.set(`${username}-${platform}`, avatarURL);
|
|
||||||
return avatarURL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function GetPronouns(platform, username) {
|
|
||||||
if (pronounMap.has(username)) {
|
|
||||||
console.debug(`Pronouns found for ${username}. Retrieving from hash map.`)
|
|
||||||
return pronounMap.get(username);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
console.debug(`No pronouns found for ${username}. Retrieving from alejo.io.`)
|
|
||||||
const response = await client.getUserPronouns(platform, username);
|
|
||||||
const userFound = response.pronoun.userFound;
|
|
||||||
const pronouns = userFound ? `${response.pronoun.pronounSubject}/${response.pronoun.pronounObject}` : '';
|
|
||||||
|
|
||||||
pronounMap.set(username, pronouns);
|
|
||||||
|
|
||||||
return pronouns;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function AddMessageItem(element, elementID, platform, userId) {
|
function AddMessageItem(element, elementID, platform, userId) {
|
||||||
// Calculate the height of the div before inserting
|
// Calculate the height of the div before inserting
|
||||||
const tempDiv = document.getElementById('IPutThisHereSoICanCalculateHowBigEachMessageIsSupposedToBeBeforeIAddItToTheMessageList');
|
const tempDiv = document.getElementById('IPutThisHereSoICanCalculateHowBigEachMessageIsSupposedToBeBeforeIAddItToTheMessageList');
|
||||||
@@ -1820,77 +1735,6 @@ function GetWinnersList(gifts) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function TranslateToFurry(sentence) {
|
|
||||||
const words = sentence.toLowerCase().split(/\b/);
|
|
||||||
|
|
||||||
const furryWords = words.map(word => {
|
|
||||||
if (/\w+/.test(word)) {
|
|
||||||
let newWord = word;
|
|
||||||
|
|
||||||
// Common substitutions
|
|
||||||
newWord = newWord.replace(/l/g, 'w');
|
|
||||||
newWord = newWord.replace(/r/g, 'w');
|
|
||||||
newWord = newWord.replace(/th/g, 'f');
|
|
||||||
newWord = newWord.replace(/you/g, 'yous');
|
|
||||||
newWord = newWord.replace(/my/g, 'mah');
|
|
||||||
newWord = newWord.replace(/me/g, 'meh');
|
|
||||||
newWord = newWord.replace(/am/g, 'am');
|
|
||||||
newWord = newWord.replace(/is/g, 'is');
|
|
||||||
newWord = newWord.replace(/are/g, 'are');
|
|
||||||
newWord = newWord.replace(/very/g, 'vewy');
|
|
||||||
newWord = newWord.replace(/pretty/g, 'pwetty');
|
|
||||||
newWord = newWord.replace(/little/g, 'wittle');
|
|
||||||
newWord = newWord.replace(/nice/g, 'nyce');
|
|
||||||
|
|
||||||
// Random additions
|
|
||||||
if (Math.random() < 0.15) {
|
|
||||||
newWord += ' nya~';
|
|
||||||
} else if (Math.random() < 0.1) {
|
|
||||||
newWord += ' >w<';
|
|
||||||
} else if (Math.random() < 0.05) {
|
|
||||||
newWord += ' owo';
|
|
||||||
}
|
|
||||||
|
|
||||||
return newWord;
|
|
||||||
}
|
|
||||||
return word;
|
|
||||||
});
|
|
||||||
|
|
||||||
return furryWords.join('');
|
|
||||||
}
|
|
||||||
|
|
||||||
function EscapeRegExp(string) {
|
|
||||||
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
|
|
||||||
}
|
|
||||||
|
|
||||||
async function GetKickChatroomId(username) {
|
|
||||||
const url = `https://kick.com/api/v2/channels/${username}`;
|
|
||||||
|
|
||||||
try {
|
|
||||||
const response = await fetch(url);
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error(`HTTP error ${response.status}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const data = await response.json();
|
|
||||||
if (data.chatroom && data.chatroom.id) {
|
|
||||||
return data.chatroom.id;
|
|
||||||
} else {
|
|
||||||
throw new Error("Chatroom ID not found in response.");
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Failed to fetch chatroom ID:", error.message);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function GetKickSubBadges(username) {
|
|
||||||
const response = await fetch(`https://kick.com/api/v2/channels/${username}`);
|
|
||||||
const data = await response.json();
|
|
||||||
|
|
||||||
return data.subscriber_badges || [];
|
|
||||||
}
|
|
||||||
|
|
||||||
function GetKickBadgeURL(data) {
|
function GetKickBadgeURL(data) {
|
||||||
switch (data.type) {
|
switch (data.type) {
|
||||||
case 'subscriber':
|
case 'subscriber':
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<link rel="icon" href="../../.resources/logo.png" type="image/png">
|
<link rel="icon" href="../../.common/resources/logo.png" type="image/png">
|
||||||
<title>nutty</title>
|
<title>nutty</title>
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
const widgetContainer = document.getElementById('widgetContainer');
|
const widgetContainer = document.getElementById('widgetContainer');
|
||||||
|
|
||||||
const settingsPageURL = '../../.utilities/settings-page-builder';
|
const settingsPageURL = '../../.common/core/settings-core';
|
||||||
|
|
||||||
const currentURL = window.location.href;
|
const currentURL = window.location.href;
|
||||||
|
|
||||||
|
|||||||
@@ -255,6 +255,14 @@
|
|||||||
"defaultValue": true,
|
"defaultValue": true,
|
||||||
"group": "Which Kick messages do you want to see?"
|
"group": "Which Kick messages do you want to see?"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "showKickGifts",
|
||||||
|
"label": "Gifts",
|
||||||
|
"description": "",
|
||||||
|
"type": "checkbox",
|
||||||
|
"defaultValue": true,
|
||||||
|
"group": "Which Kick messages do you want to see?"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "enableTikTokSupport",
|
"id": "enableTikTokSupport",
|
||||||
"label": "Enable TikTok Support",
|
"label": "Enable TikTok Support",
|
||||||
|
|||||||
@@ -76,6 +76,10 @@ html {
|
|||||||
/* background-color: red; */
|
/* background-color: red; */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#alertBoxContent img {
|
||||||
|
height: 1.2em;
|
||||||
|
}
|
||||||
|
|
||||||
#background {
|
#background {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 5.3 KiB |
@@ -66,7 +66,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template id="tiktok-gift-template">
|
<template id="tiktok-gift-template">
|
||||||
<div class="tiktok-gift">
|
<div class="tiktok-gift tiktok">
|
||||||
<img class="tiktok-gift-avatar"
|
<img class="tiktok-gift-avatar"
|
||||||
src="https://static-cdn.jtvnw.net/jtv_user_pictures/f632e0c6-38e2-4065-a29e-6ba9b3e8cacf-profile_image-300x300.png" />
|
src="https://static-cdn.jtvnw.net/jtv_user_pictures/f632e0c6-38e2-4065-a29e-6ba9b3e8cacf-profile_image-300x300.png" />
|
||||||
<div class="tiktok-gift-message">
|
<div class="tiktok-gift-message">
|
||||||
@@ -84,6 +84,28 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<template id="kick-gift-template">
|
||||||
|
<div class="kick-gift kick">
|
||||||
|
<img class="kick-gift-avatar"
|
||||||
|
src="" />
|
||||||
|
<div class="kick-gift-contents">
|
||||||
|
<span id="kick-gift-username" style="font-weight: 700;">
|
||||||
|
</span>
|
||||||
|
<br>
|
||||||
|
<div style="display: flex; flex-direction: row; align-items: center;">
|
||||||
|
<span>sent <span id="kick-gift-name"></span></span>
|
||||||
|
<img src="icons/badges/kick-kicks.svg" style="height: 1em; padding-left: 0.5em; padding-right: 0.25em;">
|
||||||
|
<span id="kick-gift-amount">13</span>
|
||||||
|
</div>
|
||||||
|
<div id="kick-gift-message">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<img class="kick-gift-sticker"
|
||||||
|
src="" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
<script src="../.common/utils/helpers.js"></script>
|
||||||
<script src="./script.js"></script>
|
<script src="./script.js"></script>
|
||||||
+83
-229
@@ -7,8 +7,6 @@ const urlParams = new URLSearchParams(queryString);
|
|||||||
|
|
||||||
const sbServerAddress = urlParams.get("address") || "127.0.0.1";
|
const sbServerAddress = urlParams.get("address") || "127.0.0.1";
|
||||||
const sbServerPort = urlParams.get("port") || "8080";
|
const sbServerPort = urlParams.get("port") || "8080";
|
||||||
const avatarMap = new Map();
|
|
||||||
const pronounMap = new Map();
|
|
||||||
|
|
||||||
/////////////////
|
/////////////////
|
||||||
// GLOBAL VARS //
|
// GLOBAL VARS //
|
||||||
@@ -55,12 +53,13 @@ const showTwitchChannelPointRedemptions = GetBooleanParam("showTwitchChannelPoin
|
|||||||
const showTwitchRaids = GetBooleanParam("showTwitchRaids", true);
|
const showTwitchRaids = GetBooleanParam("showTwitchRaids", true);
|
||||||
const showTwitchSharedChat = GetIntParam("showTwitchSharedChat", 2);
|
const showTwitchSharedChat = GetIntParam("showTwitchSharedChat", 2);
|
||||||
|
|
||||||
let kickUsername = urlParams.get("kickUsername") || "";
|
const kickUsername = urlParams.get("kickUsername") || "";
|
||||||
const showKickMessages = GetBooleanParam("showKickMessages", true);
|
const showKickMessages = GetBooleanParam("showKickMessages", true);
|
||||||
// const showKickFollows = GetBooleanParam("showKickFollows", false);
|
// const showKickFollows = GetBooleanParam("showKickFollows", false);
|
||||||
const showKickSubs = GetBooleanParam("showKickSubs", true);
|
const showKickSubs = GetBooleanParam("showKickSubs", true);
|
||||||
const showKickChannelPointRedemptions = GetBooleanParam("showKickChannelPointRedemptions", true);
|
const showKickChannelPointRedemptions = GetBooleanParam("showKickChannelPointRedemptions", true);
|
||||||
const showKickHosts = GetBooleanParam("showKickHosts", true);
|
const showKickHosts = GetBooleanParam("showKickHosts", true);
|
||||||
|
const showKickGifts = GetBooleanParam("showKickGifts", true);
|
||||||
|
|
||||||
const showYouTubeMessages = GetBooleanParam("showYouTubeMessages", true);
|
const showYouTubeMessages = GetBooleanParam("showYouTubeMessages", true);
|
||||||
const showYouTubeSuperChats = GetBooleanParam("showYouTubeSuperChats", true);
|
const showYouTubeSuperChats = GetBooleanParam("showYouTubeSuperChats", true);
|
||||||
@@ -85,9 +84,6 @@ const furryMode = GetBooleanParam("furryMode", false);
|
|||||||
|
|
||||||
const animationSpeed = GetIntParam("animationSpeed", 0.1);
|
const animationSpeed = GetIntParam("animationSpeed", 0.1);
|
||||||
|
|
||||||
// Kick is stupid and turns underscores into dashes which fuck everything up, therefore do a find/replace to make it work good
|
|
||||||
kickUsername = kickUsername.replace(/_/g, "-");
|
|
||||||
|
|
||||||
// Set fonts for the widget
|
// Set fonts for the widget
|
||||||
document.body.style.fontFamily = font;
|
document.body.style.fontFamily = font;
|
||||||
document.body.style.fontSize = `${fontSize}px`;
|
document.body.style.fontSize = `${fontSize}px`;
|
||||||
@@ -322,6 +318,11 @@ client.on('Fourthwall.GiftDrawEnded', (response) => {
|
|||||||
FourthwallGiftDrawEnded(response.data);
|
FourthwallGiftDrawEnded(response.data);
|
||||||
})
|
})
|
||||||
|
|
||||||
|
client.on('Fourthwall.GiftDrawEnded', (response) => {
|
||||||
|
console.debug(response.data);
|
||||||
|
FourthwallGiftDrawEnded(response.data);
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////
|
///////////////////////////
|
||||||
@@ -334,18 +335,20 @@ async function KickConnect() {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Channel to subscribe to (you'll need the correct channel name here)
|
// Channel to subscribe to (you'll need the correct channel name here)
|
||||||
const chatroomId = await GetKickChatroomId(kickUsername);
|
const kickIds = await GetKickIds(kickUsername);
|
||||||
|
const chatroomId = kickIds.chatroomId;
|
||||||
|
const channelId = kickIds.channelId;
|
||||||
|
|
||||||
// Cache subscriber badges
|
// Cache subscriber badges
|
||||||
kickSubBadges = await GetKickSubBadges(kickUsername);
|
kickSubBadges = await GetKickSubBadges(kickUsername);
|
||||||
|
|
||||||
const websocket = new WebSocket(kickPusherWsUrl);
|
const websocket = new WebSocket(kickPusherWsUrl);
|
||||||
|
|
||||||
// Reconnect
|
// Reconnect
|
||||||
websocket.onclose = function () {
|
websocket.onclose = function () {
|
||||||
console.log(`Reconnecting to ${kickUsername}...`);
|
console.log(`Reconnecting to ${kickUsername}...`);
|
||||||
setTimeout(connectPusher, 5000);
|
setTimeout(connectPusher, 5000);
|
||||||
};
|
};
|
||||||
|
|
||||||
websocket.onopen = function () {
|
websocket.onopen = function () {
|
||||||
console.log(`Kick successfully conntected to ${kickUsername}.`);
|
console.log(`Kick successfully conntected to ${kickUsername}.`);
|
||||||
@@ -363,10 +366,11 @@ async function KickConnect() {
|
|||||||
console.log(`[Pusher] Socket established with ID: ${socketData.socket_id}`);
|
console.log(`[Pusher] Socket established with ID: ${socketData.socket_id}`);
|
||||||
|
|
||||||
// Now subscribe to a channel
|
// Now subscribe to a channel
|
||||||
websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `chatroom_${chatroomId}` } }));
|
websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `chatroom_${chatroomId}` } }));
|
||||||
websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `chatrooms.${chatroomId}` } }));
|
websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `chatrooms.${chatroomId}` } }));
|
||||||
websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `chatrooms.${chatroomId}.v2` } }));
|
websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `chatrooms.${chatroomId}.v2` } }));
|
||||||
websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `predictions-channel-${chatroomId}` } }));
|
websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `predictions-channel-${chatroomId}` } }));
|
||||||
|
websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `channel_${channelId}` } }));
|
||||||
console.log(`[Pusher] Sent subscription request to channel: ${chatroomId}`);
|
console.log(`[Pusher] Sent subscription request to channel: ${chatroomId}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -398,6 +402,9 @@ async function KickConnect() {
|
|||||||
case 'UserBannedEvent':
|
case 'UserBannedEvent':
|
||||||
KickUserBanned(eventArgs);
|
KickUserBanned(eventArgs);
|
||||||
break;
|
break;
|
||||||
|
case 'KicksGifted':
|
||||||
|
KickKicksGifted(eventArgs);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
@@ -420,7 +427,7 @@ let tikfinityWebsocket = null;
|
|||||||
function TikfinityConnect() {
|
function TikfinityConnect() {
|
||||||
if (!enableTikTokSupport)
|
if (!enableTikTokSupport)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (tikfinityWebsocket) return; // Already connected
|
if (tikfinityWebsocket) return; // Already connected
|
||||||
|
|
||||||
tikfinityWebsocket = new WebSocket("ws://localhost:21213/");
|
tikfinityWebsocket = new WebSocket("ws://localhost:21213/");
|
||||||
@@ -457,7 +464,7 @@ function TikfinityConnect() {
|
|||||||
case 'like':
|
case 'like':
|
||||||
TikTokLikes(data);
|
TikTokLikes(data);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'follow':
|
case 'follow':
|
||||||
TikTokFollow(data);
|
TikTokFollow(data);
|
||||||
break;
|
break;
|
||||||
@@ -536,9 +543,8 @@ async function TwitchChatMessage(data) {
|
|||||||
|
|
||||||
// Set Shared Chat
|
// Set Shared Chat
|
||||||
const isFromSharedChatGuest = data.isFromSharedChatGuest;
|
const isFromSharedChatGuest = data.isFromSharedChatGuest;
|
||||||
if (isFromSharedChatGuest) {
|
if (isFromSharedChatGuest) {
|
||||||
switch (showTwitchSharedChat)
|
switch (showTwitchSharedChat) {
|
||||||
{
|
|
||||||
// 2 = Show & Highlight
|
// 2 = Show & Highlight
|
||||||
case 2:
|
case 2:
|
||||||
let sharedChatChannel = data.sharedChatSource.name; // Twitch removed the source channel for some reason?!?!
|
let sharedChatChannel = data.sharedChatSource.name; // Twitch removed the source channel for some reason?!?!
|
||||||
@@ -2518,6 +2524,35 @@ function KickMessageDeleted(data) {
|
|||||||
}, 500);
|
}, 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function KickKicksGifted(data) {
|
||||||
|
if (!showKickGifts)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Get a reference to the template
|
||||||
|
const template = document.getElementById('kick-gift-template');
|
||||||
|
|
||||||
|
// Create a new instance of the template
|
||||||
|
const instance = template.content.cloneNode(true);
|
||||||
|
|
||||||
|
// Get divs
|
||||||
|
const avatarImg = instance.querySelector('.kick-gift-avatar');
|
||||||
|
const usernameSpan = instance.querySelector('#kick-gift-username');
|
||||||
|
const giftNameSpan = instance.querySelector('#kick-gift-name');
|
||||||
|
const stickerImg = instance.querySelector('.kick-gift-sticker');
|
||||||
|
const amountDiv = instance.querySelector('#kick-gift-amount');
|
||||||
|
const messageDiv = instance.querySelector('#kick-gift-message');
|
||||||
|
|
||||||
|
avatarImg.src = await GetAvatar(data.sender.username, 'kick'); // Set the card header
|
||||||
|
usernameSpan.innerText = data.sender.username; // Set the username
|
||||||
|
usernameSpan.style.color = data.sender.username_color;
|
||||||
|
giftNameSpan.innerText = data.gift.name; // Set the gift name
|
||||||
|
stickerImg.src = `https://files.kick.com/kicks/gifts/${data.gift.gift_id.replace('_', '-')}.webp`; // Set the sticker image URL
|
||||||
|
amountDiv.innerText = data.gift.amount; // Set the number of gifts sent
|
||||||
|
messageDiv.innerText = data.message // Set the message
|
||||||
|
|
||||||
|
AddMessageItem(instance, null, 'kick', data.senderId);
|
||||||
|
}
|
||||||
|
|
||||||
function KickUserBanned(data) {
|
function KickUserBanned(data) {
|
||||||
const messageList = document.getElementById("messageList");
|
const messageList = document.getElementById("messageList");
|
||||||
|
|
||||||
@@ -2545,7 +2580,7 @@ function KickUserBanned(data) {
|
|||||||
async function TikTokChat(data) {
|
async function TikTokChat(data) {
|
||||||
if (!showTikTokMessages)
|
if (!showTikTokMessages)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Don't post messages starting with "!"
|
// Don't post messages starting with "!"
|
||||||
if (data.comment.startsWith("!") && excludeCommands)
|
if (data.comment.startsWith("!") && excludeCommands)
|
||||||
return;
|
return;
|
||||||
@@ -2728,27 +2763,28 @@ function TikTokLikes(data) {
|
|||||||
let likeCount = parseInt(data.likeCount);
|
let likeCount = parseInt(data.likeCount);
|
||||||
|
|
||||||
// Search for Previous Likes from the Same User
|
// Search for Previous Likes from the Same User
|
||||||
const previousLikeContainer = document.querySelector(`.likes[data-user-identifier="${data.userId}"]`);
|
const previousLikeContainer = document.querySelector(`.likes[data-user-identifier="${data.userId}"]`);
|
||||||
|
|
||||||
// If found, fetches the previous likes, deletes the element
|
// If found, fetches the previous likes, deletes the element
|
||||||
// and then creates a new count with a sum of the like count
|
// and then creates a new count with a sum of the like count
|
||||||
if (previousLikeContainer) {
|
if (previousLikeContainer) {
|
||||||
const likeCountElem = previousLikeContainer.querySelector('#tiktok-gift-repeat-count');
|
const likeCountElem = previousLikeContainer.querySelector('#tiktok-gift-repeat-count');
|
||||||
if (likeCountElem) {
|
if (likeCountElem) {
|
||||||
const liLikeContainer = previousLikeContainer.parentElement?.parentElement
|
const liLikeContainer = previousLikeContainer.parentElement?.parentElement;
|
||||||
if (liLikeContainer) {
|
if (liLikeContainer) {
|
||||||
|
let prevLikeCount = parseInt(likeCountElem.textContent.replace('x', ''), 10);
|
||||||
let prevLikeCount = parseInt(likeCountElem.textContent.replace('x', ''), 10);
|
let likeCountUpdate = Math.floor(prevLikeCount + likeCount);
|
||||||
let likeCountUpdate = Math.floor(prevLikeCount + likeCount);
|
let likeCountDiv = previousLikeContainer.querySelector('#tiktok-gift-repeat-count');
|
||||||
let likeCountDiv = previousLikeContainer.querySelector('#tiktok-gift-repeat-count');
|
|
||||||
|
|
||||||
likeCountDiv.innerText = `x${likeCountUpdate}`;
|
likeCountDiv.innerText = `x${likeCountUpdate}`;
|
||||||
|
|
||||||
const parent = liLikeContainer.parentElement;
|
const parent = liLikeContainer.parentElement;
|
||||||
if (parent) { parent.appendChild(liLikeContainer); }
|
if (parent) {
|
||||||
}
|
parent.appendChild(liLikeContainer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
// Get a reference to the template
|
// Get a reference to the template
|
||||||
@@ -2891,111 +2927,6 @@ function YouTubeThumbnailPreview(data) {
|
|||||||
// HELPER FUNCTIONS //
|
// HELPER FUNCTIONS //
|
||||||
//////////////////////
|
//////////////////////
|
||||||
|
|
||||||
function GetBooleanParam(paramName, defaultValue) {
|
|
||||||
const urlParams = new URLSearchParams(window.location.search);
|
|
||||||
const paramValue = urlParams.get(paramName);
|
|
||||||
|
|
||||||
if (paramValue === null) {
|
|
||||||
return defaultValue; // Parameter not found
|
|
||||||
}
|
|
||||||
|
|
||||||
const lowercaseValue = paramValue.toLowerCase(); // Handle case-insensitivity
|
|
||||||
|
|
||||||
if (lowercaseValue === 'true') {
|
|
||||||
return true;
|
|
||||||
} else if (lowercaseValue === 'false') {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return paramValue; // Return original string if not 'true' or 'false'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function GetIntParam(paramName, defaultValue) {
|
|
||||||
const urlParams = new URLSearchParams(window.location.search);
|
|
||||||
const paramValue = urlParams.get(paramName);
|
|
||||||
|
|
||||||
if (paramValue === null) {
|
|
||||||
return defaultValue; // or undefined, or a default value, depending on your needs
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(paramValue);
|
|
||||||
|
|
||||||
const intValue = parseInt(paramValue, 10); // Parse as base 10 integer
|
|
||||||
|
|
||||||
if (isNaN(intValue)) {
|
|
||||||
return null; // or handle the error in another way, e.g., throw an error
|
|
||||||
}
|
|
||||||
|
|
||||||
return intValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
function GetCurrentTimeFormatted() {
|
|
||||||
const now = new Date();
|
|
||||||
let hours = now.getHours();
|
|
||||||
const minutes = String(now.getMinutes()).padStart(2, '0');
|
|
||||||
const ampm = hours >= 12 ? 'PM' : 'AM';
|
|
||||||
|
|
||||||
hours = hours % 12;
|
|
||||||
hours = hours ? hours : 12; // the hour '0' should be '12'
|
|
||||||
|
|
||||||
const formattedTime = `${hours}:${minutes} ${ampm}`;
|
|
||||||
return formattedTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function GetAvatar(username, platform) {
|
|
||||||
|
|
||||||
// First, check if the username is hashed already
|
|
||||||
if (avatarMap.has(`${username}-${platform}`)) {
|
|
||||||
console.debug(`Avatar found for ${username} (${platform}). Retrieving from hash map.`)
|
|
||||||
return avatarMap.get(`${username}-${platform}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If code reaches this point, the username hasn't been hashed, so retrieve avatar
|
|
||||||
switch (platform) {
|
|
||||||
case 'twitch':
|
|
||||||
{
|
|
||||||
console.debug(`No avatar found for ${username} (${platform}). Retrieving from Decapi.`)
|
|
||||||
let response = await fetch('https://decapi.me/twitch/avatar/' + username);
|
|
||||||
let data = await response.text();
|
|
||||||
avatarMap.set(`${username}-${platform}`, data);
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
case 'kick':
|
|
||||||
{
|
|
||||||
console.debug(`No avatar found for ${username} (${platform}). Retrieving from Kick.`)
|
|
||||||
let response = await fetch('https://kick.com/api/v2/channels/' + username);
|
|
||||||
console.log('https://kick.com/api/v2/channels/' + username)
|
|
||||||
let data = await response.json();
|
|
||||||
let avatarURL = data.user.profile_pic;
|
|
||||||
if (!avatarURL)
|
|
||||||
avatarURL = 'https://kick.com/img/default-profile-pictures/default2.jpeg';
|
|
||||||
avatarMap.set(`${username}-${platform}`, avatarURL);
|
|
||||||
return avatarURL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function GetPronouns(platform, username) {
|
|
||||||
if (pronounMap.has(username)) {
|
|
||||||
console.debug(`Pronouns found for ${username}. Retrieving from hash map.`)
|
|
||||||
return pronounMap.get(username);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
console.debug(`No pronouns found for ${username}. Retrieving from alejo.io.`)
|
|
||||||
const response = await client.getUserPronouns(platform, username);
|
|
||||||
const userFound = response.pronoun.userFound;
|
|
||||||
const pronouns = userFound ? `${response.pronoun.pronounSubject}/${response.pronoun.pronounObject}` : '';
|
|
||||||
|
|
||||||
pronounMap.set(username, pronouns);
|
|
||||||
|
|
||||||
return pronouns;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// function IsImageUrl(url) {
|
|
||||||
// return url.match(/^http.*\.(jpeg|jpg|gif|png)$/) != null;
|
|
||||||
// }
|
|
||||||
|
|
||||||
function IsImageUrl(url) {
|
function IsImageUrl(url) {
|
||||||
try {
|
try {
|
||||||
const { pathname } = new URL(url);
|
const { pathname } = new URL(url);
|
||||||
@@ -3064,12 +2995,6 @@ function AddMessageItem(element, elementID, platform, userId) {
|
|||||||
}, 200);
|
}, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
function DecodeHTMLString(html) {
|
|
||||||
var txt = document.createElement("textarea");
|
|
||||||
txt.innerHTML = html;
|
|
||||||
return txt.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
// I used Gemini for this shit so if it doesn't work, blame Google
|
// I used Gemini for this shit so if it doesn't work, blame Google
|
||||||
function FindFirstImageUrl(jsonObject) {
|
function FindFirstImageUrl(jsonObject) {
|
||||||
if (typeof jsonObject !== 'object' || jsonObject === null) {
|
if (typeof jsonObject !== 'object' || jsonObject === null) {
|
||||||
@@ -3165,77 +3090,6 @@ function GetWinnersList(gifts) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function TranslateToFurry(sentence) {
|
|
||||||
const words = sentence.toLowerCase().split(/\b/);
|
|
||||||
|
|
||||||
const furryWords = words.map(word => {
|
|
||||||
if (/\w+/.test(word)) {
|
|
||||||
let newWord = word;
|
|
||||||
|
|
||||||
// Common substitutions
|
|
||||||
newWord = newWord.replace(/l/g, 'w');
|
|
||||||
newWord = newWord.replace(/r/g, 'w');
|
|
||||||
newWord = newWord.replace(/th/g, 'f');
|
|
||||||
newWord = newWord.replace(/you/g, 'yous');
|
|
||||||
newWord = newWord.replace(/my/g, 'mah');
|
|
||||||
newWord = newWord.replace(/me/g, 'meh');
|
|
||||||
newWord = newWord.replace(/am/g, 'am');
|
|
||||||
newWord = newWord.replace(/is/g, 'is');
|
|
||||||
newWord = newWord.replace(/are/g, 'are');
|
|
||||||
newWord = newWord.replace(/very/g, 'vewy');
|
|
||||||
newWord = newWord.replace(/pretty/g, 'pwetty');
|
|
||||||
newWord = newWord.replace(/little/g, 'wittle');
|
|
||||||
newWord = newWord.replace(/nice/g, 'nyce');
|
|
||||||
|
|
||||||
// Random additions
|
|
||||||
if (Math.random() < 0.15) {
|
|
||||||
newWord += ' nya~';
|
|
||||||
} else if (Math.random() < 0.1) {
|
|
||||||
newWord += ' >w<';
|
|
||||||
} else if (Math.random() < 0.05) {
|
|
||||||
newWord += ' owo';
|
|
||||||
}
|
|
||||||
|
|
||||||
return newWord;
|
|
||||||
}
|
|
||||||
return word;
|
|
||||||
});
|
|
||||||
|
|
||||||
return furryWords.join('');
|
|
||||||
}
|
|
||||||
|
|
||||||
function EscapeRegExp(string) {
|
|
||||||
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
|
|
||||||
}
|
|
||||||
|
|
||||||
async function GetKickChatroomId(username) {
|
|
||||||
const url = `https://kick.com/api/v2/channels/${username}`;
|
|
||||||
|
|
||||||
try {
|
|
||||||
const response = await fetch(url);
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error(`HTTP error ${response.status}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const data = await response.json();
|
|
||||||
if (data.chatroom && data.chatroom.id) {
|
|
||||||
return data.chatroom.id;
|
|
||||||
} else {
|
|
||||||
throw new Error("Chatroom ID not found in response.");
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Failed to fetch chatroom ID:", error.message);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function GetKickSubBadges(username) {
|
|
||||||
const response = await fetch(`https://kick.com/api/v2/channels/${username}`);
|
|
||||||
const data = await response.json();
|
|
||||||
|
|
||||||
return data.subscriber_badges || [];
|
|
||||||
}
|
|
||||||
|
|
||||||
function GetKickBadgeURL(data) {
|
function GetKickBadgeURL(data) {
|
||||||
switch (data.type) {
|
switch (data.type) {
|
||||||
case 'subscriber':
|
case 'subscriber':
|
||||||
@@ -3246,14 +3100,14 @@ function GetKickBadgeURL(data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function CalculateKickSubBadge(months) {
|
function CalculateKickSubBadge(months) {
|
||||||
if (!Array.isArray(kickSubBadges)) return null;
|
if (!Array.isArray(kickSubBadges)) return null;
|
||||||
|
|
||||||
// Filter for eligible badges, then get the one with the highest 'months'
|
// Filter for eligible badges, then get the one with the highest 'months'
|
||||||
const badge = kickSubBadges
|
const badge = kickSubBadges
|
||||||
.filter(b => b.months <= months)
|
.filter(b => b.months <= months)
|
||||||
.sort((a, b) => b.months - a.months)[0];
|
.sort((a, b) => b.months - a.months)[0];
|
||||||
|
|
||||||
return badge?.badge_image?.src || `icons/badges/kick-subscriber.svg`;
|
return badge?.badge_image?.src || `icons/badges/kick-subscriber.svg`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<link rel="icon" href="../../.resources/logo.png" type="image/png">
|
<link rel="icon" href="../../.common/resources/logo.png" type="image/png">
|
||||||
<title>nutty</title>
|
<title>nutty</title>
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
const widgetContainer = document.getElementById('widgetContainer');
|
const widgetContainer = document.getElementById('widgetContainer');
|
||||||
|
|
||||||
const settingsPageURL = '../../.utilities/settings-page-builder';
|
const settingsPageURL = '../../.common/core/settings-core';
|
||||||
|
|
||||||
const currentURL = window.location.href;
|
const currentURL = window.location.href;
|
||||||
|
|
||||||
|
|||||||
@@ -376,6 +376,14 @@
|
|||||||
"defaultValue": true,
|
"defaultValue": true,
|
||||||
"group": "Which Kick messages do you want to see?"
|
"group": "Which Kick messages do you want to see?"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "showKickGifts",
|
||||||
|
"label": "Gifts",
|
||||||
|
"description": "",
|
||||||
|
"type": "checkbox",
|
||||||
|
"defaultValue": true,
|
||||||
|
"group": "Which Kick messages do you want to see?"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "enableTikTokSupport",
|
"id": "enableTikTokSupport",
|
||||||
"label": "Enable TikTok Support",
|
"label": "Enable TikTok Support",
|
||||||
|
|||||||
@@ -224,17 +224,18 @@ li {
|
|||||||
transform: translate(0px, 0.25em);
|
transform: translate(0px, 0.25em);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.kick-gift,
|
||||||
.tiktok-gift {
|
.tiktok-gift {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 1em;
|
gap: 1em;
|
||||||
padding: 0.5em 1em;
|
padding: 0.5em;
|
||||||
border-radius: var(--border-radius);
|
border-radius: var(--border-radius);
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
background: linear-gradient(#262626BF, #000000BF) !important;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.kick-gift-avatar,
|
||||||
.tiktok-gift-avatar {
|
.tiktok-gift-avatar {
|
||||||
height: 3em;
|
height: 3em;
|
||||||
margin: 1px;
|
margin: 1px;
|
||||||
@@ -243,17 +244,37 @@ li {
|
|||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.kick-gift-contents,
|
||||||
.tiktok-gift-message {
|
.tiktok-gift-message {
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
white-space: nowrap; /* keeps text in a single line */
|
/* white-space: nowrap;
|
||||||
overflow: hidden; /* hides overflowed content */
|
overflow: hidden;
|
||||||
text-overflow: ellipsis; /* adds the "..." at the end */
|
text-overflow: ellipsis; */
|
||||||
|
gap: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* .kick-gift-contents {
|
||||||
|
text-align: center;
|
||||||
|
} */
|
||||||
|
|
||||||
|
#kick-gift-message {
|
||||||
|
font-size: 0.9em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.kick-gift-sticker,
|
||||||
|
.tiktok-gift-sticker {
|
||||||
|
flex-shrink: 0;
|
||||||
|
justify-content: flex-end;
|
||||||
|
|
||||||
|
filter: drop-shadow(5px 5px 5px #00000060);
|
||||||
}
|
}
|
||||||
|
|
||||||
.tiktok-gift-sticker {
|
.tiktok-gift-sticker {
|
||||||
height: 2.5em;
|
height: 2.5em;
|
||||||
flex-shrink: 0;
|
}
|
||||||
justify-content: flex-end;
|
|
||||||
|
.kick-gift-sticker {
|
||||||
|
height: 5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
#tiktok-gift-repeat-count {
|
#tiktok-gift-repeat-count {
|
||||||
@@ -292,7 +313,7 @@ li {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.kick {
|
.kick {
|
||||||
background: linear-gradient(#53fc18, #005600) !important;
|
background: linear-gradient(#32b602, #005600) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.streamlabs {
|
.streamlabs {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 5.3 KiB |
@@ -44,4 +44,5 @@
|
|||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
<script src="../.common/utils/helpers.js"></script>
|
||||||
<script src="./script.js"></script>
|
<script src="./script.js"></script>
|
||||||
+36
-120
@@ -7,7 +7,6 @@ const urlParams = new URLSearchParams(queryString);
|
|||||||
|
|
||||||
const sbServerAddress = urlParams.get("address") || "127.0.0.1";
|
const sbServerAddress = urlParams.get("address") || "127.0.0.1";
|
||||||
const sbServerPort = urlParams.get("port") || "8080";
|
const sbServerPort = urlParams.get("port") || "8080";
|
||||||
const avatarMap = new Map();
|
|
||||||
|
|
||||||
const mainContainer = document.getElementById('mainContainer');
|
const mainContainer = document.getElementById('mainContainer');
|
||||||
const alertBox = document.getElementById('alertBox');
|
const alertBox = document.getElementById('alertBox');
|
||||||
@@ -70,13 +69,15 @@ const showTwitchRaids = GetBooleanParam("showTwitchRaids", true);
|
|||||||
const twitchRaidAction = urlParams.get("twitchRaidAction") || "";
|
const twitchRaidAction = urlParams.get("twitchRaidAction") || "";
|
||||||
|
|
||||||
// Which Kick alerts do you want to see?
|
// Which Kick alerts do you want to see?
|
||||||
let kickUsername = urlParams.get("kickUsername") || "";
|
const kickUsername = urlParams.get("kickUsername") || "";
|
||||||
const showKickSubs = GetBooleanParam("showKickSubs", true);
|
const showKickSubs = GetBooleanParam("showKickSubs", true);
|
||||||
const kickSubAction = urlParams.get("kickSubAction") || "";
|
const kickSubAction = urlParams.get("kickSubAction") || "";
|
||||||
const showKickChannelPointRedemptions = GetBooleanParam("showKickChannelPointRedemptions", true);
|
const showKickChannelPointRedemptions = GetBooleanParam("showKickChannelPointRedemptions", true);
|
||||||
const kickChannelPointRedemptionAction = urlParams.get("kickChannelPointRedemptionAction") || "";
|
const kickChannelPointRedemptionAction = urlParams.get("kickChannelPointRedemptionAction") || "";
|
||||||
const showKickHosts = GetBooleanParam("showKickHosts", true);
|
const showKickHosts = GetBooleanParam("showKickHosts", true);
|
||||||
const kickHostAction = urlParams.get("kickHostAction") || "";
|
const kickHostAction = urlParams.get("kickHostAction") || "";
|
||||||
|
const showKickGifts = GetBooleanParam("showKickGifts", true);
|
||||||
|
const kickGiftAction = urlParams.get("kickGiftAction") || "";
|
||||||
|
|
||||||
// Which YouTube alerts do you want to see?
|
// Which YouTube alerts do you want to see?
|
||||||
const showYouTubeSuperChats = GetBooleanParam("showYouTubeSuperChats", true);
|
const showYouTubeSuperChats = GetBooleanParam("showYouTubeSuperChats", true);
|
||||||
@@ -107,9 +108,6 @@ const tipeeestreamDonationAction = urlParams.get("tipeeestreamDonationAction") |
|
|||||||
const showFourthwallAlerts = GetBooleanParam("showFourthwallAlerts", false);
|
const showFourthwallAlerts = GetBooleanParam("showFourthwallAlerts", false);
|
||||||
const fourthwallAlertAction = urlParams.get("fourthwallAlertAction") || "";
|
const fourthwallAlertAction = urlParams.get("fourthwallAlertAction") || "";
|
||||||
|
|
||||||
// Kick is stupid and turns underscores into dashes which fuck everything up, therefore do a find/replace to make it work good
|
|
||||||
kickUsername = kickUsername.replace(/_/g, "-");
|
|
||||||
|
|
||||||
// Set avatar visibility
|
// Set avatar visibility
|
||||||
if (!showAvatar) {
|
if (!showAvatar) {
|
||||||
avatarElement.style.display = 'none';
|
avatarElement.style.display = 'none';
|
||||||
@@ -315,7 +313,9 @@ async function KickConnect() {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Channel to subscribe to (you'll need the correct channel name here)
|
// Channel to subscribe to (you'll need the correct channel name here)
|
||||||
const chatroomId = await GetKickChatroomId(kickUsername);
|
const kickIds = await GetKickIds(kickUsername);
|
||||||
|
const chatroomId = kickIds.chatroomId;
|
||||||
|
const channelId = kickIds.channelId;
|
||||||
|
|
||||||
// Cache subscriber badges
|
// Cache subscriber badges
|
||||||
kickSubBadges = await GetKickSubBadges(kickUsername);
|
kickSubBadges = await GetKickSubBadges(kickUsername);
|
||||||
@@ -348,6 +348,7 @@ async function KickConnect() {
|
|||||||
websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `chatrooms.${chatroomId}` } }));
|
websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `chatrooms.${chatroomId}` } }));
|
||||||
websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `chatrooms.${chatroomId}.v2` } }));
|
websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `chatrooms.${chatroomId}.v2` } }));
|
||||||
websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `predictions-channel-${chatroomId}` } }));
|
websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `predictions-channel-${chatroomId}` } }));
|
||||||
|
websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `channel_${channelId}` } }));
|
||||||
console.log(`[Pusher] Sent subscription request to channel: ${chatroomId}`);
|
console.log(`[Pusher] Sent subscription request to channel: ${chatroomId}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -370,6 +371,9 @@ async function KickConnect() {
|
|||||||
case 'StreamHostEvent':
|
case 'StreamHostEvent':
|
||||||
KickStreamHost(eventArgs);
|
KickStreamHost(eventArgs);
|
||||||
break;
|
break;
|
||||||
|
case 'KicksGifted':
|
||||||
|
KickKicksGifted(eventArgs);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
@@ -1365,6 +1369,32 @@ async function KickStreamHost(data) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function KickKicksGifted(data) {
|
||||||
|
if (!showKickGifts)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Set the text
|
||||||
|
const username = data.sender.username;
|
||||||
|
const tiktokIcon = `<img src="icons/platforms/kick.png" class="platform"/>`;
|
||||||
|
// const giftImg = `<img src=https://files.kick.com/kicks/gifts/${data.gift.gift_id.replace('_', '-')}.webp style="height: 1em"/>`;
|
||||||
|
const kickKicksIcon = `<img src=icons/badges/kick-kicks.svg style="height: 0.8em"/>`;
|
||||||
|
|
||||||
|
// Render avatars
|
||||||
|
const avatarURL = `https://files.kick.com/kicks/gifts/${data.gift.gift_id.replace('_', '-')}.webp`;
|
||||||
|
|
||||||
|
UpdateAlertBox(
|
||||||
|
'kick',
|
||||||
|
avatarURL,
|
||||||
|
`${username}`,
|
||||||
|
`sent ${kickKicksIcon} ${data.gift.amount}`,
|
||||||
|
'',
|
||||||
|
username,
|
||||||
|
data.message,
|
||||||
|
kickGiftAction,
|
||||||
|
data
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
async function TikTokGift(data) {
|
async function TikTokGift(data) {
|
||||||
if (!showTikTokGifts)
|
if (!showTikTokGifts)
|
||||||
return;
|
return;
|
||||||
@@ -1429,83 +1459,6 @@ async function TikTokSubscribe(data) {
|
|||||||
// HELPER FUNCTIONS //
|
// HELPER FUNCTIONS //
|
||||||
//////////////////////
|
//////////////////////
|
||||||
|
|
||||||
function GetBooleanParam(paramName, defaultValue) {
|
|
||||||
const urlParams = new URLSearchParams(window.location.search);
|
|
||||||
const paramValue = urlParams.get(paramName);
|
|
||||||
|
|
||||||
if (paramValue === null) {
|
|
||||||
return defaultValue; // Parameter not found
|
|
||||||
}
|
|
||||||
|
|
||||||
const lowercaseValue = paramValue.toLowerCase(); // Handle case-insensitivity
|
|
||||||
|
|
||||||
if (lowercaseValue === 'true') {
|
|
||||||
return true;
|
|
||||||
} else if (lowercaseValue === 'false') {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return paramValue; // Return original string if not 'true' or 'false'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function GetIntParam(paramName, defaultValue) {
|
|
||||||
const urlParams = new URLSearchParams(window.location.search);
|
|
||||||
const paramValue = urlParams.get(paramName);
|
|
||||||
|
|
||||||
if (paramValue === null) {
|
|
||||||
return defaultValue; // or undefined, or a default value, depending on your needs
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(paramValue);
|
|
||||||
|
|
||||||
const intValue = parseInt(paramValue, 10); // Parse as base 10 integer
|
|
||||||
|
|
||||||
if (isNaN(intValue)) {
|
|
||||||
return null; // or handle the error in another way, e.g., throw an error
|
|
||||||
}
|
|
||||||
|
|
||||||
return intValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function GetAvatar(username, platform) {
|
|
||||||
|
|
||||||
// First, check if the username is hashed already
|
|
||||||
if (avatarMap.has(`${username}-${platform}`)) {
|
|
||||||
console.debug(`Avatar found for ${username} (${platform}). Retrieving from hash map.`)
|
|
||||||
return avatarMap.get(`${username}-${platform}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If code reaches this point, the username hasn't been hashed, so retrieve avatar
|
|
||||||
switch (platform) {
|
|
||||||
case 'twitch':
|
|
||||||
{
|
|
||||||
console.debug(`No avatar found for ${username} (${platform}). Retrieving from Decapi.`)
|
|
||||||
let response = await fetch('https://decapi.me/twitch/avatar/' + username);
|
|
||||||
let data = await response.text();
|
|
||||||
avatarMap.set(`${username}-${platform}`, data);
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
case 'kick':
|
|
||||||
{
|
|
||||||
console.debug(`No avatar found for ${username} (${platform}). Retrieving from Kick.`)
|
|
||||||
let response = await fetch('https://kick.com/api/v2/channels/' + username);
|
|
||||||
console.log('https://kick.com/api/v2/channels/' + username)
|
|
||||||
let data = await response.json();
|
|
||||||
let avatarURL = data.user.profile_pic;
|
|
||||||
if (!avatarURL)
|
|
||||||
avatarURL = 'https://kick.com/img/default-profile-pictures/default2.jpeg';
|
|
||||||
avatarMap.set(`${username}-${platform}`, avatarURL);
|
|
||||||
return avatarURL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function DecodeHTMLString(html) {
|
|
||||||
var txt = document.createElement("textarea");
|
|
||||||
txt.innerHTML = html;
|
|
||||||
return txt.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
// I used Gemini for this shit so if it doesn't work, blame Google
|
// I used Gemini for this shit so if it doesn't work, blame Google
|
||||||
function FindFirstImageUrl(jsonObject) {
|
function FindFirstImageUrl(jsonObject) {
|
||||||
if (typeof jsonObject !== 'object' || jsonObject === null) {
|
if (typeof jsonObject !== 'object' || jsonObject === null) {
|
||||||
@@ -1710,43 +1663,6 @@ function UpdateAlertBox(platform, avatarURL, headerText, descriptionText, attrib
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function GetKickChatroomId(username) {
|
|
||||||
const url = `https://kick.com/api/v2/channels/${username}`;
|
|
||||||
|
|
||||||
try {
|
|
||||||
const response = await fetch(url);
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error(`HTTP error ${response.status}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const data = await response.json();
|
|
||||||
if (data.chatroom && data.chatroom.id) {
|
|
||||||
return data.chatroom.id;
|
|
||||||
} else {
|
|
||||||
throw new Error("Chatroom ID not found in response.");
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Failed to fetch chatroom ID:", error.message);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function GetKickSubBadges(username) {
|
|
||||||
const response = await fetch(`https://kick.com/api/v2/channels/${username}`);
|
|
||||||
const data = await response.json();
|
|
||||||
|
|
||||||
return data.subscriber_badges || [];
|
|
||||||
}
|
|
||||||
|
|
||||||
function GetKickBadgeURL(data) {
|
|
||||||
switch (data.type) {
|
|
||||||
case 'subscriber':
|
|
||||||
return CalculateKickSubBadge(data.count);
|
|
||||||
default:
|
|
||||||
return `icons/badges/kick-${data.type}.svg`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function CalculateKickSubBadge(months) {
|
function CalculateKickSubBadge(months) {
|
||||||
if (!Array.isArray(kickSubBadges)) return null;
|
if (!Array.isArray(kickSubBadges)) return null;
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<link rel="icon" href="../../.resources/logo.png" type="image/png">
|
<link rel="icon" href="../../.common/resources/logo.png" type="image/png">
|
||||||
<title>nutty</title>
|
<title>nutty</title>
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
const widgetContainer = document.getElementById('widgetContainer');
|
const widgetContainer = document.getElementById('widgetContainer');
|
||||||
|
|
||||||
const settingsPageURL = '../../.utilities/settings-page-builder';
|
const settingsPageURL = '../../.common/core/settings-core';
|
||||||
|
|
||||||
const currentURL = window.location.href;
|
const currentURL = window.location.href;
|
||||||
|
|
||||||
|
|||||||
@@ -422,6 +422,23 @@
|
|||||||
"showIf": "showKickHosts",
|
"showIf": "showKickHosts",
|
||||||
"group": "Which Kick alerts do you want to see?"
|
"group": "Which Kick alerts do you want to see?"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "showKickGifts",
|
||||||
|
"label": "Gifts",
|
||||||
|
"description": "",
|
||||||
|
"type": "checkbox",
|
||||||
|
"defaultValue": true,
|
||||||
|
"group": "Which Kick alerts do you want to see?"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "kickGiftAction",
|
||||||
|
"label": "",
|
||||||
|
"description": "Also run this Streamer.bot Action",
|
||||||
|
"type": "sb-actions",
|
||||||
|
"defaultValue": "",
|
||||||
|
"showIf": "showKickGifts",
|
||||||
|
"group": "Which Kick alerts do you want to see?"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "enableTikTokSupport",
|
"id": "enableTikTokSupport",
|
||||||
"label": "Enable TikTok Support",
|
"label": "Enable TikTok Support",
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -25,6 +25,8 @@
|
|||||||
<div class="broadcast-info">
|
<div class="broadcast-info">
|
||||||
<label class="setting-attribute">
|
<label class="setting-attribute">
|
||||||
<i>YouTube stream info can only be updated while live</i>
|
<i>YouTube stream info can only be updated while live</i>
|
||||||
|
<br>
|
||||||
|
<i><span id="youtube-title-on-broadcast-start-label"></span></i>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -59,6 +61,17 @@
|
|||||||
<input type="text" id="all-category-input" placeholder="Leave empty to keep current category">
|
<input type="text" id="all-category-input" placeholder="Leave empty to keep current category">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="include-youtube-setting-wrapper" class="setting">
|
||||||
|
<div>
|
||||||
|
<div class="setting-label">Include YouTube</div>
|
||||||
|
<div class="setting-description">Update YouTube title as soon as broadcast starts</div>
|
||||||
|
</div>
|
||||||
|
<label class="switch" style="margin-left: auto;">
|
||||||
|
<input type="checkbox" id="include-youtube-setting" name="include-youtube-setting" checked>
|
||||||
|
<span class="slider round"></span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
<button id="all-submit-button" onclick="UpdateAllSubmit()">Update All</button>
|
<button id="all-submit-button" onclick="UpdateAllSubmit()">Update All</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -211,7 +224,7 @@
|
|||||||
<div class="broadcast-info">
|
<div class="broadcast-info">
|
||||||
<label id="broadcast-title"></label>
|
<label id="broadcast-title"></label>
|
||||||
<label id="broadcast-category" class="setting-description"></label>
|
<label id="broadcast-category" class="setting-description"></label>
|
||||||
<label id="kick-warning" class="setting-attribute"><br><i>Stream info only available when live — Showing
|
<label id="kick-warning" class="setting-attribute"><br><i>Most up to date stream info only available when live — Showing
|
||||||
last known stream title</i></label>
|
last known stream title</i></label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ const sbActionOpenUrl = '14da1d44-6e29-4582-92c3-2c59388be57e';
|
|||||||
|
|
||||||
let currentBroadcastId = '';
|
let currentBroadcastId = '';
|
||||||
let runningActionId = '';
|
let runningActionId = '';
|
||||||
|
let youtubeTitleOnBroadcastStart = '';
|
||||||
|
|
||||||
|
|
||||||
///////////////////
|
///////////////////
|
||||||
@@ -21,6 +22,9 @@ const updateKickDialog = document.getElementById('update-kick-dialog');
|
|||||||
const updateYouTubeDialog = document.getElementById('update-youtube-dialog');
|
const updateYouTubeDialog = document.getElementById('update-youtube-dialog');
|
||||||
const broadcastList = document.getElementById('broadcast-list');
|
const broadcastList = document.getElementById('broadcast-list');
|
||||||
const youtubeWarning = document.getElementById('youtube-warning');
|
const youtubeWarning = document.getElementById('youtube-warning');
|
||||||
|
const includeYouTubeSettingWrapper = document.getElementById('include-youtube-setting-wrapper');
|
||||||
|
const includeYouTubeSetting = document.getElementById('include-youtube-setting');
|
||||||
|
const youtubeTitleOnBroadcastStartLabel = document.getElementById('youtube-title-on-broadcast-start-label');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -37,6 +41,21 @@ window.parent.sbClient.on('General.Custom', (response) => {
|
|||||||
GeneralCustom(response.data);
|
GeneralCustom(response.data);
|
||||||
})
|
})
|
||||||
|
|
||||||
|
window.parent.sbClient.on('YouTube.BroadcastStarted', (response) => {
|
||||||
|
console.debug(response.data);
|
||||||
|
YouTubeBroadcastStarted(response.data);
|
||||||
|
})
|
||||||
|
|
||||||
|
window.parent.sbClient.on('Twitch.StreamUpdate', (response) => {
|
||||||
|
console.debug(response.data);
|
||||||
|
FetchBroadcasts();
|
||||||
|
})
|
||||||
|
|
||||||
|
window.parent.sbClient.on('YouTube.BroadcastUpdated', (response) => {
|
||||||
|
console.debug(response.data);
|
||||||
|
FetchBroadcasts();
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
@@ -64,9 +83,17 @@ async function GeneralCustom(data) {
|
|||||||
// Only show the warning if there are 0 monitored broadcasts
|
// Only show the warning if there are 0 monitored broadcasts
|
||||||
const ytBroadcastCount = data.broadcastList.filter(b => b.platform === "youtube").length;
|
const ytBroadcastCount = data.broadcastList.filter(b => b.platform === "youtube").length;
|
||||||
if (ytBroadcastCount <= 0)
|
if (ytBroadcastCount <= 0)
|
||||||
|
{
|
||||||
youtubeWarning.style.display = 'flex';
|
youtubeWarning.style.display = 'flex';
|
||||||
|
includeYouTubeSettingWrapper.style.display = 'flex';
|
||||||
|
includeYouTubeSetting.checked = true;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
youtubeWarning.style.display = 'none';
|
youtubeWarning.style.display = 'none';
|
||||||
|
includeYouTubeSettingWrapper.style.display = 'none';
|
||||||
|
includeYouTubeSetting.checked = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Set the URL to the livestreaming dashboard
|
// Set the URL to the livestreaming dashboard
|
||||||
const broadcastButton = youtubeWarning.querySelector('#broadcast-dashboard-button');
|
const broadcastButton = youtubeWarning.querySelector('#broadcast-dashboard-button');
|
||||||
@@ -83,7 +110,7 @@ async function GeneralCustom(data) {
|
|||||||
const childDivs = broadcastList.querySelectorAll(":scope > div");
|
const childDivs = broadcastList.querySelectorAll(":scope > div");
|
||||||
childDivs.forEach(childDiv => {
|
childDivs.forEach(childDiv => {
|
||||||
var result = data.broadcastList.find(obj => {
|
var result = data.broadcastList.find(obj => {
|
||||||
return obj.id === childDiv.id
|
return `id-${obj.id}` === childDiv.id;
|
||||||
})
|
})
|
||||||
if (result == null)
|
if (result == null)
|
||||||
childDiv.remove();
|
childDiv.remove();
|
||||||
@@ -93,17 +120,58 @@ async function GeneralCustom(data) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function YouTubeBroadcastStarted(data) {
|
||||||
|
if (!includeYouTubeSetting.checked)
|
||||||
|
return;
|
||||||
|
|
||||||
|
setTimeout(async () => {
|
||||||
|
await window.parent.sbClient.doAction(
|
||||||
|
action = {
|
||||||
|
id: sbActionUpdateStreamInfo
|
||||||
|
},
|
||||||
|
args = {
|
||||||
|
platform: 'youtube',
|
||||||
|
title: youtubeTitleOnBroadcastStart,
|
||||||
|
broadcastId: data.id
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
async function FetchBroadcasts() {
|
async function FetchBroadcasts() {
|
||||||
// Fetch from Streamer.bot
|
// Fetch from Streamer.bot
|
||||||
const response = await window.parent.sbClient.doAction({ id: sbActionFetchBroadcasts});
|
const response = await window.parent.sbClient.doAction({ id: sbActionFetchBroadcasts});
|
||||||
runningActionId = response.args.runningActionId;
|
runningActionId = response.args.runningActionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function FetchKickInfo() {
|
||||||
|
// Fetch from Streamer.bot
|
||||||
|
const broadcasterInfo = await window.parent.sbClient.getBroadcaster();
|
||||||
|
|
||||||
|
if (broadcasterInfo.platforms.kick) {
|
||||||
|
const userLogin = broadcasterInfo.platforms.kick.broadcasterLogin;
|
||||||
|
|
||||||
|
let kickData = {
|
||||||
|
platform: 'kick',
|
||||||
|
id: 'kick',
|
||||||
|
streamUrl: `https://www.kick.com/${userLogin.replaceAll('_', '-')}`,
|
||||||
|
dashboardUrl: 'https://dashboard.kick.com/stream',
|
||||||
|
userLogin: userLogin
|
||||||
|
}
|
||||||
|
AddBroadcast(kickData);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const kickBroadcastDiv = document.getElementById('id-kick');
|
||||||
|
if (kickBroadcastDiv)
|
||||||
|
kickBroadcastDiv.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function AddBroadcast(data) {
|
async function AddBroadcast(data) {
|
||||||
// Get a reference to the template
|
// Get a reference to the template
|
||||||
const template = document.getElementById('broadcast-template');
|
const template = document.getElementById('broadcast-template');
|
||||||
|
|
||||||
const existingDiv = broadcastList.querySelector(`#${data.id}`);
|
const existingDiv = broadcastList.querySelector(`#id-${data.id}`);
|
||||||
|
|
||||||
// Create a new instance of the template
|
// Create a new instance of the template
|
||||||
let instance;
|
let instance;
|
||||||
@@ -112,7 +180,7 @@ async function AddBroadcast(data) {
|
|||||||
instance = existingDiv;
|
instance = existingDiv;
|
||||||
else {
|
else {
|
||||||
instance = template.content.firstElementChild.cloneNode(true);
|
instance = template.content.firstElementChild.cloneNode(true);
|
||||||
instance.id = data.id;
|
instance.id = `id-${data.id}`;
|
||||||
broadcastList.appendChild(instance);
|
broadcastList.appendChild(instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,6 +352,18 @@ async function UpdateAllSubmit() {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Set the YouTube title for next broadcast start
|
||||||
|
if (includeYouTubeSetting.checked)
|
||||||
|
{
|
||||||
|
youtubeTitleOnBroadcastStart = document.getElementById('all-title-input').value;
|
||||||
|
if (youtubeTitleOnBroadcastStart)
|
||||||
|
youtubeTitleOnBroadcastStartLabel.textContent = `Title will be set to '${youtubeTitleOnBroadcastStart}' when broadcast starts.`;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
youtubeTitleOnBroadcastStart = '';
|
||||||
|
youtubeTitleOnBroadcastStartLabel.textContent = '';
|
||||||
|
}
|
||||||
|
|
||||||
CloseUpdateAllDialog();
|
CloseUpdateAllDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -543,4 +623,4 @@ ValidateYouTubeDialog();
|
|||||||
// REFRESH BROADCAST LIST //
|
// REFRESH BROADCAST LIST //
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
|
|
||||||
setInterval(FetchBroadcasts, 5000);
|
setInterval(FetchKickInfo, 5000);
|
||||||
@@ -69,6 +69,13 @@ button {
|
|||||||
color: yellow;
|
color: yellow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.setting {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
#kick-warning {
|
#kick-warning {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<link rel="stylesheet" href="../.common/styles/global.css" />
|
<link rel="stylesheet" href="../.common/styles/global.css" />
|
||||||
<link rel="icon" href="../../.resources/logo.png" type="image/png">
|
<link rel="icon" href="../../.common/resources/logo.png" type="image/png">
|
||||||
<title>nutty</title>
|
<title>nutty</title>
|
||||||
<style>
|
<style>
|
||||||
#dock-wrapper {
|
#dock-wrapper {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<link rel="icon" href="../../.resources/logo.png" type="image/png">
|
<link rel="icon" href="../../.common/resources/logo.png" type="image/png">
|
||||||
<title>nutty</title>
|
<title>nutty</title>
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
const widgetContainer = document.getElementById('widgetContainer');
|
const widgetContainer = document.getElementById('widgetContainer');
|
||||||
|
|
||||||
const settingsPageURL = '../../.utilities/settings-page-builder';
|
const settingsPageURL = '../../.common/core/settings-core';
|
||||||
|
|
||||||
const currentURL = window.location.href;
|
const currentURL = window.location.href;
|
||||||
|
|
||||||
|
|||||||
@@ -73,4 +73,5 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<script src="../../../.common/utils/helpers.js"></script>
|
||||||
<script src="script.js"></script>
|
<script src="script.js"></script>
|
||||||
@@ -3,7 +3,6 @@
|
|||||||
//////////////////////
|
//////////////////////
|
||||||
|
|
||||||
const sbActionPrintRoutine = '5c756513-a1d0-4285-9dbc-21ad34491310';
|
const sbActionPrintRoutine = '5c756513-a1d0-4285-9dbc-21ad34491310';
|
||||||
const avatarMap = new Map();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -582,45 +581,6 @@ async function CustomEvent(data) {
|
|||||||
// HELPER FUNCTIONS //
|
// HELPER FUNCTIONS //
|
||||||
//////////////////////
|
//////////////////////
|
||||||
|
|
||||||
async function GetAvatar(username, platform) {
|
|
||||||
|
|
||||||
// First, check if the username is hashed already
|
|
||||||
if (avatarMap.has(`${username}-${platform}`)) {
|
|
||||||
console.debug(`Avatar found for ${username} (${platform}). Retrieving from hash map.`)
|
|
||||||
return avatarMap.get(`${username}-${platform}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If code reaches this point, the username hasn't been hashed, so retrieve avatar
|
|
||||||
switch (platform) {
|
|
||||||
case 'twitch':
|
|
||||||
{
|
|
||||||
console.debug(`No avatar found for ${username} (${platform}). Retrieving from Decapi.`)
|
|
||||||
let response = await fetch('https://decapi.me/twitch/avatar/' + username);
|
|
||||||
let data = await response.text();
|
|
||||||
avatarMap.set(`${username}-${platform}`, data);
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
case 'kick':
|
|
||||||
{
|
|
||||||
console.debug(`No avatar found for ${username} (${platform}). Retrieving from Kick.`)
|
|
||||||
try {
|
|
||||||
let response = await fetch('https://kick.com/api/v2/channels/' + username);
|
|
||||||
console.log('https://kick.com/api/v2/channels/' + username)
|
|
||||||
let data = await response.json();
|
|
||||||
let avatarURL = data.user.profile_pic;
|
|
||||||
if (!avatarURL)
|
|
||||||
avatarURL = 'https://kick.com/img/default-profile-pictures/default2.jpeg';
|
|
||||||
avatarMap.set(`${username}-${platform}`, avatarURL);
|
|
||||||
return avatarURL;
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
console.debug(error);
|
|
||||||
return 'https://kick.com/img/default-profile-pictures/default2.jpeg';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function GetRenderedHTML(fragment) {
|
async function GetRenderedHTML(fragment) {
|
||||||
if (!(fragment instanceof DocumentFragment)) {
|
if (!(fragment instanceof DocumentFragment)) {
|
||||||
throw new Error('Argument must be a DocumentFragment');
|
throw new Error('Argument must be a DocumentFragment');
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<link rel="stylesheet" href="../.common/styles/global.css" />
|
<link rel="stylesheet" href="../.common/styles/global.css" />
|
||||||
<link rel="icon" href="../../.resources/logo.png" type="image/png">
|
<link rel="icon" href="../../.common/resources/logo.png" type="image/png">
|
||||||
<title>nutty</title>
|
<title>nutty</title>
|
||||||
<style>
|
<style>
|
||||||
#dock-wrapper {
|
#dock-wrapper {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<link rel="icon" href="../../.resources/logo.png" type="image/png">
|
<link rel="icon" href="../../.common/resources/logo.png" type="image/png">
|
||||||
<title>nutty</title>
|
<title>nutty</title>
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
const widgetContainer = document.getElementById('widgetContainer');
|
const widgetContainer = document.getElementById('widgetContainer');
|
||||||
|
|
||||||
const settingsPageURL = '../../.utilities/settings-page-builder';
|
const settingsPageURL = '../../.common/core/settings-core';
|
||||||
|
|
||||||
const currentURL = window.location.href;
|
const currentURL = window.location.href;
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<link rel="icon" href="../../.resources/logo.png" type="image/png">
|
<link rel="icon" href="../../.common/resources/logo.png" type="image/png">
|
||||||
<title>nutty</title>
|
<title>nutty</title>
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
const widgetContainer = document.getElementById('widgetContainer');
|
const widgetContainer = document.getElementById('widgetContainer');
|
||||||
|
|
||||||
const settingsPageURL = '../../.utilities/settings-page-builder';
|
const settingsPageURL = '../../.common/core/settings-core';
|
||||||
|
|
||||||
const currentURL = window.location.href;
|
const currentURL = window.location.href;
|
||||||
|
|
||||||
|
|||||||
@@ -25,4 +25,5 @@
|
|||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
<script src="../.common/utils/helpers.js"></script>
|
||||||
<script src="./script.js"></script>
|
<script src="./script.js"></script>
|
||||||
@@ -147,7 +147,7 @@ client.on('Twitch.UpcomingAd', (response) => {
|
|||||||
|
|
||||||
function TwitchAdRun(data) {
|
function TwitchAdRun(data) {
|
||||||
const duration = data.length_seconds;
|
const duration = data.length_seconds;
|
||||||
|
|
||||||
// Unset the upcoming ad countdown warning
|
// Unset the upcoming ad countdown warning
|
||||||
upcomingAdWarningStartDelay = null;
|
upcomingAdWarningStartDelay = null;
|
||||||
|
|
||||||
@@ -160,8 +160,7 @@ function TwitchAdRun(data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function TwitchUpcomingAd(data) {
|
function TwitchUpcomingAd(data) {
|
||||||
if (upcomingAdWarningStartDelay != null)
|
if (upcomingAdWarningStartDelay != null) {
|
||||||
{
|
|
||||||
console.debug('Countdown already started, skipping...');
|
console.debug('Countdown already started, skipping...');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -269,7 +268,7 @@ function TimerLabelAnimation(duration) {
|
|||||||
function UpcomingAdWarning(warningSeconds) {
|
function UpcomingAdWarning(warningSeconds) {
|
||||||
if (!showUpcomingAdWarning)
|
if (!showUpcomingAdWarning)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Check if the widget is in the middle of an animation
|
// Check if the widget is in the middle of an animation
|
||||||
if (upcomingAdWarningLocked)
|
if (upcomingAdWarningLocked)
|
||||||
return;
|
return;
|
||||||
@@ -307,44 +306,6 @@ function UpcomingAdWarning(warningSeconds) {
|
|||||||
// HELPER FUNCTIONS //
|
// HELPER FUNCTIONS //
|
||||||
//////////////////////
|
//////////////////////
|
||||||
|
|
||||||
function GetBooleanParam(paramName, defaultValue) {
|
|
||||||
const urlParams = new URLSearchParams(window.location.search);
|
|
||||||
const paramValue = urlParams.get(paramName);
|
|
||||||
|
|
||||||
if (paramValue === null) {
|
|
||||||
return defaultValue; // Parameter not found
|
|
||||||
}
|
|
||||||
|
|
||||||
const lowercaseValue = paramValue.toLowerCase(); // Handle case-insensitivity
|
|
||||||
|
|
||||||
if (lowercaseValue === 'true') {
|
|
||||||
return true;
|
|
||||||
} else if (lowercaseValue === 'false') {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return paramValue; // Return original string if not 'true' or 'false'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function GetIntParam(paramName, defaultValue) {
|
|
||||||
const urlParams = new URLSearchParams(window.location.search);
|
|
||||||
const paramValue = urlParams.get(paramName);
|
|
||||||
|
|
||||||
if (paramValue === null) {
|
|
||||||
return defaultValue; // or undefined, or a default value, depending on your needs
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(paramValue);
|
|
||||||
|
|
||||||
const intValue = parseInt(paramValue, 10); // Parse as base 10 integer
|
|
||||||
|
|
||||||
if (isNaN(intValue)) {
|
|
||||||
return null; // or handle the error in another way, e.g., throw an error
|
|
||||||
}
|
|
||||||
|
|
||||||
return intValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
String.prototype.toHHMMSS = function () {
|
String.prototype.toHHMMSS = function () {
|
||||||
var sec_num = parseInt(this, 10); // don't forget the second param
|
var sec_num = parseInt(this, 10); // don't forget the second param
|
||||||
var hours = Math.floor(sec_num / 3600);
|
var hours = Math.floor(sec_num / 3600);
|
||||||
@@ -358,24 +319,20 @@ String.prototype.toHHMMSS = function () {
|
|||||||
return minutes + ':' + seconds;
|
return minutes + ':' + seconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
function IsNullOrWhitespace(str) {
|
|
||||||
return /^\s*$/.test(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatTime(seconds) {
|
function formatTime(seconds) {
|
||||||
seconds = Math.floor(seconds); // Round down to nearest whole second
|
seconds = Math.floor(seconds); // Round down to nearest whole second
|
||||||
|
|
||||||
if (seconds < 60) {
|
if (seconds < 60) {
|
||||||
return `${seconds}`;
|
return `${seconds}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const mins = Math.floor(seconds / 60);
|
const mins = Math.floor(seconds / 60);
|
||||||
const secs = seconds % 60;
|
const secs = seconds % 60;
|
||||||
|
|
||||||
// Pad seconds with a leading zero if less than 10
|
// Pad seconds with a leading zero if less than 10
|
||||||
const paddedSecs = secs.toString().padStart(2, '0');
|
const paddedSecs = secs.toString().padStart(2, '0');
|
||||||
|
|
||||||
return `${mins}:${paddedSecs}`;
|
return `${mins}:${paddedSecs}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////
|
////////////////////
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<link rel="icon" href="../../.resources/logo.png" type="image/png">
|
<link rel="icon" href="../../.common/resources/logo.png" type="image/png">
|
||||||
<title>nutty</title>
|
<title>nutty</title>
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
const widgetContainer = document.getElementById('widgetContainer');
|
const widgetContainer = document.getElementById('widgetContainer');
|
||||||
|
|
||||||
const settingsPageURL = '../../.utilities/settings-page-builder';
|
const settingsPageURL = '../../.common/core/settings-core';
|
||||||
|
|
||||||
const currentURL = window.location.href;
|
const currentURL = window.location.href;
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<link rel="icon" href="../../.resources/logo.png" type="image/png">
|
<link rel="icon" href="../../.common/resources/logo.png" type="image/png">
|
||||||
<title>nutty</title>
|
<title>nutty</title>
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
const widgetContainer = document.getElementById('widgetContainer');
|
const widgetContainer = document.getElementById('widgetContainer');
|
||||||
|
|
||||||
const settingsPageURL = '../../.utilities/settings-page-builder';
|
const settingsPageURL = '../../.common/core/settings-core';
|
||||||
|
|
||||||
const currentURL = window.location.href;
|
const currentURL = window.location.href;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user