Greasy Fork is available in English.
This script automatically clicks the "Message Input" button on the sidebar, on kick.com when the stream is live.
当前为
// ==UserScript==
// @name Auto Click Chatbox
// @namespace http://greasyfork.icu/en/users/1200587-trilla-g
// @match *://*.kick.com/*
// @grant none
// @version 6.0
// @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();
}
}
// Function to observe URL changes using MutationObserver
const observeUrlChanges = () => {
const observer = new MutationObserver(() => {
const newUrl = window.location.href;
if (newUrl.includes('kick.com')) {
clickMessageInput();
}
});
// Start observing changes to the href attribute of the document's body
observer.observe(document.body, { subtree: true, childList: true });
// Cleanup observer on page unload
window.addEventListener('beforeunload', () => observer.disconnect());
};
// Initial run of the script
setTimeout(clickMessageInput, 1600); // 2-second delay before the initial click
// Initial observation of URL changes
observeUrlChanges();
})();