Like Function FIx

This commit is contained in:
Rodrigo Emanuel
2025-09-11 14:47:21 -03:00
parent bd80e2f50c
commit 1ebfa5a561
+12 -2
View File
@@ -2728,7 +2728,8 @@ function TikTokLikes(data) {
var likeCountTotal = parseInt(data.likeCount); var likeCountTotal = parseInt(data.likeCount);
// Search for Previous Likes from the Same User // Search for Previous Likes from the Same User
const previousLikeContainer = document.querySelector(`li[data-user-id="${data.userId}"]`); //const previousLikeContainer = document.querySelector(`li[data-user-id="${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
@@ -2737,7 +2738,7 @@ function TikTokLikes(data) {
if (likeCountElem) { if (likeCountElem) {
var likeCountPrev = parseInt(likeCountElem.textContent.replace('x', '')); var likeCountPrev = parseInt(likeCountElem.textContent.replace('x', ''));
likeCountTotal = Math.floor(likeCountPrev + likeCountTotal); likeCountTotal = Math.floor(likeCountPrev + likeCountTotal);
previousLikeContainer.remove(); previousLikeContainer.parentElement.parentElement.remove();
} }
} }
@@ -2746,6 +2747,15 @@ function TikTokLikes(data) {
// Create a new instance of the template // Create a new instance of the template
const instance = template.content.cloneNode(true); const instance = template.content.cloneNode(true);
// gets the GiftElement
const giftElement = instance.querySelector('.tiktok-gift');
// adds the like class
giftElement.classList.add('likes');
// and assigns the user id
giftElement.dataset.userIdentifier = data.userId;
// Get divs // Get divs
const avatarImg = instance.querySelector('.tiktok-gift-avatar'); const avatarImg = instance.querySelector('.tiktok-gift-avatar');