| 1 | async function enviarScript(scriptText){ |
| 2 | const lines = scriptText.split(/[\n\t]+/).map(line => line.trim()).filter(line => line); |
| 3 | main = document.querySelector("#main"), |
| 4 | textarea = main.querySelector(`div[contenteditable="true"]`) |
| 5 | |
| 6 | if(!textarea) throw new Error("Não há uma conversa aberta") |
| 7 | |
| 8 | for(const line of lines){ |
| 9 | console.log(line) |
| 10 | |
| 11 | textarea.focus(); |
| 12 | document.execCommand('insertText', false, line); |
| 13 | textarea.dispatchEvent(new Event('change', {bubbles: true})); |
| 14 | |
| 15 | setTimeout(() => { |
| 16 | (main.querySelector(`[data-testid="send"]`) || main.querySelector(`[data-icon="send"]`)).click(); |
| 17 | }, 100); |
| 18 | |
| 19 | if(lines.indexOf(line) !== lines.length - 1) await new Promise(resolve => setTimeout(resolve, 250)); |
| 20 | } |
| 21 | |
| 22 | return lines.length; |
| 23 | } |
| 24 | |
| 25 | enviarScript(` |
| 26 | BEE Movie |