From 843d0828fe5b3ed3564cfe62d64ba67cf6fed3d5 Mon Sep 17 00:00:00 2001 From: nuttylmao <76841561+nuttylmao@users.noreply.github.com> Date: Mon, 22 Sep 2025 04:39:50 +1000 Subject: [PATCH] Revert "TikTok Like Events not updating properly" --- multichat-overlay/script.js | 62 +++++++++++++------------------------ 1 file changed, 21 insertions(+), 41 deletions(-) diff --git a/multichat-overlay/script.js b/multichat-overlay/script.js index ab79cbc..6779df8 100644 --- a/multichat-overlay/script.js +++ b/multichat-overlay/script.js @@ -2725,62 +2725,42 @@ function TikTokLikes(data) { // Get the total number of likes - let likeCount = parseInt(data.likeCount); + var likeCountTotal = parseInt(data.likeCount); // Search for Previous Likes from the Same User - const previousLikeContainer = document.querySelector(`.likes[data-user-identifier="${data.userId}"]`); + const previousLikeContainer = document.querySelector(`li[data-user-id="${data.userId}"]`); // If found, fetches the previous likes, deletes the element // and then creates a new count with a sum of the like count if (previousLikeContainer) { const likeCountElem = previousLikeContainer.querySelector('#tiktok-gift-repeat-count'); if (likeCountElem) { - const liLikeContainer = previousLikeContainer.parentElement?.parentElement - if (liLikeContainer) { - - let prevLikeCount = parseInt(likeCountElem.textContent.replace('x', ''), 10); - let likeCountUpdate = Math.floor(prevLikeCount + likeCount); - let likeCountDiv = previousLikeContainer.querySelector('#tiktok-gift-repeat-count'); - - likeCountDiv.innerText = `x${likeCountUpdate}`; - - const parent = liLikeContainer.parentElement; - if (parent) { parent.appendChild(liLikeContainer); } - } + var likeCountPrev = parseInt(likeCountElem.textContent.replace('x', '')); + likeCountTotal = Math.floor(likeCountPrev + likeCountTotal); + previousLikeContainer.remove(); } } - else { - // Get a reference to the template - const template = document.getElementById('tiktok-gift-template'); + // Get a reference to the template + const template = document.getElementById('tiktok-gift-template'); - // Create a new instance of the template - const instance = template.content.cloneNode(true); - - // gets the GiftElement - const giftElement = instance.querySelector('.tiktok-gift'); + // Create a new instance of the template + const instance = template.content.cloneNode(true); - // adds the like class - giftElement.classList.add('likes'); + // Get divs + const avatarImg = instance.querySelector('.tiktok-gift-avatar'); + const usernameSpan = instance.querySelector('#tiktok-gift-username'); + const giftNameSpan = instance.querySelector('#tiktok-gift-name'); + const stickerImg = instance.querySelector('.tiktok-gift-sticker'); + const repeatCountDiv = instance.querySelector('#tiktok-gift-repeat-count'); - // and assigns the user id - giftElement.dataset.userIdentifier = data.userId; + avatarImg.src = data.profilePictureUrl; + usernameSpan.innerText = data.nickname; + giftNameSpan.innerText = 'Likes'; + stickerImg.src = ''; + repeatCountDiv.innerText = `x${likeCountTotal}`; - // Get divs - const avatarImg = instance.querySelector('.tiktok-gift-avatar'); - const usernameSpan = instance.querySelector('#tiktok-gift-username'); - const giftNameSpan = instance.querySelector('#tiktok-gift-name'); - const stickerImg = instance.querySelector('.tiktok-gift-sticker'); - const repeatCountDiv = instance.querySelector('#tiktok-gift-repeat-count'); - - avatarImg.src = data.profilePictureUrl; - usernameSpan.innerText = data.nickname; - giftNameSpan.innerText = 'Likes'; - stickerImg.src = ''; - repeatCountDiv.innerText = `x${likeCount}`; - - AddMessageItem(instance, data.msgId, 'tiktok', data.userId); - } + AddMessageItem(instance, data.msgId, 'tiktok', data.userId); } function TikTokGift(data) {