您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Auto-start new chat on disconnect and keep chat input focused.
// ==UserScript== // @name Emerald Auto Next // @namespace https://greasyfork.org/ // @version 1.3 // @description Auto-start new chat on disconnect and keep chat input focused. // @author Zach // @license Apache-2.0 // @icon https://emeraldchat.com/logo7.svg // @match https://emeraldchat.com/app // @grant none // @compatible Firefox // @compatible Violentmonkey // ==/UserScript== 'use strict'; function randomTimeout(min, max) { const minMs = min * 1000; const maxMs = max * 1000; return Math.floor(Math.random() * (maxMs - minMs + 1)) + minMs; } function simulateClick(element) { const mouseDown = new MouseEvent('mousedown', { bubbles: true, cancelable: true }); const mouseUp = new MouseEvent('mouseup', { bubbles: true, cancelable: true }); const clickEvent = new MouseEvent('click', { bubbles: true, cancelable: true }); element.dispatchEvent(mouseDown); element.dispatchEvent(mouseUp); element.dispatchEvent(clickEvent); } function giveKarma() { const [good, bad] = document.querySelectorAll("a.ui-button-match-mega"); if (!good || !bad) return; const messages = document.querySelectorAll("#messages > .room-component-message-container").length; if (messages > 3) { simulateClick(good); } else { simulateClick(bad); } } function nextChat() { const startButton = document.querySelector(".ui-button-match"); if (!startButton) return; setTimeout(() => { if (startButton.textContent === "Start") { simulateClick(startButton); } }, randomTimeout()); } function focusChat() { const chatInput = document.getElementById("room-input"); if (!chatInput) return; document.body.addEventListener("keydown", (event) => { if (!document.querySelector("#ui-hatch > *, #ui-hatch-2 > *, #interests") && event.key !== "`") { chatInput.focus(); } }, { once: true }); } function observeChanges() { const container = document.getElementById("container"); if (!container) return; let shouldExecute = true; const observer = new MutationObserver(() => { giveKarma(); if (shouldExecute) nextChat(); focusChat(); }); observer.observe(container, { childList: true, subtree: true }); document.addEventListener("keydown", (event) => { if (event.key === "`") { event.preventDefault(); shouldExecute = !shouldExecute; } }); } observeChanges();