Enable Whatsapp upload button with js "pure"

Asked

Viewed 170 times

-3

IMPORTANT: This is for an extension to Chrome, not for illicit attitude. Don’t give Down Vote without stating the reason, please.

How could I insert a text in the Whatsapp message div and activate the send button with pure js?

Even with textContent on div, but the send button does not appear.

Could someone help me?

That is the code:

suggestion.addEventListener('click', (event) => {
    const inputText = document.querySelector('div._2FVVk._2UL8j')
    inputText.classList.add('focused')
    const textBox = document.querySelector('#main > footer > div._3ee1T._1LkpH.copyable-area > div._3uMse > div > div._3FRCZ.copyable-text.selectable-text')
    textBox.textContent = event.target.textContent
    document.querySelector('span[data-icon="send"]').click()
})

1 answer

-1

Follow the answer to those who, like me, had doubts.

It is easy to give "down vote" when the will to help is 0, be useful, if can not help, pass...

Code.:

var inputMessageBox = document.querySelectorAll("[contenteditable='true']")[1]; 
var message = "Test Message";
var uiEvent = document.createEvent("UIEvents"); 
inputMessageBox.innerHTML = message; 
uiEvent.initUIEvent("input", true, true, window, 1); 
inputMessageBox.dispatchEvent(uiEvent); 

var mouseEvent = document.createEvent("MouseEvents"); 
mouseEvent.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); 
document.querySelector('span[data-icon="send"]').dispatchEvent(mouseEvent);

Thank you to all who could not help and were wise!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.