-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Description
SendScriptWhatsApp/shrekSendScript.js
Line 1 in 0ac6dad
| async function enviarScript(scriptText){ |
I saw a mistake insend functions, because whatsapp made an update, I solved by myself here is the solutions:
async function enviarScript(scriptText) {
const lines = scriptText
.split(/[\n\t]+/)
.map(line => line.trim())
.filter(line => line);
const main = document.querySelector("#main");
const textarea = main?.querySelector(`div[contenteditable="true"]`);
if (!textarea) throw new Error("No hay una conversación abierta");
for (const line of lines) {
console.log("Enviando línea:", line);
// Limpiar el textarea antes de escribir
textarea.focus();
document.execCommand('selectAll', false, null);
document.execCommand('delete', false, null);
// Insertar texto
document.execCommand('insertText', false, line);
textarea.dispatchEvent(new InputEvent("input", { bubbles: true }));
// Esperar un poco antes de enviar
await new Promise(resolve => setTimeout(resolve, 100));
// Buscar el botón con aria-label="Send" y hacer clic
const sendButton = document.querySelector('button[aria-label="Send"]');
if (sendButton) {
sendButton.click();
} else {
console.warn("Botón de enviar no encontrado");
}
// Esperar antes de pasar a la siguiente línea (ajusta si se salta mensajes)
await new Promise(resolve => setTimeout(resolve, 500));
}
return lines.length;
}
ediervillaneda
Metadata
Metadata
Assignees
Labels
No labels