MooMoo.io Hats and Accessories AutoBuy

Toggle key: T

// ==UserScript==
// @name         MooMoo.io Hats and Accessories AutoBuy
// @author       Cubic Flex [CF]
// @description  Toggle key: T
// @namespace    -
// @version      1.0
// @license      MIT
// @match        *://*.moomoo.io/*
// @require      https://cdn.jsdelivr.net/npm/msgpack-lite@0.1.26/dist/msgpack.min.js
// ==/UserScript==

/* global msgpack */
var aB = true, gW = "not";
WebSocket.prototype.oldSender = WebSocket.prototype.send;
WebSocket.prototype.send = function(m) {
    if(gW == "not"){
        gW = this;
    }
    if(msgpack.decode(new Uint8Array(Array.from(new Uint8Array(m))))[0] == "13c"){
        if(msgpack.decode(new Uint8Array(Array.from(new Uint8Array(m))))[1][0] == 0 && msgpack.decode(new Uint8Array(Array.from(new Uint8Array(m))))[1][1] != 0 && aB){
            this.oldSender(new Uint8Array(Array.from(msgpack.encode((['13c', [1, msgpack.decode(new Uint8Array(Array.from(new Uint8Array(m))))[1][1], msgpack.decode(new Uint8Array(Array.from(new Uint8Array(m))))[1][2]]])))));
        }
    }
    this.oldSender(m);
};

let d = document;d.addEventListener("keydown", (e)=>{
    if(e.keyCode==84){;
        /*gW.send(new Uint8Array(Array.from(msgpack.encode(["13c", [0, 11, 1]]))));*/ //Works with hat and acc
        aB = !aB;
        d.title = "Auto Buy: " + (aB ? "ON" : "OFF");
    }
});
d.title = "Auto Buy: " + (aB ? "ON" : "OFF");