Greasy Fork

Greasy Fork is available in English.

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 提交的版本,查看 最新版本

// ==UserScript==
// @name        Auto Click Chatbox
// @namespace   http://greasyfork.icu/en/users/1200587-trilla-g
// @match       *://*.kick.com/*
// @grant       none
// @version     1.1
// @license     MIT
// @author      Trilla_G
// @description This script automatically clicks the "Message Input" button on the sidebar, on kick.com when the stream is live.
// ==/UserScript==
 
(function() {
    'use strict';
 
    function isLive() {
        let liveDisplay = document.querySelector(".vjs-live-control");
        return liveDisplay && !liveDisplay.classList.contains('vjs-hidden');
    }
 
    function clickMessageInput() {
        let messageInputButton = document.querySelector('#message-input');
        if (isLive() && messageInputButton) {
            messageInputButton.click();
        }
    }
 
    // Create a MutationObserver to retrigger on hashchange
    const observer = new MutationObserver(() => {
        console.log('Hashchange event detected. Retriggering script.');
        clickMessageInput();
    });
 
    // Configure and start observing changes to the URL hash
    const config = { childList: true, subtree: true };
    observer.observe(document.body, config);
 
    // Initial click and observe hashchange
    setTimeout(function() {
        clickMessageInput();
    }, 2000);
})();