mirror of
https://github.com/nuttylmao/nutty.gg.git
synced 2026-09-18 19:50:58 -04:00
Added Patreon support
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
@@ -45,6 +45,7 @@ const showYouTubeMemberships = GetBooleanParam("showYouTubeMemberships", true);
|
||||
|
||||
const showStreamlabsDonations = GetBooleanParam("showStreamlabsDonations", true)
|
||||
const showStreamElementsTips = GetBooleanParam("showStreamElementsTips", true);
|
||||
const showPatreonMemberships = GetBooleanParam("showPatreonMemberships", true);
|
||||
|
||||
// Set fonts for the widget
|
||||
document.body.style.fontFamily = font;
|
||||
@@ -198,6 +199,11 @@ client.on('StreamElements.Tip', (response) => {
|
||||
StreamElementsTip(response.data);
|
||||
})
|
||||
|
||||
client.on('Patreon.PledgeCreated', (response) => {
|
||||
console.debug(response.data);
|
||||
PatreonPledgeCreated(response.data);
|
||||
})
|
||||
|
||||
|
||||
|
||||
///////////////////////
|
||||
@@ -213,7 +219,7 @@ async function TwitchChatMessage(data) {
|
||||
return;
|
||||
|
||||
// Don't post messages from users from the ignore list
|
||||
if (ignoreUserList.includes(data.message.username))
|
||||
if (ignoreUserList.includes(data.message.username.toLowerCase()))
|
||||
return;
|
||||
|
||||
// Get a reference to the template
|
||||
@@ -783,7 +789,7 @@ function YouTubeMessage(data) {
|
||||
return;
|
||||
|
||||
// Don't post messages from users from the ignore list
|
||||
if (ignoreUserList.includes(data.user.name))
|
||||
if (ignoreUserList.includes(data.user.name.toLowerCase()))
|
||||
return;
|
||||
|
||||
// Get a reference to the template
|
||||
@@ -1097,6 +1103,37 @@ async function StreamElementsTip(data) {
|
||||
AddMessageItem(instance, data.id);
|
||||
}
|
||||
|
||||
function PatreonPledgeCreated(data) {
|
||||
if (!showPatreonMemberships)
|
||||
return;
|
||||
|
||||
// Get a reference to the template
|
||||
const template = document.getElementById('cardTemplate');
|
||||
|
||||
// Create a new instance of the template
|
||||
const instance = template.content.cloneNode(true);
|
||||
|
||||
// Get divs
|
||||
const cardDiv = instance.querySelector("#card");
|
||||
const headerDiv = instance.querySelector("#header");
|
||||
const avatarDiv = instance.querySelector("#avatar");
|
||||
const iconDiv = instance.querySelector("#icon");
|
||||
const titleDiv = instance.querySelector("#title");
|
||||
const contentDiv = instance.querySelector("#content");
|
||||
|
||||
// Set the card background colors
|
||||
cardDiv.classList.add('patreon');
|
||||
|
||||
// Set the text
|
||||
const user = data.attributes.full_name;
|
||||
const amount = (data.attributes.will_pay_amount_cents/100).toFixed(2);
|
||||
const patreonIcon = `<img src="icons/platforms/patreon.png" class="platform"/>`;
|
||||
|
||||
titleDiv.innerHTML = `${patreonIcon} ${user} joined Patreon ($${amount})`;
|
||||
|
||||
AddMessageItem(instance, data.id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////////
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
let settingsContainer = document.getElementById('settings-container');
|
||||
settingsContainer.src = `https://widgets.nutty.gg/widget-customizer?settingsJson=${window.location.href}/settings.json`
|
||||
settingsContainer.src = `../../widget-customizer?settingsJson=${window.location.href}/settings.json`
|
||||
console.log(settingsContainer.src);
|
||||
|
||||
function reloadWidget(data) {
|
||||
|
||||
@@ -269,6 +269,14 @@
|
||||
"defaultValue": true,
|
||||
"group": "Which donation messages do you want to see?"
|
||||
},
|
||||
{
|
||||
"id": "showPatreonMemberships",
|
||||
"label": "Patreon Memberships",
|
||||
"description": "",
|
||||
"type": "checkbox",
|
||||
"defaultValue": true,
|
||||
"group": "Which donation messages do you want to see?"
|
||||
},
|
||||
{
|
||||
"id": "address",
|
||||
"label": "Address",
|
||||
|
||||
@@ -207,6 +207,10 @@ li {
|
||||
background: linear-gradient(#263b8abf, #0a112abf) !important;
|
||||
}
|
||||
|
||||
.patreon {
|
||||
background: linear-gradient(#c76633, #fd5e0a) !important;
|
||||
}
|
||||
|
||||
/****************/
|
||||
/** ANIMATIONS **/
|
||||
/****************/
|
||||
|
||||
Reference in New Issue
Block a user