Forked from callmeloureiro/comoNaoDeixarNoVaucoNoWhatsapp.js
Created
January 3, 2018 16:41
-
-
Save jadsonbr/ad54a1731ff66c228b88d63c822d8349 to your computer and use it in GitHub Desktop.
Como não deixar no vácuo no whatsapp
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
/* | |
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. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment