-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsendScript.js
More file actions
36 lines (26 loc) · 1.57 KB
/
sendScript.js
File metadata and controls
36 lines (26 loc) · 1.57 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
async function enviarLetra(letra) {
const delayInput = prompt("⏱ Delay between messages (milliseconds)\n• Under 600ms = messages group into one notification\n• 600ms or more = each message pings separately\nExamples: 300 = fast, 1000 = 1 ping per line", "500");
const delay = parseInt(delayInput) || 500;
const burstInput = prompt("💥 Group mode: send X lines at a time, then pause for a notification to fire.\nEnter group size, or 0 to send one line at a time.", "0");
const burstSize = parseInt(burstInput) || 0;
const burstDelay = burstSize > 0
? parseInt(prompt("⏸ Delay between bursts (milliseconds)\nRecommended: 6000 or more to trigger separate notifications.", "6000")) || 6000
: 0;
const lines = letra.split(/[\n\t]+/).map(line => line.trim()).filter(line => line);
const textarea = document.querySelectorAll("div[contenteditable='true']")[1];
if (!textarea) throw new Error("No hay una conversación abierta");
for (let i = 0; i < lines.length; i++) {
const line = lines[i];
console.log(`[${i + 1}/${lines.length}] ${line}`);
textarea.focus();
document.execCommand('insertText', false, line);
textarea.dispatchEvent(new Event('change', {bubbles: true}));
await new Promise(resolve => setTimeout(resolve, 150));
textarea.dispatchEvent(new KeyboardEvent('keydown', {key: 'Enter', code: 'Enter', keyCode: 13, which: 13, bubbles: true}));
if (i < lines.length - 1) {
const isEndOfBurst = burstSize > 0 && (i + 1) % burstSize === 0;
await new Promise(resolve => setTimeout(resolve, isEndOfBurst ? burstDelay : delay));
}
}
return lines.length;
}