Auto Click Chatbox

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

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

  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 "Chat" button and "Message Input" on the sidebar, on kick.com.
  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 clickChatAndMessageInput() {
  21. let chatButton = document.querySelector('#chat-button');
  22. let messageInputButton = document.querySelector('#message-input');
  23.  
  24. if (isLive()) {
  25. if (messageInputButton) {
  26. messageInputButton.click();
  27. }
  28. } else {
  29. if (chatButton) {
  30. chatButton.click();
  31. }
  32. if (messageInputButton) {
  33. messageInputButton.click();
  34. }
  35. }
  36. }
  37.  
  38. // Create a MutationObserver to retrigger on hashchange
  39. const observer = new MutationObserver(() => {
  40. console.log('Hashchange event detected. Retriggering script.');
  41. clickChatAndMessageInput();
  42. });
  43.  
  44. // Configure and start observing changes to the URL hash
  45. const config = { childList: true, subtree: true };
  46. observer.observe(document.body, config);
  47.  
  48. // Initial click and observe hashchange
  49. setTimeout(function() {
  50. clickChatAndMessageInput();
  51. }, 1000);
  52. })();