Kick.com Unique Chatter Counter - Detect whos viewbotting
当前为
// ==UserScript==
// @name Kick.com Unique Chatter Counter
// @version 0.1
// namespace RishiSunakDiscord
// @description Kick.com Unique Chatter Counter - Detect whos viewbotting
// @author Rishi Sunak
// @match https://kick.com/*
// @grant none
// @namespace https://greasyfork.org/users/1235079
// ==/UserScript==
(function() {
'use strict';
// Use an object to store unique user IDs
let uniqueUserIds = {};
// Variable to store the current stream src
let currentStreamSrc = null;
// Function to count unique user IDs
function countUniqueUserIds() {
const userIdElements = document.querySelectorAll('[data-chat-entry-user-id]');
userIdElements.forEach(element => {
const userId = element.getAttribute('data-chat-entry-user-id');
uniqueUserIds[userId] = true;
});
const uniqueUserCount = Object.keys(uniqueUserIds).length;
console.log(`Unique User IDs: ${uniqueUserCount}`);
// Update the text content of the element with the class "text-base font-bold"
const chatHeaderElement = document.querySelector('.flex.flex-row.items-center.text-center .text-base.font-bold');
if (chatHeaderElement) {
chatHeaderElement.textContent = `Unique Chatters: ${uniqueUserCount}`;
}
}
// Function to check if the stream has changed
function checkStreamChange() {
const videoElement = document.querySelector('video.vjs-tech');
if (videoElement) {
const newStreamSrc = videoElement.getAttribute('src');
if (newStreamSrc !== currentStreamSrc) {
// Reset uniqueUserIds and update currentStreamSrc
uniqueUserIds = {};
currentStreamSrc = newStreamSrc;
}
}
}
// Run the initial checks
countUniqueUserIds();
checkStreamChange();
// Use MutationObserver to watch for changes in the DOM (new chat entries and stream changes)
const observer = new MutationObserver(() => {
countUniqueUserIds();
checkStreamChange();
});
// Specify the target node and configuration for the observer
const targetNode = document.body;
const config = { childList: true, subtree: true };
// Start observing the target node for changes in the DOM
observer.observe(targetNode, config);
})();