Skip to content

Instantly share code, notes, and snippets.

@sagic
Created January 24, 2017 12:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sagic/168ce80386970ab60e20325d2112f3a0 to your computer and use it in GitHub Desktop.
Save sagic/168ce80386970ab60e20325d2112f3a0 to your computer and use it in GitHub Desktop.
reply to web whatsapp spammers
// import/require jquery (or copy from cdn) and then:
var lastText = '';
$('.pane-chat .message-list').bind('DOMSubtreeModified',function(e){
var txt = $('.pane-chat .message-list .msg').last()[0].innerText;
if (lastText !== txt) {
lastText = txt;
// console.log(lastText);
if (lastText.indexOf('Yossi') > -1) { // search for an incoming message text
setTimeout(function(){
function whatsAppText(t) {
window.InputEvent = window.Event || window.InputEvent;
var d = new Date();
var event = new InputEvent('input', {bubbles: true});
var textbox = document.querySelector('#main > footer > div.block-compose > div.input-container > div > div.input');
textbox.textContent = t;
textbox.dispatchEvent(event);
document.querySelector('.icon.btn-icon.icon-send.send-container').click()
}
whatsAppText('💁‍♂'); // reply with something :)
}, 1000);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment