1 // ==UserScript==
2 // @name moomoo.io chat shortcuts
3 // @namespace http://bzzzzdzzzz.blogspot.com/
4 // @version 0.1
5 // @description read name
6 // @author BZZZZ
7 // @match *://moomoo.io/*
8 // @match *://sandbox.moomoo.io/*
9 // @grant none
10 // ==/UserScript==
11
12 var chatShortcuts = { // add or remove stuff here
13 "KeyH": "Hello!",
14 "KeyB": "Bye!",
15 "KeyG": "Goodbye, cruel world."
16 };
17
18 var sockSend = WebSocket.prototype.send, sock;
19 var blobOptions = {"type": "application/octet-stream"};
20
21 function sendChat(msg) {
22 msg = new Blob([msg], blobOptions);
23 var size = msg.size;
24 if ((size > 30) || (size < 1)) throw new Error("invalid message size");
25 sockSend.call(sock, new Blob([new Uint8Array([146, 162, 99, 104, 145, 160 + size]), msg], blobOptions));
26 }
27
28 function isHidden(element) {
29 return window.getComputedStyle(element, null).getPropertyValue("display") === "none";
30 }
31
32 function socketFoundCallBack() {
33 document.addEventListener("keydown", function (evt) {
34 var msg = chatShortcuts[evt.code];
35 if ((typeof msg !== "undefined") && isHidden(chatHolder) && !isHidden(gameUI) && isHidden(allianceMenu)) sendChat(msg);
36 }, false);
37 }
38
39 WebSocket.prototype.send = function () {
40 WebSocket.prototype.send = sockSend;
41 sock = this;
42 socketFoundCallBack();
43 return sockSend.apply(this, arguments);
44 };
moomoo.io chat shortcuts
Subscribe to:
Posts (Atom)
No comments:
Post a Comment