Auto Click Chatbox

This script automatically clicks the "Message Input" button on the sidebar, on kick.com.

当前为 2023-11-15 提交的版本,查看 最新版本

  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.0
  7. // @license MIT
  8. // @author Trilla_G
  9. // @description This script automatically clicks the "Message Input" button on the sidebar, on kick.com.
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. function clickMessageInput() {
  16. var messageInputButton = document.querySelector('#message-input');
  17. if (messageInputButton) {
  18. var clickEvent = document.createEvent('MouseEvents');
  19. clickEvent.initEvent('click', true, true);
  20. messageInputButton.dispatchEvent(clickEvent);
  21. }
  22. }
  23.  
  24. // Create a MutationObserver to retrigger on hashchange
  25. const observer = new MutationObserver(() => {
  26. console.log('Hashchange event detected. Retriggering script.');
  27. clickMessageInput();
  28. });
  29.  
  30. // Configure and start observing changes to the URL hash
  31. const config = { childList: true, subtree: true };
  32. observer.observe(document.body, config);
  33.  
  34. // Initial click and observe hashchange
  35. setTimeout(function() {
  36. clickMessageInput();
  37. }, 2000);
  38. })();