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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
|
/// <reference types="../../../CTAutocomplete" />
/// <reference lib="es2015" />
import SoopyContentChangeEvent from "../../../guimanager/EventListener/SoopyContentChangeEvent";
import Feature from "../../featureClass/class";
import soopyV2Server from "../../socketConnection";
import { fetch } from "../../utils/networkUtils";
import ToggleSetting from "../settings/settingThings/toggle";
class SpamHider extends Feature {
constructor() {
super()
}
onEnable() {
this.initVariables()
this.hideMessages = []
this.hideMessagesRexex = []
this.moveMessages = []
this.moveMessagesRexex = []
this.moveMessagesDict = {
all: []
}
this.hideMessagesDict = {
all: []
}
this.hideMessagesSetting = new ToggleSetting("Hide some messages", "This will completely remove some spammy messages from chat", true, "completely_hide_spam", this)
this.moveMessagesSetting = new ToggleSetting("Move some messages to spam hider", "This will move some (potentially) usefull messages into a 'second chat'", true, "move_spam", this)
this.moveChatMessages = new ToggleSetting("Move spammed chat messages to spam hider", "This will move messages spammed in hubs to spam hider\n(eg the website advertisment bots)", true, "move_spam_chat", this)
this.textShadowSetting = new ToggleSetting("Spam Hider Text Shadow", "Whether to give the spam hider text shadow", true, "spam_text_shadow", this)
this.showFriendMessages = new ToggleSetting("Show friend message", "should it show friend join/leave message", false, "spam_text_friend", this)
this.showGuildMessages = new ToggleSetting("Show guild message", "should it show guild mate join/leave message", false, "spam_text_guild", this)
this.SpamHiderMessagesRenderer = new SpamHiderMessagesRenderer()
this.textShadowSetting.toggleObject.addEvent(new SoopyContentChangeEvent().setHandler((newVal, oldVal, resetFun) => {
this.SpamHiderMessagesRenderer.textShadow = this.textShadowSetting.getValue()
}))
this.loadSpamMessages()
this.registerChat("${*}", this.onChat)
this.registerEvent("renderOverlay", this.renderOverlay).registeredWhen(() => this.moveMessagesSetting.getValue())
// this.registerChat("&r${userandrank}&r&f: ${message}&r", this.chatPlayerMessage)
}
// chatPlayerMessage(userandrank, message, e){
// if(!this.FeatureManager.features["generalSettings"]) return
// if(userandrank.includes(">")) return
// if(message.length < 10) return //Short messages like 'LOL' are bound to get repeated
// let msg = sha256(message + "This is a salt PogU")
// if(soopyV2Server.spammedMessages.includes(msg)){
// if(this.moveChatMessages.getValue()){
// this.SpamHiderMessagesRenderer.addMessage(ChatLib.getChatMessage(e, true))
// cancel(e)
// }
// return
// }
// if(this.FeatureManager.features["generalSettings"].class.sendChatSetting && this.FeatureManager.features["generalSettings"].class.sendChatSetting.getValue()){
// soopyV2Server.sendMessageToServer(msg, sha256(this.FeatureManager.features["dataLoader"].class.stats["Server"] + "This is a salt PogU"))
// }
// }
onChat(e) {
let msg = ChatLib.getChatMessage(e, true).replace(/§/g, "&").replace(/(?:^&r)|(?:&r$)/g, "")
if (msg.length > 1000) return //performance
//&r&aFriend > &r&6Soopyboo32 &r&ejoined.&r
if (this.showFriendMessages && msg.includes("&aFriend")) return
//&r&2Guild > &r&6Soopyboo32 &r&ejoined.&r
if (this.showGuildMessages && msg.includes("&2Guild")) return
if (this.hideMessagesSetting.getValue()) {
// console.log("testing " + (this.hideMessagesDict[msg.substring(0,5)]?.length || 0) + this.hideMessagesDict.all.length + " hide messages")
this.hideMessagesDict[msg.substring(0, 5)]?.forEach(regex => {
if (regex.test(msg)) {
cancel(e)
return
}
})
this.hideMessagesDict.all.forEach(regex => {
if (regex.test(msg)) {
cancel(e)
return
}
})
}
if (this.moveMessagesSetting.getValue()) {
// console.log("testing " + (this.moveMessagesDict[msg.substring(0,5)]?.length || 0) + this.moveMessagesDict.all.length + " spam messages")
this.moveMessagesDict[msg.substring(0, 5)]?.forEach(regex => {
if (regex.test(msg)) {
this.SpamHiderMessagesRenderer.addMessage(msg)
cancel(e)
return
}
})
this.moveMessagesDict.all.forEach(regex => {
if (regex.test(msg)) {
this.SpamHiderMessagesRenderer.addMessage(msg)
cancel(e)
return
}
})
}
}
renderOverlay() {
this.SpamHiderMessagesRenderer.render(100, 100, 1, 1)
}
loadSpamMessages() {
fetch("http://soopymc.my.to/api/soopyv2/spamHiderMessages.json").json(messages => {
this.hideMessages = messages.hideMessages
this.moveMessages = messages.moveMessages
this.hideMessagesDict = {
all: []
}
this.hideMessagesRexex = []
this.hideMessages.forEach(message => {
let regex = new RegExp(message.replace(/[\\^$*+?.()|[\]{}]/g, '$&')
.replace(/\$\{\*\}/g, "(?:.+)"))
if (!message.substring(0, 5).includes("$")) {
if (!this.hideMessagesDict[message.substring(0, 5)]) this.hideMessagesDict[message.substring(0, 5)] = []
this.hideMessagesDict[message.substring(0, 5)].push(regex)
} else {
this.hideMessagesDict.all.push(regex)
}
this.hideMessagesRexex.push(regex)
})
this.moveMessagesDict = {
all: []
}
this.moveMessagesRexex = []
this.moveMessages.forEach(message => {
let regex = new RegExp(message.replace(/[\\^$*+?.()|[\]{}]/g, '$&')
.replace(/\$\{\*\}/g, "(?:.+)"))
if (!message.substring(0, 5).includes("$")) {
if (!this.moveMessagesDict[message.substring(0, 5)]) this.moveMessagesDict[message.substring(0, 5)] = []
this.moveMessagesDict[message.substring(0, 5)].push(regex)
} else {
this.moveMessagesDict.all.push(regex)
}
this.moveMessagesRexex.push(regex)
})
})
}
initVariables() {
this.hideMessages = undefined
this.hideMessagesRexex = undefined
this.moveMessages = undefined
this.moveMessagesRexex = undefined
this.SpamHiderMessagesRenderer = undefined
}
onDisable() {
this.initVariables()
}
}
class SpamHiderMessagesRenderer {
constructor() {
this.messages = []
this.x = 0 //offset from corner, not absolute location
this.y = 0 //offset from corner, not absolute location
this.scale = 1
this.corner = 2
this.lastRender = 0
this.textShadow = true
}
addMessage(str) {
this.messages.push([str, Date.now(), this.y])
}
render() {
Renderer.drawString("", -100, -100)//Fixes skytils issue //idk if this is still needed, it was in old code and imma just leave it ig
let now = Date.now()
let animDiv = (now - this.lastRender) / 1000
this.lastRender = now
let swidth = Renderer.screen.getWidth()
let sheight = Renderer.screen.getHeight()
//loop over all messages backwards
for (let i = this.messages.length - 1; i >= 0; i--) {
let message = this.messages[i]
let [str, time, height] = message
time = now - time
let messageWidth = Renderer.getStringWidth(ChatLib.removeFormatting(str))
let x = 0;
let y = 0;
if (this.corner === 0) { //top left
x = 20
this.messages[i][2] = height + (((this.messages.length - i) * -10) - height) * (animDiv * 5)
}
if (this.corner === 1) { //top right
x = swidth - 20 - messageWidth
this.messages[i][2] = height + (((this.messages.length - i) * -10) - height) * (animDiv * 5)
}
if (this.corner === 2) { //bottom right
x = swidth - 20 - messageWidth
this.messages[i][2] = height + (((this.messages.length - i) * 10) - height) * (animDiv * 5)
}
let animOnOff = 0
if (time < 500) {
animOnOff = 1 - (time / 500)
}
if (time > 3500) {
animOnOff = ((time - 3500) / 500)
}
animOnOff *= 90
animOnOff += 90
animOnOff = animOnOff * Math.PI / 180;
animOnOff = Math.sin(animOnOff)
animOnOff *= -1
animOnOff += 1
if (this.corner === 0) { //top left
x += ((animOnOff * -1) * (messageWidth + 30))
y = 30 - (height)
}
if (this.corner === 1) { //top right
x += (animOnOff * (messageWidth + 30))
y = 30 - (height)
}
if (this.corner === 2) { //bottom right
x += (animOnOff * (messageWidth + 30))
y = sheight - 30 - (height)
}
if (this.textShadow) {
Renderer.drawStringWithShadow(str, x + this.x, y + this.y);
} else {
Renderer.drawString(str, x + this.x, y + this.y);
}
if (time > 4000) {
this.messages.shift()
}
}
}
}
module.exports = {
class: new SpamHider()
}
var sha256 = function a(b) {
function c(a, b) {
return (a >>> b) | (a << (32 - b));
}
for (
var d,
e,
f = Math.pow,
g = f(2, 32),
h = "length",
i = "",
j = [],
k = 8 * b[h],
l = (a.h = a.h || []),
m = (a.k = a.k || []),
n = m[h],
o = {},
p = 2;
64 > n;
p++
)
if (!o[p]) {
for (d = 0; 313 > d; d += p) o[d] = p;
(l[n] = (f(p, 0.5) * g) | 0), (m[n++] = (f(p, 1 / 3) * g) | 0);
}
for (b += "\x80"; (b[h] % 64) - 56;) b += "\x00";
for (d = 0; d < b[h]; d++) {
if (((e = b.charCodeAt(d)), e >> 8)) return;
j[d >> 2] |= e << (((3 - d) % 4) * 8);
}
for (j[j[h]] = (k / g) | 0, j[j[h]] = k, e = 0; e < j[h];) {
var q = j.slice(e, (e += 16)),
r = l;
for (l = l.slice(0, 8), d = 0; 64 > d; d++) {
var s = q[d - 15],
t = q[d - 2],
u = l[0],
v = l[4],
w =
l[7] +
(c(v, 6) ^ c(v, 11) ^ c(v, 25)) +
((v & l[5]) ^ (~v & l[6])) +
m[d] +
(q[d] =
16 > d
? q[d]
: (q[d - 16] +
(c(s, 7) ^ c(s, 18) ^ (s >>> 3)) +
q[d - 7] +
(c(t, 17) ^ c(t, 19) ^ (t >>> 10))) |
0),
x =
(c(u, 2) ^ c(u, 13) ^ c(u, 22)) +
((u & l[1]) ^ (u & l[2]) ^ (l[1] & l[2]));
(l = [(w + x) | 0].concat(l)), (l[4] = (l[4] + w) | 0);
}
for (d = 0; 8 > d; d++) l[d] = (l[d] + r[d]) | 0;
}
for (d = 0; 8 > d; d++)
for (e = 3; e + 1; e--) {
var y = (l[d] >> (8 * e)) & 255;
i += (16 > y ? 0 : "") + y.toString(16);
}
return i;
};
|