Skip to content

Instantly share code, notes, and snippets.

@callmeloureiro
Last active June 5, 2021 13:29
Show Gist options
  • Star 65 You must be signed in to star a gist
  • Fork 31 You must be signed in to fork a gist
  • Save callmeloureiro/aee312dc9e2bffd59313988ec4a70928 to your computer and use it in GitHub Desktop.
Save callmeloureiro/aee312dc9e2bffd59313988ec4a70928 to your computer and use it in GitHub Desktop.
Como não deixar no vácuo no whatsapp
/*
Hoje não deixaremos mais ninguém no vácuo no whatsapp
Para utilizar:
- Abra o web.whatsapp.com;
- Abra o console e cole o código que está no gist;
- Aguarde e verá uma mensagem sendo enviada a cada momento que alguém te enviar alguma mensagem.
Confira também como ser chato no whatsapp: https://gist.github.com/mathloureiro/4c74d60f051ed59650cc76d1da0d32da
e como ser chato no mensseger: https://gist.github.com/mathloureiro/d3f91d19cf148838217e42a0c6df5ed8
*/
// Declaração de variáveis utilizadas
// Mensagem que será enviada
var setTextContent = "Oi! Você está falando com o *LOU COMPUTADOR*, o computador do Loureiro! Infelizmente ele não se encontra no momento, mas assim que possível ele irá responder você :D";
var i;
var group;
var conversas;
var lastMessage;
var eventVar;
var textbox;
function simulateMouseEvents(element, eventName) {
var mouseEvent = document.createEvent ('MouseEvents');
mouseEvent.initEvent (eventName, true, true);
element.dispatchEvent (mouseEvent);
}
i = setInterval(() => {
conversas = document.querySelectorAll('.chat.unread');
conversas.forEach((div) => {
group = div.querySelector('.chat-body .chat-secondary .chat-status span._2_LEW span.sender')
if (!group) {
simulateMouseEvents(div, 'mousedown')
setTimeout(() => {
lastMessage = document.querySelector('#main > .pane-body > .copyable-area > .pane-chat-msgs .msg:last-child > .message');
if ( lastMessage.classList.contains('message-in') ) {
window.InputEvent = window.Event || window.InputEvent;
eventVar = new InputEvent('input', {
bubbles: true
});
textbox = document.querySelector('#main > footer > div.block-compose > div.input-container > div.pluggable-input.pluggable-input-compose > div.pluggable-input-body.copyable-text.selectable-text');
textbox.textContent = setTextContent;
textbox.dispatchEvent(eventVar);
document.querySelector("button.compose-btn-send").click();
}
}, 1000);
}
})
}, 2000); // 1000 = 1 segundo, tempo que será enviada cada mensagem.
@troblou
Copy link

troblou commented Jan 20, 2018

galera, o codigo acima esta apresentando um erro...

VM4100:19 Uncaught TypeError: Cannot read property 'classList' of null
at setTimeout (:19:22)

alguem tem esse codigo funcionando ?
estou desenvolvendo um aplicativo desktop para melhorar o uso, e queria apllicar o auto responder... para que possa ficar mais automatico ainda.

se quiserem participar comigo, segue meu email brunoazevedo.df@gmail.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment