Ability to Chat on TikTok Enabled

This commit is contained in:
Rodrigo Emanuel
2025-05-30 16:05:49 -03:00
committed by GitHub
parent 0f21d31476
commit 008aa10318
8 changed files with 550 additions and 299 deletions

View File

@@ -416,14 +416,29 @@ chatInputForm.addEventListener("submit", function(event) {
var chatSendPlatforms = [];
if (showTwitchMessages == true) {
const chatOnTwitch = document.querySelector('#chat-input #twitch input[type=checkbox]').checked;
const chatOnYoutube = document.querySelector('#chat-input #youtube input[type=checkbox]').checked;
const chatOnTiktok = document.querySelector('#chat-input #tiktok input[type=checkbox]').checked;
const chatOnKick = document.querySelector('#chat-input #kick input[type=checkbox]').checked;
console.log(chatOnTwitch,chatOnYoutube,chatOnTiktok,chatOnKick);
if (chatOnTwitch == true) {
chatSendPlatforms.push('twitch');
}
if (showYouTubeMessages == true) {
if (chatOnYoutube == true) {
chatSendPlatforms.push('youtube');
}
if (chatOnTiktok == true) {
chatSendPlatforms.push('tiktok');
}
if (chatOnKick == true) {
chatSendPlatforms.push('kick');
}
chatSendPlatforms = chatSendPlatforms.join(',')
const chatInput = chatInputForm.querySelector("input[type=text]")
@@ -441,19 +456,31 @@ chatInputForm.addEventListener("submit", function(event) {
console.debug('Sending Chat to Streamer.Bot', sendchatstuff);
});
if (showKickMessages == true) {
// Sends Message to Kick that are not commands
if (chatSendPlatforms.includes('kick')) {
if (!chatInputText.startsWith('/')) {
streamerBotClient.doAction(
{ name : "ChatRD Kick Messages" },
{
"message": chatInputText,
}
).then( (sendchatstuff) => {
console.debug('Sending Kick Chat to Streamer.Bot', sendchatstuff);
});
// Sends Message to Kick that are not commands
if (chatSendPlatforms.includes('kick')) {
if (!chatInputText.startsWith('/')) {
streamerBotClient.doAction(
{ name : "ChatRD Kick Messages" },
{
"message": chatInputText,
}
).then( (sendchatstuff) => {
console.debug('Sending Kick Chat to Streamer.Bot', sendchatstuff);
});
}
}
// Sends Message to TikTok that are not commands
if (chatSendPlatforms.includes('tiktok')) {
if (!chatInputText.startsWith('/')) {
streamerBotClient.doAction(
{ name : "ChatRD TikTok Messages" },
{
"ttkmessage": chatInputText,
}
).then( (sendchatstuff) => {
console.debug('Sending TikTok Chat to Streamer.Bot', sendchatstuff);
});
}
}
@@ -587,4 +614,37 @@ document.addEventListener('click', function (e) {
if (e.target !== chatcommandslist) {
chatcommandslist.innerHTML = '';
}
});
document.addEventListener("DOMContentLoaded", function () {
const settingsPanel = document.querySelector('#chat-input .settings');
chatSettings.addEventListener('click', function () {
settingsPanel.classList.toggle('active');
chatSettings.classList.toggle('active');
});
const checkboxNames = ["chatOnTwitch", "chatOnYouTube", "chatOnTiktok", "chatOnKick"];
// Restore checkbox states from localStorage
checkboxNames.forEach(name => {
const checkbox = document.querySelector(`input[name="${name}"]`);
const savedValue = localStorage.getItem(name);
if (checkbox && savedValue !== null) {
checkbox.checked = savedValue === "true";
}
});
// Save state to localStorage on change
checkboxNames.forEach(name => {
const checkbox = document.querySelector(`input[name="${name}"]`);
if (checkbox) {
checkbox.addEventListener("change", function () {
localStorage.setItem(name, checkbox.checked);
});
}
});
});

View File

@@ -2,7 +2,7 @@ const showPatreonMemberships = getURLParam("showPatreonMemberships", true
const patreonHandlers = {
'Patreon.PledgeCreated': (response) => {
console.debug('Patreon Membersihp', response.data);
console.debug('Patreon Membership', response.data);
patreonMemberships(response.data);
},
};

View File

@@ -354,38 +354,99 @@ async function populateEmoteList() {
const accordionButtons = document.querySelectorAll("button.accordion");
accordionButtons.forEach(button => {
button.addEventListener("click", () => {
const targetId = button.getAttribute("data-target");
const target = document.getElementById(targetId);
const icon = button.querySelector("i");
if (!target || !target.classList.contains("accordion-container")) return;
const isOpen = target.classList.contains("open");
// Fecha todos os outros accordions
document.querySelectorAll(".accordion-container.open").forEach(container => {
if (container !== target) {
container.classList.remove("open");
container.style.maxHeight = null;
const otherButton = document.querySelector(`button.accordion[data-target="${container.id}"]`);
if (otherButton) {
const otherIcon = otherButton.querySelector("i");
if (otherIcon) otherIcon.className = "fa-solid fa-chevron-down";
}
}
});
// Alterna o atual
if (!isOpen) {
target.classList.add("open");
target.style.maxHeight = target.scrollHeight + "px";
if (icon) icon.className = "fa-solid fa-chevron-up";
// Espera a animação terminar para scrollar
target.addEventListener("transitionend", function handler(e) {
if (e.propertyName === "max-height") {
target.removeEventListener("transitionend", handler);
const offset = target.getBoundingClientRect().top + window.scrollY - 60;
window.scrollTo({
top: offset,
behavior: "smooth"
});
}
});
}
else {
target.classList.remove("open");
target.style.maxHeight = null;
if (icon) icon.className = "fa-solid fa-chevron-down";
}
});
});
window.addEventListener('load', () => {
loadSettingsFromLocalStorage();
generateUrl();
pushChangeEvents();
populateEmoteList();
});
document.querySelectorAll('.nav-bar a').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
document.querySelectorAll('.nav-bar a').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
// Remove todas as classes dos links dentro da nav-bar
document.querySelectorAll('.nav-bar a').forEach(link => {
link.classList.remove('active');
});
this.classList.add('active');
const targetId = this.getAttribute('href');
const targetElement = document.querySelector(targetId);
if (targetElement) {
const offset = 20; // ajusta 20px acima
const y = targetElement.getBoundingClientRect().top + window.scrollY - offset;
window.scrollTo({
top: y,
behavior: 'smooth'
// Remove todas as classes dos links dentro da nav-bar
document.querySelectorAll('.nav-bar a').forEach(link => {
link.classList.remove('active');
});
}
this.classList.add('active');
const targetId = this.getAttribute('href');
const targetElement = document.querySelector(targetId);
if (targetElement) {
const offset = 60; // ajusta 20px acima
const y = targetElement.getBoundingClientRect().top + window.scrollY - offset;
window.scrollTo({
top: y,
behavior: 'smooth'
});
}
});
});
});
});