Greasy Fork

来自缓存

Greasy Fork is available in English.

Auto Click Chatbox

This script automatically clicks the "Chat" button and "Message Input" on the sidebar, on kick.com. It pauses for 10 seconds after any mouse click.

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

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        Auto Click Chatbox
// @namespace   http://greasyfork.icu/en/users/1200587-trilla-g
// @match       *://*.kick.com/*
// @grant       none
// @version     1.37
// @license     MIT
// @author      Trilla_G
// @description This script automatically clicks the "Chat" button and "Message Input" on the sidebar, on kick.com. It pauses for 10 seconds after any mouse click.
// ==/UserScript==

(function() {
    'use strict';

    let clickingEnabled = true; // Variable to control automatic clicking

    function isLive() {
        let liveDisplay = document.querySelector(".vjs-live-control");
        return liveDisplay && !liveDisplay.classList.contains('vjs-hidden');
    }

    function clickChatAndMessageInput() {
        if (!clickingEnabled) {
            return;
        }

        let chatButton = document.querySelector('#chat-button');
        let messageInputButton = document.querySelector('#message-input');

        if (isLive()) {
            if (messageInputButton) {
                messageInputButton.click();
            }
        } else {
            if (chatButton) {
                chatButton.click();
            }
            if (messageInputButton) {
                messageInputButton.click();
            }
        }
    }

    // Function to handle mouse clicks
    function handleMouseClick() {
        // Disable automatic clicking
        clickingEnabled = false;

        // Pause the script for 10 seconds
        setTimeout(() => {
            // Re-enable automatic clicking
            clickingEnabled = true;

            // Restart the script
            clickChatAndMessageInput();
        }, 10000);
    }

    // Function to handle hashchange events
    function handleHashChange() {
        // Re-trigger clicking "Message Input" instantly
        clickChatAndMessageInput();
    }

    // Create a MutationObserver to retrigger on hashchange
    const observer = new MutationObserver(() => {
        console.log('Hashchange event detected. Retriggering script.');
        handleHashChange();
    });

    // 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(() => {
        clickChatAndMessageInput();
    }, 1000);

    // Add event listener for mouse clicks
    document.body.addEventListener('mousedown', handleMouseClick);
})();