From 479a138d54901920ffd666585270d9b0f4e21720 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Victor?= <89094972+jotaaave@users.noreply.github.com> Date: Mon, 12 Jan 2026 21:34:59 -0300 Subject: [PATCH 1/2] Refactor enviarScript for WhatsApp's new DOM structure 12/01/26 Updated the enviarScript function to adapt to changes in WhatsApp's DOM structure, ensuring the message sending process works correctly with the new button layout. --- shrekSendScript.js | 55 +++++++++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 18 deletions(-) diff --git a/shrekSendScript.js b/shrekSendScript.js index ff005de..85b9f5d 100644 --- a/shrekSendScript.js +++ b/shrekSendScript.js @@ -1,24 +1,43 @@ -async function enviarScript(scriptText){ - const lines = scriptText.split(/[\n\t]+/).map(line => line.trim()).filter(line => line); - main = document.querySelector("#main"), - textarea = main.querySelector(`div[contenteditable="true"]`) - - if(!textarea) throw new Error("Não há uma conversa aberta") - - for(const line of lines){ - console.log(line) - +async function enviarScript(scriptText) { + const lines = scriptText + .split(/[\n\t]+/) + .map(l => l.trim()) + .filter(Boolean); + // This changed to new msg button in whatsapp, resolve for "Chat is not openning/Conversa não aberta" + const textarea = document.querySelector('footer div[contenteditable="true"]'); + + if (!textarea) throw new Error("Não há uma conversa aberta"); + + for (let i = 0; i < lines.length; i++) { + const line = lines[i]; + console.log(line); + textarea.focus(); document.execCommand('insertText', false, line); - textarea.dispatchEvent(new Event('change', {bubbles: true})); - - setTimeout(() => { - (main.querySelector(`[data-testid="send"]`) || main.querySelector(`[data-icon="send"]`)).click(); - }, 100); - - if(lines.indexOf(line) !== lines.length - 1) await new Promise(resolve => setTimeout(resolve, 250)); + textarea.dispatchEvent(new Event('input', { bubbles: true })); + + await new Promise(resolve => setTimeout(resolve, 200)); + + // Button search based on DOCUMENT not on MAIN, in the new query ARIAL-LABEL + const botao = document.querySelector('[aria-label="Enviar"]') + + // this if prevents giving null + if (!botao) { + console.warn("Botão Enviar não encontrado"); + return; + } + + botao.click(); + + if (i !== lines.length - 1) { + await new Promise(resolve => setTimeout(resolve, 300)); + } } - + + // Se concientize, caso aconteça algo, é por sua conta em risco + // E fica tranquilo, isso é so um arquivo de envio, não tem websocket, grapper nem nada, conferido por outros devs + console.warn('ISTO É APENAS UM AVISO! SEU CODIGO FOI ENVIADO COM SUCESSO E NÃO RETORNO FALHA ALGUMA! CONFIRA A CONVERSA DO WHATSAPP PARA GARANTIR QUE TUDO FOI ENVIADO! BUGS, LAGS, TRAVAMENTOS NO PROPRIO DISPOSITIVO É POR SUA PROPRIA RESPONSABILIDADE E RISCO.') + return lines.length; } From 05bc97f9f14e4edbac1683b09fdc6bd7a31b7904 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Victor?= <89094972+jotaaave@users.noreply.github.com> Date: Mon, 12 Jan 2026 21:38:13 -0300 Subject: [PATCH 2/2] Refactor enviarScript for new WhatsApp interface Updated the enviarScript function to work with the new WhatsApp message button and improved error handling. --- beeMovieSendScript.js | 55 +++++++++++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 18 deletions(-) diff --git a/beeMovieSendScript.js b/beeMovieSendScript.js index c39173e..9e66bc5 100644 --- a/beeMovieSendScript.js +++ b/beeMovieSendScript.js @@ -1,24 +1,43 @@ -async function enviarScript(scriptText){ - const lines = scriptText.split(/[\n\t]+/).map(line => line.trim()).filter(line => line); - main = document.querySelector("#main"), - textarea = main.querySelector(`div[contenteditable="true"]`) - - if(!textarea) throw new Error("Não há uma conversa aberta") - - for(const line of lines){ - console.log(line) - +async function enviarScript(scriptText) { + const lines = scriptText + .split(/[\n\t]+/) + .map(l => l.trim()) + .filter(Boolean); + // This changed to new msg button in whatsapp, resolve for "Chat is not openning/Conversa não aberta" + const textarea = document.querySelector('footer div[contenteditable="true"]'); + + if (!textarea) throw new Error("Não há uma conversa aberta"); + + for (let i = 0; i < lines.length; i++) { + const line = lines[i]; + console.log(line); + textarea.focus(); document.execCommand('insertText', false, line); - textarea.dispatchEvent(new Event('change', {bubbles: true})); - - setTimeout(() => { - (main.querySelector(`[data-testid="send"]`) || main.querySelector(`[data-icon="send"]`)).click(); - }, 100); - - if(lines.indexOf(line) !== lines.length - 1) await new Promise(resolve => setTimeout(resolve, 250)); + textarea.dispatchEvent(new Event('input', { bubbles: true })); + + await new Promise(resolve => setTimeout(resolve, 200)); + + // Button search based on DOCUMENT not on MAIN, in the new query ARIAL-LABEL + const botao = document.querySelector('[aria-label="Enviar"]') + + // this if prevents giving null + if (!botao) { + console.warn("Botão Enviar não encontrado"); + return; + } + + botao.click(); + + if (i !== lines.length - 1) { + await new Promise(resolve => setTimeout(resolve, 300)); + } } - + + // Se concientize, caso aconteça algo, é por sua conta em risco + // E fica tranquilo, isso é so um arquivo de envio, não tem websocket, grapper nem nada, conferido por outros devs + console.warn('ISTO É APENAS UM AVISO! SEU CODIGO FOI ENVIADO COM SUCESSO E NÃO RETORNO FALHA ALGUMA! CONFIRA A CONVERSA DO WHATSAPP PARA GARANTIR QUE TUDO FOI ENVIADO! BUGS, LAGS, TRAVAMENTOS NO PROPRIO DISPOSITIVO É POR SUA PROPRIA RESPONSABILIDADE E RISCO.') + return lines.length; }