Auto Click Chatbox

This script automatically clicks the "Chat" button and "Message Input" on the sidebar, on kick.com. It pauses for 10 seconds after any mouse click.

目前為 2023-11-20 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Auto Click Chatbox
  3. // @namespace https://greasyfork.org/en/users/1200587-trilla-g
  4. // @match *://*.kick.com/*
  5. // @grant none
  6. // @version 1.37
  7. // @license MIT
  8. // @author Trilla_G
  9. // @description This script automatically clicks the "Chat" button and "Message Input" on the sidebar, on kick.com. It pauses for 10 seconds after any mouse click.
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. let clickingEnabled = true; // Variable to control automatic clicking
  16.  
  17. function isLive() {
  18. let liveDisplay = document.querySelector(".vjs-live-control");
  19. return liveDisplay && !liveDisplay.classList.contains('vjs-hidden');
  20. }
  21.  
  22. function clickChatAndMessageInput() {
  23. if (!clickingEnabled) {
  24. return;
  25. }
  26.  
  27. let chatButton = document.querySelector('#chat-button');
  28. let messageInputButton = document.querySelector('#message-input');
  29.  
  30. if (isLive()) {
  31. if (messageInputButton) {
  32. messageInputButton.click();
  33. }
  34. } else {
  35. if (chatButton) {
  36. chatButton.click();
  37. }
  38. if (messageInputButton) {
  39. messageInputButton.click();
  40. }
  41. }
  42. }
  43.  
  44. // Function to handle mouse clicks
  45. function handleMouseClick() {
  46. // Disable automatic clicking
  47. clickingEnabled = false;
  48.  
  49. // Pause the script for 10 seconds
  50. setTimeout(() => {
  51. // Re-enable automatic clicking
  52. clickingEnabled = true;
  53.  
  54. // Restart the script
  55. clickChatAndMessageInput();
  56. }, 10000);
  57. }
  58.  
  59. // Function to handle hashchange events
  60. function handleHashChange() {
  61. // Re-trigger clicking "Message Input" instantly
  62. clickChatAndMessageInput();
  63. }
  64.  
  65. // Create a MutationObserver to retrigger on hashchange
  66. const observer = new MutationObserver(() => {
  67. console.log('Hashchange event detected. Retriggering script.');
  68. handleHashChange();
  69. });
  70.  
  71. // Configure and start observing changes to the URL hash
  72. const config = { childList: true, subtree: true };
  73. observer.observe(document.body, config);
  74.  
  75. // Initial click and observe hashchange
  76. setTimeout(() => {
  77. clickChatAndMessageInput();
  78. }, 1000);
  79.  
  80. // Add event listener for mouse clicks
  81. document.body.addEventListener('mousedown', handleMouseClick);
  82. })();
  83.  
  84.