-
Notifications
You must be signed in to change notification settings - Fork 17
/
showid.user.js
79 lines (74 loc) · 2.62 KB
/
showid.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// ==UserScript==
// @name Moomoo Bot Utilities
// @namespace https://discord.gg/Uj3GWPy
// @version 1.4.0
// @description Shows your internal ID and position.
// @author Mega_Mewthree
// @match *://moomoo.io/*
// @match *://45.77.0.81/*
// @match *://dev.moomoo.io/*
// @grant none
// @require https://cdn.rawgit.com/creationix/msgpack-js-browser/9117d0f8/msgpack.js
// @run-at document-start
// ==/UserScript==
(() => {
var ws = null;
var id = null;
var pos = [];
WebSocket = class extends WebSocket {
constructor(...arg) {
super(...arg);
ws = this;
this.addEventListener("message", function(e){
handleMessage(e);
});
this._send = this.send;
this.send = function (){
if (typeof arguments[0] !== "string"){
try {
const sent = msgpack.decode(arguments[0].slice(1));
if (sent[0] === "1"){
const req = new XMLHttpRequest();
req.open("POST", `http://localhost:15729/?spawned=true`, true);
req.send();
}
}catch (e){
console.error(e);
}
}
this._send.apply(this, arguments);
};
}
};
function handleMessage(e){
var m = e.data;
if (typeof m === "string") return;
m = msgpack.decode(m.slice(1)).data;
if (m[0] !== "2" && m[0] !== "3" && m[0] !== "5" && m[0] !== "6") displayID();
if (m[0] === "1"){
id = m[1];
const req = new XMLHttpRequest();
req.open("POST", `http://localhost:15729/?ownerID=${id}`, true);
req.send();
}else if (m[0] === "3"){
for (var i = 0, len = m[1].length / 13; i < len; i++){
if (id === m[1][i * 13]){
pos[0] = m[1][1 + i * 13];
pos[1] = m[1][2 + i * 13];
}
}
}
}
function displayID(){
var t = document.getElementById("ageText");
var age = /AGE [0-9]+/.exec(t.innerHTML);
t.innerHTML = `${age && age[0]} (${id}) [${pos.join(", ")}]`;
}
setInterval(() => {
if (id){
const req = new XMLHttpRequest();
req.open("POST", `http://localhost:15729/?ownerID=${id}`, true);
req.send();
}
}, 5000);
})();