// ==UserScript== // @name WTFHELP // @namespace eee // @version 1.0.5 // @description 一个WTFgame的辅助脚本引擎 // @author EC // @match https://game.elfive.cn:91/wtfgame/ // @match http://154.211.15.42:9191/wtfgame/ // @match https://wtf.haven.chat/ // @icon https://i.imgs.ovh/2025/07/25/WoXqY.png/ // @grant none // ==/UserScript== (function() { const hook = window.WebSocket; let ws; window.WebSocket = function(protocols) { ws = new hook(protocols); //非必要情况下勿改 const originalSend = ws.send; ws.send = function(data) { originalSend.call(ws, data); }; ws.addEventListener('message', function(event) { // 这里可以添加消息处理逻辑 return; }); ws.addEventListener('open', function(event) { // 连接打开时的逻辑 return; }); ws.addEventListener('close', function(event) { document.body.innerHTML += "
断开链接
"; }); return ws; }; // 创建按钮容器 const box = document.createElement('div'); box.id = "wtfhelp-container"; box.style.position = "fixed"; box.style.top = "30%"; box.style.left = "10px"; box.style.transform = "translateY(-50%)"; box.style.backgroundColor = "rgba(0, 0, 0, 0.7)"; box.style.padding = "10px"; box.style.borderRadius = "5px"; box.style.zIndex = "999999"; // 添加按钮 box.innerHTML = ` `; // 按钮点击事件处理 box.onclick = function(event) { if (event.target.id === "001") { const roomNumber = prompt("输入房间号"); if (roomNumber !== null && roomNumber.trim() !== "") { send(`{"k":"msg","v":{"msg":"/room ${roomNumber.trim()}"}}`); } } else if (event.target.id === "002") { send(`{"k":"msg","v":{"msg":"/room py"}}`); } else if (event.target.id === "003") { const randomRoom = getRandomRoom(); send(`{"k":"msg","v":{"msg":"/room ${randomRoom}"}}`); } else if (event.target.id === "004") { /*发包可以测试脚本是否运行成功*/ send(`{"k":"move","v":{"t":"warp"}}`); } }; document.body.appendChild(box); // 发送消息函数 function send(message) { try { ws.send(btoa(message)); } catch (error) { console.error("发送消息失败:", error); } } // 生成随机房间号 function getRandomRoom() { const totalRooms = 12; const roomNumber = Math.floor(Math.random() * totalRooms) + 1; return String(roomNumber).padStart(3, '0'); } // 三叶 })();