mirror of
https://github.com/nuttylmao/nutty.gg.git
synced 2026-09-19 04:00:59 -04:00
Update script.js
This commit is contained in:
+34
-28
@@ -2725,8 +2725,7 @@ function TikTokLikes(data) {
|
|||||||
|
|
||||||
|
|
||||||
// Get the total number of likes
|
// Get the total number of likes
|
||||||
let likeCountTotal = parseInt(data.likeCount);
|
let likeCount = parseInt(data.likeCount);
|
||||||
let sumLikes = 0;
|
|
||||||
|
|
||||||
// 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}"]`);
|
||||||
@@ -2738,43 +2737,50 @@ function TikTokLikes(data) {
|
|||||||
if (likeCountElem) {
|
if (likeCountElem) {
|
||||||
const liLikeContainer = previousLikeContainer.parentElement?.parentElement
|
const liLikeContainer = previousLikeContainer.parentElement?.parentElement
|
||||||
if (liLikeContainer) {
|
if (liLikeContainer) {
|
||||||
var likeCountPrev = parseInt(likeCountElem.textContent.replace('x', ''), 10);
|
|
||||||
sumLikes = Math.floor(likeCountPrev + likeCountTotal);
|
let prevLikeCount = parseInt(likeCountElem.textContent.replace('x', ''), 10);
|
||||||
//console.log(`[User ${data.userId}] likeCountPrev: ${likeCountPrev}, likeCountToAdd: ${likeCountTotal}, sumLikes: ${sumLikes}`);
|
let likeCountUpdate = Math.floor(prevLikeCount + likeCount);
|
||||||
previousLikeContainer.parentElement.parentElement.remove();
|
let likeCountDiv = previousLikeContainer.querySelector('#tiktok-gift-repeat-count');
|
||||||
|
|
||||||
|
likeCountDiv.innerText = `x${likeCountUpdate}`;
|
||||||
|
|
||||||
|
const parent = liLikeContainer.parentElement;
|
||||||
|
if (parent) { parent.appendChild(liLikeContainer); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get a reference to the template
|
else {
|
||||||
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
|
// Create a new instance of the template
|
||||||
const instance = template.content.cloneNode(true);
|
const instance = template.content.cloneNode(true);
|
||||||
|
|
||||||
// gets the GiftElement
|
// gets the GiftElement
|
||||||
const giftElement = instance.querySelector('.tiktok-gift');
|
const giftElement = instance.querySelector('.tiktok-gift');
|
||||||
|
|
||||||
// adds the like class
|
// adds the like class
|
||||||
giftElement.classList.add('likes');
|
giftElement.classList.add('likes');
|
||||||
|
|
||||||
// and assigns the user id
|
// and assigns the user id
|
||||||
giftElement.dataset.userIdentifier = data.userId;
|
giftElement.dataset.userIdentifier = data.userId;
|
||||||
|
|
||||||
// Get divs
|
// Get divs
|
||||||
const avatarImg = instance.querySelector('.tiktok-gift-avatar');
|
const avatarImg = instance.querySelector('.tiktok-gift-avatar');
|
||||||
const usernameSpan = instance.querySelector('#tiktok-gift-username');
|
const usernameSpan = instance.querySelector('#tiktok-gift-username');
|
||||||
const giftNameSpan = instance.querySelector('#tiktok-gift-name');
|
const giftNameSpan = instance.querySelector('#tiktok-gift-name');
|
||||||
const stickerImg = instance.querySelector('.tiktok-gift-sticker');
|
const stickerImg = instance.querySelector('.tiktok-gift-sticker');
|
||||||
const repeatCountDiv = instance.querySelector('#tiktok-gift-repeat-count');
|
const repeatCountDiv = instance.querySelector('#tiktok-gift-repeat-count');
|
||||||
|
|
||||||
avatarImg.src = data.profilePictureUrl;
|
avatarImg.src = data.profilePictureUrl;
|
||||||
usernameSpan.innerText = data.nickname;
|
usernameSpan.innerText = data.nickname;
|
||||||
giftNameSpan.innerText = 'Likes';
|
giftNameSpan.innerText = 'Likes';
|
||||||
stickerImg.src = '';
|
stickerImg.src = '';
|
||||||
repeatCountDiv.innerText = `x${sumLikes}`;
|
repeatCountDiv.innerText = `x${likeCount}`;
|
||||||
|
|
||||||
AddMessageItem(instance, data.msgId, 'tiktok', data.userId);
|
AddMessageItem(instance, data.msgId, 'tiktok', data.userId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function TikTokGift(data) {
|
function TikTokGift(data) {
|
||||||
|
|||||||
Reference in New Issue
Block a user