// ==UserScript==
// @name WTFHELP
// @namespace eee
// @version 1.0.2
// @description 一个WTFgame辅助脚本引擎
// @author EC
// @match https://game.elfive.cn:91/wtfgame/
// @match http://154.211.15.42:9191/wtfgame/
// @match http://160.202.232.88:43943/
// @icon https://www.google.com/s2/favicons?sz=64&domain=elfive.cn
// @icon https://www.google.com/s2/favicons?sz=64&domain=154.211.15.42
// @icon https://www.google.com/s2/favicons?sz=64&domain=160.202.232.88
// @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}"}}`);
}
};
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');
}
// 三叶
})();