Auto Click Chatbox

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

目前为 2024-01-10 提交的版本。查看 最新版本

  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.1
  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. (function() {
  12. 'use strict';
  13. function isLive() {
  14. let liveDisplay = document.querySelector(".vjs-live-control");
  15. return liveDisplay && !liveDisplay.classList.contains('vjs-hidden');
  16. }
  17. function clickMessageInput() {
  18. let messageInputButton = document.querySelector('#message-input');
  19. if (isLive() && messageInputButton) {
  20. messageInputButton.click();
  21. }
  22. }
  23. // Create a MutationObserver to retrigger on hashchange
  24. const observer = new MutationObserver(() => {
  25. console.log('Hashchange event detected. Retriggering script.');
  26. clickMessageInput();
  27. });
  28. // Configure and start observing changes to the URL hash
  29. const config = { childList: true, subtree: true };
  30. observer.observe(document.body, config);
  31. // Initial click and observe hashchange
  32. setTimeout(function() {
  33. clickMessageInput();
  34. }, 2000);
  35. })();