Kick.com Unique Chatter Counter

Kick.com Unique Chatter Counter - Detect whos viewbotting

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Kick.com Unique Chatter Counter
// @version      0.4
// @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';

    let uniqueUserIds = {};
    let currentStreamSrc = null;

    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}`);

        const chatHeaderElement = document.querySelector('.flex.flex-row.items-center.text-center .text-base.font-bold');
        if (chatHeaderElement) {
            chatHeaderElement.textContent = `Unique Chatters: ${uniqueUserCount}`;
        }
    }

    function checkStreamChange() {
        const videoElement = document.querySelector('video.vjs-tech');
        if (videoElement) {
            const newStreamSrc = videoElement.getAttribute('src');
            if (newStreamSrc !== currentStreamSrc) {
                uniqueUserIds = {};
                currentStreamSrc = newStreamSrc;
            }
        }
    }

    countUniqueUserIds();
    checkStreamChange();

    const observer = new MutationObserver(() => {
        countUniqueUserIds();
        checkStreamChange();
    });

    const targetNode = document.body;
    const config = { childList: true, subtree: true };

    observer.observe(targetNode, config);

})();