Xiangqi Game Chat Automator

Automatically pastes text into the chat dialogue on Xiangqi game pages

Size

1.7 KB

Version

1.0.1

Created

Mar 30, 2026

Updated

17 days ago

1// ==UserScript==
2// @name		Xiangqi Game Chat Automator
3// @description		Automatically pastes text into the chat dialogue on Xiangqi game pages
4// @version		1.0.1
5// @match		https://*.play.xiangqi.com/*
6// @icon		https://play.xiangqi.com/icon.svg
7// ==/UserScript==
8(function() {
9    'use strict';
10    
11    // Function to paste text into chat
12    function pasteTextToChat() {
13        // Look for the chat input element
14        const chatInput = document.querySelector('input[placeholder*="chat"], input[placeholder*="message"], textarea[placeholder*="chat"], textarea[placeholder*="message"]');
15        
16        // If chat input is found, paste the text
17        if (chatInput) {
18            chatInput.value = 'abc-test';
19            // Trigger input event to simulate typing
20            const inputEvent = new Event('input', { bubbles: true });
21            chatInput.dispatchEvent(inputEvent);
22            
23            // Trigger keydown and keyup events for Enter key to submit
24            const keydownEvent = new KeyboardEvent('keydown', {
25                key: 'Enter',
26                code: 'Enter',
27                keyCode: 13,
28                which: 13,
29                bubbles: true
30            });
31            const keyupEvent = new KeyboardEvent('keyup', {
32                key: 'Enter',
33                code: 'Enter',
34                keyCode: 13,
35                which: 13,
36                bubbles: true
37            });
38            
39            chatInput.dispatchEvent(keydownEvent);
40            chatInput.dispatchEvent(keyupEvent);
41            
42            console.log('Text "abc-test" pasted to chat');
43        } else {
44            console.log('Chat input not found');
45        }
46    }
47    
48    // Run the function every 5 seconds
49    setInterval(pasteTextToChat, 5000);
50})();
Xiangqi Game Chat Automator | Robomonkey