// ==UserScript== // @name Sploop Hat Macro & Menu // @description A script that includes hat macro & a menu // @author DETIX // @version 2.1 // @icon https://sploop.io/img/ui/favicon.png // @match *://sploop.io/* // @license MIT // @namespace https://greasyfork.org/users/1311498 // @downloadURL none // ==/UserScript== let DETIX; function initialize(DETIX) { window.DETIX = DETIX; } WebSocket.prototype.lastSend = WebSocket.prototype.send; window.WebSocket = new Proxy(window.WebSocket, { construct(target, args) { const DETIX = new target(...args); if (!args[0].includes("sploop")) return DETIX; initialize(DETIX); return DETIX; } }); WebSocket.prototype.lastSend = WebSocket.prototype.send; WebSocket.prototype.send = function(a) { this.lastSend(a); if (DETIX !== this) DETIX = this; }; const HATS = { BerserkerGear: { id: 2, defaultKey: "KeyB" }, CrystalGear: { id: 4, defaultKey: "KeyG" }, DemolistHat: { id: 11, defaultKey: "KeyZ" }, SpikeGear: { id: 5, defaultKey: "KeyT" }, BoostHat: { id: 7, defaultKey: "KeyH" }, ScubaGear: { id: 9, defaultKey: "KeyM" } }; let chatWrapper = document.getElementById("chat-wrapper"), clanMenu = document.getElementById("clan-menu"); function check(){ const chatWrapper = document.getElementById("chat-wrapper"); const clanMenu = document.getElementById("clan-menu"); if (chatWrapper.style.display === "block" || clanMenu.style.display === "block") return false; return true; } function EQUIP(id) { DETIX.send(new Uint8Array([5, id, 1])); DETIX.send(new Uint8Array([5, id, 0])); } function handleKeys(event, pressedKey) { pressedKey = event.code; Object.keys(HATS).forEach(key => { if (HATS[key].defaultKey === pressedKey && check()) { EQUIP(HATS[key].id); } }); } document.addEventListener("keypress", handleKeys); const menu = document.createElement("div"); menu.id = "hatMacroMenu"; menu.innerHTML = `