Last active
May 3, 2024 19:17
-
-
Save javimata/39eee045f189106f4e7c596d1859bbfe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function enviarScript(scriptText){ | |
let main = document.querySelector("#main"), | |
textarea = main.querySelector(`div[contenteditable="true"]`) | |
const largo = 30 | |
if(!textarea) throw new Error("No hay una conversación iniciada") | |
let n = 0; | |
let sendButton = main.querySelector(`[data-testid="send"]`) || main.querySelector(`[data-icon="send"]`); | |
while (n < largo) { | |
console.log("BAJA " + n); | |
textarea.focus(); | |
document.execCommand('insertText', false, "BAJA " + n); | |
textarea.dispatchEvent(new Event('change', {bubbles: true})); | |
setTimeout(() => { | |
(main.querySelector(`[data-testid="send"]`) || main.querySelector(`[data-icon="send"]`)).click(); | |
}, 100); | |
if(n < largo) await new Promise(resolve => setTimeout(resolve, 250)); | |
n++; | |
} | |
return n; | |
} | |
enviarScript(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment