-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
619 lines (579 loc) · 23.7 KB
/
index.html
File metadata and controls
619 lines (579 loc) · 23.7 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
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
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
<!DOCTYPE html>
<html>
<head>
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300&display=swap" rel="stylesheet">
<!-- Import Roboto Light from Google Fonts -->
<link rel="stylesheet" href="./build.css">
</head>
<body>
<div class="left">
<h1>UnknownBot Reworked Version v3.4</h1>
<form id="connect-form">
<label for="host">Host:</label>
<br>
<input type="text" id="host" value="localhost" name="host">
<br>
<label for="usernameprefix">Username Prefix:</label>
<br>
<input type="text" id="usernameprefix" value="" name="usernameprefix">
<br>
<label for="usernames">Usernames: <span id="usernameCount"></span>
</label>
<br>
<textarea id="usernames" name="usernames" rows="4" cols="50"></textarea>
<br>
<br>
<label for="version">Version:</label>
<br>
<select id="version" name="version">
<option value="1.8.8">1.8.8</option>
<option value="1.8.9">1.8.9</option>
<option value="1.9">1.9</option>
<option value="1.9.1">1.9.1</option>
<option value="1.9.2">1.9.2</option>
<option value="1.9.3">1.9.3</option>
<option value="1.9.4">1.9.4</option>
<option value="1.10">1.10</option>
<option value="1.10.1">1.10.1</option>
<option value="1.10.2">1.10.2</option>
<option value="1.11">1.11</option>
<option value="1.11.1">1.11.1</option>
<option value="1.11.2">1.11.2</option>
<option value="1.12">1.12</option>
<option value="1.12.1">1.12.1</option>
<option value="1.12.2">1.12.2</option>
<option value="1.13">1.13</option>
<option value="1.13.1">1.13.1</option>
<option value="1.13.2">1.13.2</option>
<option value="1.14">1.14</option>
<option value="1.14.1">1.14.1</option>
<option value="1.14.2">1.14.2</option>
<option value="1.14.3">1.14.3</option>
<option value="1.14.4">1.14.4</option>
<option value="1.15">1.15</option>
<option value="1.15.1">1.15.1</option>
<option value="1.15.2">1.15.2</option>
<option value="1.16">1.16</option>
<option value="1.16.1">1.16.1</option>
<option value="1.16.2">1.16.2</option>
<option value="1.16.3">1.16.3</option>
<option value="1.16.4">1.16.4</option>
<option value="1.16.5">1.16.5</option>
<option value="1.17">1.17</option>
<option value="1.17.1">1.17.1</option>
<option value="1.18">1.18</option>
<option value="1.18.1">1.18.1</option>
<option value="1.19">1.19</option>
<option value="1.19.1">1.19.1</option>
<option value="1.20">1.20</option>
<option value="1.20.1">1.20.1</option>
<option value="1.20.2">1.20.2</option>
<option value="1.20.3">1.20.3</option>
<option value="1.20.4">1.20.4</option>
</select>
<br>
<br>
<label for="proxies">Proxies: <span id="proxyCount"></span>
</label>
<br>
<textarea id="proxies" name="proxies" rows="4" cols="50"></textarea>
<br>
<br>
<input type="radio" id="socks4" name="proxyType" value="socks4" class="round-checkbox">
<label for="socks4">Socks4</label>
<br>
<input type="radio" id="socks5" name="proxyType" value="socks5" class="round-checkbox">
<label for="socks5">Socks5</label>
<br>
<input type="radio" id="httpproxy" name="proxyType" value="httpproxy" class="round-checkbox">
<label for="httpproxy">HTTP</label>
<br>
<br>
<div class="aligned-item">
<input type="checkbox" id="autoReconnect" name="autoReconnect" class="round-checkbox" onchange="sendDataReconnect()">
<label for="autoReconnect">Auto Reconnect</label>
</div>
<div class="aligned-item">
<input type="checkbox" id="fallCheck" name="fallCheck" class="round-checkbox" onchange="sendFallCheck()">
<label for="fallCheck">Fall Check Bypass</label>
</div>
<div class="aligned-item" id="delayDiv" style="display: none;">
<label for="delay" class="delay-label">Delay(MS):</label>
<input type="number" id="delay" name="delay" class="delay-input" min="0" max="10000" value="0"
onchange="sendDataReconnect()" oninput="validateInput(this)">
</div>
<br>
<br>
<label for="delayBC" class="delayBC-label">Delay Between Connect(MS):</label>
<input type="number" id="delayBC" name="delayBC" class="delayBC-input" min="0" max="10000" value="0"
oninput="validateInput(this)">
<br>
<input type="submit" value="Connect">
</form>
</div>
<div class="aligned-item">
<input type="checkbox" id="backgroundToggle" class="round-checkbox">
<label for="backgroundToggle">Custom Background</label>
</div>
<div class="right">
<div id="all-bots">
<h2>All Bots</h2>
<div class="bot-controls">
<h3 id="all-bots-control">All Bots Control</h3>
<div class="button-group">
<button id="showchat-all">Show Chat</button>
<button id="reconnect-all-button">Reconnect All</button>
<button id="remove-all-button">Remove All Bots</button>
<button id="reconnect-disconnected-button">Reconnect All Disconnected Bots</button>
<button id="remove-disconnected-button">Remove All Disconnected Bots</button>
</div>
</div>
<div id="chat-all" style="display: none;" class="chat"></div>
<input type="text" id="input-all" style="display: none;" placeholder="Insira sua mensagem" class="input">
</div>
<div id="bots">
<h2 id="bots-heading">Bots</h2>
</div>
</div>
<script>
const {
ipcRenderer
} = require('electron')
async function createDomElement(botUsername) {
return new Promise(resolve => {
const newBotDiv = document.createElement('div')
newBotDiv.id = botUsername
newBotDiv.className = 'bot-div'
newBotDiv.innerHTML = `
<div class="bot-controls">
<h3 id="${botUsername}-status">${botUsername}</h3>
<div class="button-group">
<button id="${botUsername}-showchat">Show Chat</button>
<button id="${botUsername}-reconnect-button">Reconnect</button>
<button id="${botUsername}-remove-button">Remove Bot</button>
</div>
</div>
<div id="${botUsername}-chat" style="display: none;" class="chat"></div>
<input type="text" id="${botUsername}-input" style="display: none;" placeholder="Insira sua mensagem" class="input">`
document.getElementById('bots').appendChild(newBotDiv)
requestAnimationFrame(() => {
resolve();
});
});
}
document.getElementById('backgroundToggle').addEventListener('change', function() {
if (this.checked) {
// Defina o caminho completo para a imagem no diretório especificado
document.body.style.backgroundImage = "url('./assetsUBBOT/custom_background.jpg')";
document.body.style.backgroundSize = "cover"; // Ajuste para cobrir todo o fundo
document.body.style.backgroundRepeat = "no-repeat"; // Evite repetição da imagem
document.body.style.backgroundPosition = "center"; // Centralize a imagem
} else {
document.body.style.backgroundImage = "none"; // Remove o plano de fundo
}
});
const divBots = document.getElementById('bots');
const divContagemBots = document.createElement('div');
divContagemBots.id = 'contagem-bots';
divBots.insertBefore(divContagemBots, divBots.firstChild);
function sendDataReconnect() {
const autoReconnect = document.getElementById('autoReconnect').checked;
let delay = document.getElementById('delay').value || 0;
const data = {
autoReconnect,
delay
};
ipcRenderer.send('form-data-changed-reconnect', data); // Alterar nome do evento
}
function sendFallCheck() {
const fallCheckBox = document.getElementById('fallCheck').checked;
const data = {
fallCheck: fallCheckBox // Alinhar nome da propriedade ao código Java
};
ipcRenderer.send('form-data-changed-fallcheck', data); // Alterar nome do evento
}
function validateInput(input) {
if (input.value > 10000) {
input.value = 10000;
}
input.value = input.value.replace(/[^0-9]/g, '');
}
document.getElementById('autoReconnect').addEventListener('change', function () {
document.getElementById('delayDiv').style.display = this.checked ? 'flex' : 'none';
});
function toggleDelayInput() {
var checkBox = document.getElementById("autoReconnect");
var delayDiv = document.getElementById("delayDiv");
if (checkBox.checked == true) {
delayDiv.style.display = "flex";
} else {
delayDiv.style.display = "none";
}
}
let botMessages = {}
let botVersions = {}
let botUsernames = {}
let botProxies = {}
let botProxyTypes = {}
document.getElementById('connect-form').addEventListener('submit', async (e) => {
e.preventDefault()
const host = document.getElementById('host').value
const usernames = document.getElementById('usernames').value.split('\n').filter(username => username)
const version = document.getElementById('version').value
const proxies = document.getElementById('proxies').value.split('\n').map(proxy => {
const parts = proxy.split(':')
const ip = parts[0]
const port = parseInt(parts[1])
let user = ''
let password = ''
if (parts.length === 3) {
user = parts[2]
} else if (parts.length > 3) {
user = parts.slice(2, -1).join(':')
password = parts[parts.length - 1]
}
return ip && port ? {
ip,
port,
user,
password
} : null
})
let proxyType = null;
if (document.getElementById('socks4').checked) {
proxyType = '4'
}
else if (document.getElementById('socks5').checked) {
proxyType = '5'
}
else if (document.getElementById('httpproxy').checked) {
proxyType = 'http'
}
for (let index = 0; index < usernames.length; index++) {
const username = usernames[index];
botVersions[username] = version
botUsernames[username] = username
botProxies[username] = proxies[index % proxies.length]
botProxyTypes[username] = proxyType
ipcRenderer.send('connect-bot', {
host,
username,
version,
proxy: proxies[index],
proxyType
})
var delayBC = document.getElementById('delayBC').value;
await new Promise(resolve => setTimeout(resolve, delayBC));
}
})
ipcRenderer.on('bot-connecting', async (event, botUsername) => {
const botDiv = document.getElementById(botUsername)
if (!botDiv) {
await createDomElement(botUsername);
}
})
ipcRenderer.on('bot-connected', async (event, botUsername) => {
const botDiv = document.getElementById(botUsername)
if (!botDiv) {
await createDomElement(botUsername);
}
})
/*ipcRenderer.on('bot-disconnected', (event, botUsername) => { // problemas na hora do reconnect
delete botMessages[botUsername]
delete botVersions[botUsername]
delete botUsernames[botUsername]
delete botProxies[botUsername]
delete botProxyTypes[botUsername]
})*/
let botsConectados = 0;
let botsDesconectados = 0;
let botsConectando = 0;
let statusBots = {};
function atualizarContagemBots() {
const botsHeading = document.getElementById('bots-heading');
botsHeading.textContent = `Bots [✔️${botsConectados} | ❌${botsDesconectados} | ⌛${botsConectando} ]`;
}
async function removeBots(botNames) {
for (const botUsername of botNames) {
const botDiv = document.getElementById(botUsername)
if (botDiv) {
botDiv.remove()
}
const statusBot = statusBots[botUsername];
if (statusBot === 'connected') {
botsConectados--;
} else if (statusBot === 'disconnected') {
botsDesconectados--;
} else if (statusBot === 'connecting') {
botsConectando--;
}
delete statusBots[botUsername];
delete botMessages[botUsername]
delete botVersions[botUsername]
delete botUsernames[botUsername]
delete botProxies[botUsername]
delete botProxyTypes[botUsername]
ipcRenderer.send('remove-bot', botUsername)
atualizarContagemBots();
}
}
async function removeDisconnectedBots(botNames) {
for (const botUsername of botNames) {
const botDiv = document.getElementById(botUsername)
const botStatusElement = document.getElementById(`${botUsername}-status`)
if (botStatusElement.innerHTML.includes('❌')) {
if (botDiv) {
botDiv.remove()
}
if (statusBots[botUsername] === 'disconnected') {
botsDesconectados--;
}
delete statusBots[botUsername];
delete botMessages[botUsername]
delete botVersions[botUsername]
delete botUsernames[botUsername]
delete botProxies[botUsername]
delete botProxyTypes[botUsername]
ipcRenderer.send('remove-bot', botUsername)
atualizarContagemBots();
}
}
}
async function reconnectDisconnectedBots(botNames, host) {
for (const botUsername of botNames) {
const botStatusElement = document.getElementById(`${botUsername}-status`)
if (botStatusElement.innerHTML.includes('❌')) {
const version = botVersions[botUsername]
const username = botUsername // Use botUsername diretamente
const proxy = botProxies[botUsername]
const proxyType = botProxyTypes[botUsername]
ipcRenderer.send('reco-bot', { host, botUsername, version, proxy, proxyType })
}
}
}
async function reconnectAllButton(botNames, host, delay) {
for (const botUsername of botNames) {
// Envia todos os dados como um único objeto
ipcRenderer.send('reco-bot', {
host,
botUsername,
botVersion: botVersions[botUsername],
botProxy: botProxies[botUsername],
botProxyType: botProxyTypes[botUsername]
});
await new Promise(resolve => setTimeout(resolve, delay));
}
}
atualizarContagemBots();
ipcRenderer.on('update-bot-status', (event, { bot, status }) => {
const botStatusElement = document.getElementById(`${bot}-status`);
const statusAnterior = statusBots[bot] || '';
if (status === 'connected') {
botStatusElement.innerHTML = `${bot} ✔️`;
if (statusAnterior !== 'connected') {
botsConectados++;
}
if (statusAnterior === 'connecting') {
botsConectando--;
} else if (statusAnterior === 'disconnected') {
botsDesconectados--;
}
} else if (status === 'disconnected') {
botStatusElement.innerHTML = `${bot} ❌`;
if (statusAnterior !== 'disconnected') {
botsDesconectados++;
}
if (statusAnterior === 'connecting') {
botsConectando--;
} else if (statusAnterior === 'connected') {
botsConectados--;
}
} else if (status === 'connecting') {
botStatusElement.innerHTML = `${bot} ⌛`;
if (statusAnterior !== 'connecting') {
botsConectando++;
}
if (statusAnterior === 'connected') {
botsConectados--;
} else if (statusAnterior === 'disconnected') {
botsDesconectados--;
}
}
statusBots[bot] = status;
atualizarContagemBots();
requestAnimationFrame(() => { });
});
ipcRenderer.on('bot-message', async (event, { bot, message }) => {
const chatDiv = document.getElementById(`${bot}-chat`);
if (chatDiv) {
chatDiv.insertAdjacentHTML('beforeend', `${message}<br>`);
chatDiv.scrollTop = chatDiv.scrollHeight;
}
});
ipcRenderer.on('bot-message-all', (event, { message }) => {
const chatDivAll = document.getElementById(`chat-all`);
if (chatDivAll) {
chatDivAll.insertAdjacentHTML('beforeend', `${message}<br>`);
chatDivAll.scrollTop = chatDivAll.scrollHeight;
}
});
document.addEventListener('click', (event) => {
if (event.target.id.endsWith('-showchat')) {
const botUsername = event.target.id.split('-')[0]
const chatDiv = document.getElementById(`${botUsername}-chat`)
const inputDiv = document.getElementById(`${botUsername}-input`)
if (chatDiv && inputDiv) {
const display = chatDiv.style.display === 'none' ? 'block' : 'none'
chatDiv.style.display = display
inputDiv.style.display = display
}
} else if (event.target.id.endsWith('-remove-button')) {
const botUsername = event.target.id.replace('-remove-button', '')
const botDiv = document.getElementById(botUsername)
if (botDiv) {
botDiv.remove()
}
const statusBot = statusBots[botUsername];
if (statusBot === 'connected') {
botsConectados--;
} else if (statusBot === 'disconnected') {
botsDesconectados--;
} else if (statusBot === 'connecting') {
botsConectando--;
}
delete statusBots[botUsername];
delete botMessages[botUsername]
delete botVersions[botUsername]
delete botUsernames[botUsername]
delete botProxies[botUsername]
delete botProxyTypes[botUsername]
ipcRenderer.send('remove-bot', botUsername)
atualizarContagemBots();
}
else if (event.target.id.endsWith('-reconnect-button')) {
const botUsername = event.target.id.replace('-reconnect-button', '')
const host = document.getElementById('host').value
const version = botVersions[botUsername]
const proxy = botProxies[botUsername]
const proxyType = botProxyTypes[botUsername]
ipcRenderer.send('reco-bot', { host, botUsername, version, proxy, proxyType });
}
else if (event.target.id === 'showchat-all') {
const chatDivAll = document.getElementById(`chat-all`)
const inputDivAll = document.getElementById(`input-all`)
if (chatDivAll && inputDivAll) {
const display = chatDivAll.style.display === 'none' ? 'block' : 'none'
chatDivAll.style.display = display
inputDivAll.style.display = display
}
} else if (event.target.id === 'remove-all-button') {
const botDivs = document.querySelectorAll('.bot-div');
const botNames = Array.from(botDivs).map(div => div.id);
removeBots(botNames, 1);
atualizarContagemBots();
}
else if (event.target.id === 'remove-disconnected-button') {
const botDivs = document.querySelectorAll('.bot-div');
const botNames = Array.from(botDivs).map(div => div.id);
removeDisconnectedBots(botNames, 1);
atualizarContagemBots();
}
else if (event.target.id === 'reconnect-disconnected-button') {
const host = document.getElementById('host').value
const botDivs = document.querySelectorAll('.bot-div');
const botNames = Array.from(botDivs).map(div => div.id);
reconnectDisconnectedBots(botNames, host, 1);
} else if (event.target.id === 'reconnect-all-button') {
const host = document.getElementById('host').value
const botDivs = document.querySelectorAll('.bot-div');
const botNames = Array.from(botDivs).map(div => div.id);
reconnectAllButton(botNames, host, 1);
};
})
document.addEventListener('keydown', async (event) => {
if (event.key === 'Enter' && event.target.id === 'input-all') {
event.preventDefault();
const message = event.target.value;
if (message == "$inventoryinterface") {
ipcRenderer.send('send-message-all', { message: "<br><span style='color:red'>Comando nao suportado neste canal!</span><br><br>" });
} else {
ipcRenderer.send('send-message-for-all-threads', { message });
}
event.target.value = '';
}
});
document.addEventListener('keydown', (event) => {
if (event.key === 'Enter' && event.target.nodeName !== 'TEXTAREA') {
event.preventDefault();
const message = event.target.value;
if (event.target.className === 'input') {
const botUsername = event.target.id.split('-')[0];
const botStatusElement = document.getElementById(`${botUsername}-status`);
if (!botStatusElement.textContent.includes('❌')) {
ipcRenderer.send('send-message', { botUsername, message });
}
} else if (event.target.id === 'input-all') {
ipcRenderer.send('ready-for-bots');
}
event.target.value = '';
} else if (event.ctrlKey && event.shiftKey) {
let textarea = document.getElementById('usernames');
for (let i = 0; i < 5; i++) {
if (event.key === 'F') {
textarea.value += generateRandomStringWithPrefix(5) + '\n';
} else if (event.key === 'G') {
textarea.value += generateRandomString(15) + '\n';
}
}
updateUsernameCount();
}
});
document.getElementById('usernames').addEventListener('input', updateUsernameCount);
document.getElementById('proxies').addEventListener('input', updateProxyCount);
function generateRandomString(length) {
let result = '';
let characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
for (let i = 0; i < length; i++) {
result += characters.charAt(Math.floor(Math.random() * characters.length));
}
return result;
}
function generateRandomStringWithPrefix(length) {
// Obtenha o valor do campo de entrada
let prefix = document.getElementById('usernameprefix').value;
// Se o campo de entrada estiver vazio, use 'unknownbot_' como padrão
if (!prefix) {
prefix = 'unknownbot_';
}
let result = prefix;
let characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
for (let i = 0; i < length; i++) {
result += characters.charAt(Math.floor(Math.random() * characters.length));
}
return result;
}
function updateUsernameCount() {
let textarea = document.getElementById('usernames');
let usernames = textarea.value.split('\n');
let count = 0;
for (let i = 0; i < usernames.length; i++) {
if (usernames[i] !== '') {
count++;
}
}
document.getElementById('usernameCount').textContent = count;
}
function updateProxyCount() {
let textarea = document.getElementById('proxies');
let usernames = textarea.value.split('\n');
let count = 0;
for (let i = 0; i < usernames.length; i++) {
if (usernames[i] !== '') {
count++;
}
}
document.getElementById('proxyCount').textContent = count;
}
</script>
</body>
</html>