-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspam.js
More file actions
40 lines (33 loc) · 1.3 KB
/
spam.js
File metadata and controls
40 lines (33 loc) · 1.3 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
document.addEventListener('click', async () => {
let msgBox = document.querySelectorAll("[contenteditable='true']")[1];
// Ambil input dari user
let pesan = prompt('Input Message:');
let jumlah = parseInt(prompt('Number of Messages:'));
if (pesan && !isNaN(jumlah) && jumlah > 0) {
for (let i = 1; i <= jumlah; i++) {
// Fokus ke kotak pesan
msgBox.focus();
// Kosongkan dulu agar tidak double
msgBox.innerHTML = "";
// Masukkan pesan
document.execCommand("insertText", false, pesan);
// Trigger event input agar terdeteksi oleh web
msgBox.dispatchEvent(new InputEvent("input", {
bubbles: true,
cancelable: true,
inputType: "insertText",
data: pesan
}));
// Simulasi tekan Enter untuk kirim
msgBox.dispatchEvent(new KeyboardEvent("keydown", {
key: "Enter",
code: "Enter",
keyCode: 13,
which: 13,
bubbles: true
}));
// Tunggu sedikit biar pesan terkirim dengan aman
await new Promise(resolve => setTimeout(resolve, 1200));
}
}
});