-
Notifications
You must be signed in to change notification settings - Fork 68
Expand file tree
/
Copy pathben_10.js
More file actions
55 lines (44 loc) · 1.52 KB
/
ben_10.js
File metadata and controls
55 lines (44 loc) · 1.52 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
async function enviarScript(scriptText, delay = 1000) {
const lines = scriptText.split('\n').map(line => line.trim()).filter(line => line);
const main = document.querySelector("#main");
const textarea = main.querySelector(`div[contenteditable="true"]`);
if (!textarea) {
throw new Error("Não há uma conversa aberta");
}
for (const line of lines) {
console.log(line);
textarea.focus();
document.execCommand('insertText', false, line);
textarea.dispatchEvent(new Event('change', { bubbles: true }));
await new Promise(resolve => setTimeout(resolve, 100));
const sendButton = main.querySelector(`[data-testid="send"]`) || main.querySelector(`[data-icon="send"]`);
sendButton.click();
if (lines.indexOf(line) !== lines.length - 1) {
await new Promise(resolve => setTimeout(resolve, delay));
}
}
return lines.length;
}
const script = `
A história começou
Quando um relógio esquisito
Grudou no pulso dele vindo lá do infinito
Agora tem poderes e com eles faz bonito
É o Ben 10
(Ben 10, Ben 10, Ben 10)
Se acaso encontrá-lo, você vai se admirar
Diante de seus olhos ele vai se transformar
Em um ser alienígena
Que bota pra quebrar
É o Ben 10
(Ben 10)
Com seus poderes vai combater
Os inimigos e vai vencer
Ele não foge de medo ou dor
Moleque muito irado
Seja onde for
É o Ben 10
`;
enviarScript(script, 2000)
.then(e => console.log(`Código finalizado, ${e} mensagens enviadas`))
.catch(console.error);