-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwisp.js
More file actions
53 lines (51 loc) · 1.2 KB
/
wisp.js
File metadata and controls
53 lines (51 loc) · 1.2 KB
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
const ERROR_MESSAGE = '\u00A7cWisp Proxy is not enabled!'
class WispWebSocket extends EventTarget {
readyState;
constructor() {
super();
this.readyState = WebSocket.CLOSED;
setTimeout(() => {
this.dispatchEvent(new Event('open'));
});
}
send(chunk) {
if (typeof chunk === 'string' && chunk.trim().toLowerCase().replaceAll(' ', '') === 'accept:motd') {
this.dispatchEvent(
new MessageEvent("message", {
data: JSON.stringify({
name: '',
brand: '',
vers: '',
cracked: true,
time: Date.now(),
uuid: '',
type: 'motd',
data: {
cache: true,
icon: false,
online: 0,
max: -1,
motd: [ERROR_MESSAGE],
players: [],
},
}),
})
);
} else {
const enc = new TextEncoder().encode(ERROR_MESSAGE);
const eag = Uint8Array.from([0xff, 0x08, enc.length, ...enc]);
this.dispatchEvent(new MessageEvent('message', { data: eag }));
this.dispatchEvent(new CloseEvent('close'));
}
}
close() {}
}
window.WebSocket = new Proxy(window.WebSocket, {
construct (a, [b, c]) {
if (b.includes('java://')) {
return new WispWebSocket();
} else {
return new a(b, c);
}
}
});