Kick.com Unique Chatter Counter

Kick.com Unique Chatter Counter - Detect whos viewbotting

当前为 2023-12-17 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==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);

})();