Auto Click Chatbox

This script automatically clicks the "Message Input" button on the sidebar, on kick.com when the stream is live.

当前为 2024-03-06 提交的版本,查看 最新版本

  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 6.0
  7. // @license MIT
  8. // @author Trilla_G
  9. // @description This script automatically clicks the "Message Input" button on the sidebar, on kick.com when the stream is live.
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. function isLive() {
  16. let liveDisplay = document.querySelector(".vjs-live-control");
  17. return liveDisplay && !liveDisplay.classList.contains('vjs-hidden');
  18. }
  19.  
  20. function clickMessageInput() {
  21. let messageInputButton = document.querySelector('#message-input');
  22. if (isLive() && messageInputButton) {
  23. messageInputButton.click();
  24. }
  25. }
  26.  
  27. // Function to observe URL changes using MutationObserver
  28. const observeUrlChanges = () => {
  29. const observer = new MutationObserver(() => {
  30. const newUrl = window.location.href;
  31. if (newUrl.includes('kick.com')) {
  32. clickMessageInput();
  33. }
  34. });
  35.  
  36. // Start observing changes to the href attribute of the document's body
  37. observer.observe(document.body, { subtree: true, childList: true });
  38.  
  39. // Cleanup observer on page unload
  40. window.addEventListener('beforeunload', () => observer.disconnect());
  41. };
  42.  
  43. // Initial run of the script
  44. setTimeout(clickMessageInput, 1600); // 2-second delay before the initial click
  45.  
  46. // Initial observation of URL changes
  47. observeUrlChanges();
  48. })();