Auto Click Chatbox

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

当前为 2023-12-29 提交的版本,查看 最新版本

  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 3.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 getPlayer() {
  16. var possibleVideo = document.querySelector('.vjs-tech');
  17. if (!possibleVideo || possibleVideo.nodeName !== "VIDEO") {
  18. return null;
  19. }
  20. return possibleVideo;
  21. }
  22.  
  23. function clickMessageInput() {
  24. var videoPlayer = getPlayer();
  25. if (videoPlayer) {
  26. console.log('Video found. Clicking "Message Input" button.');
  27. var messageInputButton = document.querySelector('#message-input');
  28. if (messageInputButton) {
  29. var clickEvent = document.createEvent('MouseEvents');
  30. clickEvent.initEvent('click', true, true);
  31. messageInputButton.dispatchEvent(clickEvent);
  32. }
  33. } else {
  34. console.log('No video found on the page.');
  35. }
  36. }
  37.  
  38. // Initial click and observe hashchange
  39. setTimeout(function () {
  40. clickMessageInput();
  41. }, 1337);
  42.  
  43. // Create a MutationObserver to retrigger on hashchange
  44. const observer = new MutationObserver(() => {
  45. console.log('Hashchange event detected. Retriggering script.');
  46. clickMessageInput();
  47. });
  48.  
  49. // Configure and start observing changes to the URL hash
  50. const config = { childList: true, subtree: true };
  51. observer.observe(document.body, config);
  52. })();