-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTracers.user.js
88 lines (72 loc) · 2.56 KB
/
Tracers.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
80
81
82
83
84
85
86
87
88
// ==UserScript==
// @name Tracers
// @namespace http://tampermonkey.net/
// @version 0.1
// @description later...
// @author Devil D. Nudo#7346
// @match *://*.moomoo.io/*
// @match *://moomoo.io/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=moomoo.io
// @grant none
// @run-at document-start
// ==/UserScript==
(function() {
function gameRender(myPlayer, tmpPlayer, xOffset, yOffset, context) {
const config = {
enemyColor: "#cc5151",
allyColor: "#8ecc51",
animalColor: "#518ccc",
lineWidth: 5.5
}
function tracer(target, other, color) {
context.save()
context.strokeStyle = color
context.lineCap = "round"
context.lineWidth = config.lineWidth
context.beginPath()
context.moveTo(target.x - xOffset, target.y - yOffset)
context.lineTo(other.x - xOffset, other.y - yOffset)
context.closePath()
context.stroke()
context.restore()
}
if (tmpPlayer.sid === myPlayer.sid) return
if (tmpPlayer.isPlayer) {
const color = (tmpPlayer.team !== myPlayer.team || !tmpPlayer.team) ? config.enemyColor : config.allyColor
tracer(myPlayer, tmpPlayer, color)
} else {
tracer(myPlayer, tmpPlayer, config.animalColor)
}
}
function applyRegex(code) {
const matchHealth = code.match(/\.health\>\d/)
const tmpPlayer = code.slice(matchHealth.index - 1, matchHealth.index)
const targetContent = `${tmpPlayer}.health>0`
const regex = new RegExp(`${tmpPlayer}\.health\>0`)
const args = `A, U, d, f, ve`
const result = code.replace(regex, `;${gameRender.toString()};gameRender(${args});${targetContent}`)
code = result
return code
}
async function loadScript(script) {
const response = await fetch(script.src)
let code = await response.text()
code = applyRegex(code)
eval(code)
}
const observer = new MutationObserver(function(mutations) {
for (const mutation of mutations) {
for (const node of mutation.addedNodes) {
if (node.tagName === "SCRIPT" && /bundle\.js$/.test(node.src)) {
observer.disconnect()
loadScript(node)
node.remove()
}
}
}
})
observer.observe(document, {
childList: true,
subtree: true
})
})()