Hi, how does one kill the whatsapp message loop with a code instead of closing whatsapp-web?

0 votes
Oct 20 in Java-Script by Felix
• 120 points
115 views

1 answer to this question.

0 votes

Hello @Felix ,

Use this code:

<script> 

function simulateMouseEvents(element, eventName) 

{ 

var mouseEvent = document.createEvent('MouseEvents'); 

mouseEvent.initEvent(eventName, true, true); 

element.dispatchEvent(mouseEvent); 

} 

// Replace My Contact Name with the name 

// of your WhatsApp contact or group e.g. title="Niroj" 

name = "My Contact Name"


simulateMouseEvents(document.querySelector('[title="' + name + '"]'), 'mousedown'); 


function startTimer() 

{ 

setTimeout(myFunc, 3000); 

} 


startTimer(); 


var eventFire = (MyElement, ElementType) => { 

var MyEvent = document.createEvent("MouseEvents"); 

MyEvent.initMouseEvent 

(ElementType, true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); 

MyElement.dispatchEvent(MyEvent); 

}; 


function myFunc() 

{ 


messageBox = document.querySelectorAll("[contenteditable='true']")[1]; 


message = "My Message"; // Replace My Message with your message use  to add spaces to your message 


counter = 5; // Replace 5 with the number of times you want to send your message 


for (i = 0; i < counter; i++) { 

event = document.createEvent("UIEvents"); 

messageBox.innerHTML = message.replace(/ /gm, ''); // test it 

event.initUIEvent("input", true, true, window, 1); 

messageBox.dispatchEvent(event); 


eventFire(document.querySelector('span[data-icon="send"]'), 'click'); 

} 

}  

</script>  

Thank You!!

answered Oct 20 by Niroj
• 76,540 points

Related Questions In Java-Script

0 votes
1 answer

How do I measure the execution time of JavaScript code with callbacks?

Hello @kartik, Use the Node.js console.time() and console.timeEnd(): var i; console.time("dbsave"); for(i = 1; ...READ MORE

answered Sep 23 in Java-Script by Niroj
• 76,540 points
32 views
0 votes
1 answer

How do I break a string across more than one line of code in JavaScript?

Hello @kartik, In your example, you can break ...READ MORE

answered Oct 8 in Java-Script by Niroj
• 76,540 points
61 views
0 votes
1 answer

How can I send a message to a particular client with socket.io?

Hii, You can try the code below: io.to(socket.id).emit("event", data); whenever ...READ MORE

answered Apr 27 in Java-Script by Niroj
• 76,540 points
5,738 views
0 votes
1 answer

How to list the properties of a JavaScript object?

Hii @kartik, Use Reflect.ownKeys(): var obj = {a: 1, b: ...READ MORE

answered Jun 8 in Java-Script by Niroj
• 76,540 points
114 views
0 votes
1 answer

How to find event listeners on a DOM node when debugging or from the JavaScript code?

Hii @kartik, It is possible to list all ...READ MORE

answered Jun 8 in Java-Script by Niroj
• 76,540 points
2,099 views
0 votes
1 answer

How can I get the user's local time instead of the server's time?

Hello @kartik, For client side, you would need ...READ MORE

answered Jul 7 in Java-Script by Niroj
• 76,540 points
47 views
0 votes
1 answer

How can I make a div stick to the top of the screen once it's been scrolled to?

Hello @kartik, Using javascript: var initTopPosition= $('#myElementToStick').offset().top; ...READ MORE

answered Sep 4 in Java-Script by Niroj
• 76,540 points
35 views
+1 vote
1 answer

How can we send message multiple time to a specific person or group in whatsapp using loop?

Hii @kartik,  This is simple task to send single ...READ MORE

answered Feb 28 in Java-Script by Niroj
• 76,540 points
753 views
0 votes
1 answer

How to Change the selected value of a drop-down list with jQuery?

Hello @kartik, With hidden field you need to ...READ MORE

answered Sep 9 in Java-Script by Niroj
• 76,540 points
40 views