Kick.com Unique Chatter Counter

Kick.com Unique Chatter Counter - Detect whos viewbotting

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

  1. // ==UserScript==
  2. // @name Kick.com Unique Chatter Counter
  3. // @version 0.1
  4. // namespace RishiSunakDiscord
  5. // @description Kick.com Unique Chatter Counter - Detect whos viewbotting
  6. // @author Rishi Sunak
  7. // @match https://kick.com/*
  8. // @grant none
  9. // @namespace https://greasyfork.org/users/1235079
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // Use an object to store unique user IDs
  16. let uniqueUserIds = {};
  17.  
  18. // Variable to store the current stream src
  19. let currentStreamSrc = null;
  20.  
  21. // Function to count unique user IDs
  22. function countUniqueUserIds() {
  23. const userIdElements = document.querySelectorAll('[data-chat-entry-user-id]');
  24.  
  25. userIdElements.forEach(element => {
  26. const userId = element.getAttribute('data-chat-entry-user-id');
  27. uniqueUserIds[userId] = true;
  28. });
  29.  
  30. const uniqueUserCount = Object.keys(uniqueUserIds).length;
  31. console.log(`Unique User IDs: ${uniqueUserCount}`);
  32.  
  33. // Update the text content of the element with the class "text-base font-bold"
  34. const chatHeaderElement = document.querySelector('.flex.flex-row.items-center.text-center .text-base.font-bold');
  35. if (chatHeaderElement) {
  36. chatHeaderElement.textContent = `Unique Chatters: ${uniqueUserCount}`;
  37. }
  38. }
  39.  
  40. // Function to check if the stream has changed
  41. function checkStreamChange() {
  42. const videoElement = document.querySelector('video.vjs-tech');
  43. if (videoElement) {
  44. const newStreamSrc = videoElement.getAttribute('src');
  45. if (newStreamSrc !== currentStreamSrc) {
  46. // Reset uniqueUserIds and update currentStreamSrc
  47. uniqueUserIds = {};
  48. currentStreamSrc = newStreamSrc;
  49. }
  50. }
  51. }
  52.  
  53. // Run the initial checks
  54. countUniqueUserIds();
  55. checkStreamChange();
  56.  
  57. // Use MutationObserver to watch for changes in the DOM (new chat entries and stream changes)
  58. const observer = new MutationObserver(() => {
  59. countUniqueUserIds();
  60. checkStreamChange();
  61. });
  62.  
  63. // Specify the target node and configuration for the observer
  64. const targetNode = document.body;
  65. const config = { childList: true, subtree: true };
  66.  
  67. // Start observing the target node for changes in the DOM
  68. observer.observe(targetNode, config);
  69.  
  70. })();