forked from Nebula-Developers/Moomoo-AI-Bot-Sender
-
Notifications
You must be signed in to change notification settings - Fork 0
/
showid.js
55 lines (50 loc) · 1.6 KB
/
showid.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
// ==UserScript==
// @name Moomoo Bot Utilities
// @namespace https://discord.gg/Uj3GWPy
// @version 1.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
// @run-at document-start
// ==/UserScript==
var ws = null;
var id = null;
var pos = [];
WebSocket.prototype.oldSend = WebSocket.prototype.send;
WebSocket.prototype.send = function(m){
this.oldSend(m);
if (!ws){
ws = this;
socketFound(this);
}
};
function socketFound(socket){
socket.addEventListener('message', function(e){
handleMessage(e);
});
}
function handleMessage(e){
var m = e.data;
if (!m.startsWith(`42["2",`) && !m.startsWith(`42["3",`) && !m.startsWith(`42["5",`) && !m.startsWith(`42["6",`)) displayID();
if (m.startsWith(`42["1",`)){
id = /(42\[\"1\",)([0-9]+)\]/.exec(m)[2];
}else if (m.startsWith(`42["3",`)){
var packet = m.replace(`42["3",`, "");
packet = packet.substr(0, packet.length - 1);
var data = JSON.parse(packet);
for (var i = 0, len = data.length / 13; i < len; i++){
if (id == data[0 + i * 13]){
pos[0] = data[1 + i * 13];
pos[1] = data[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(", ")}]`;
}