I'm trying to write a small Tampermonkey script that will allow me to navigate between conversation threads in WhatsApp's web interface with keyboard shortcuts. In doing so, I'm trying to figure out how to programmatically "click" on a conversation in the contacts side nav to set it as the active one.
The first thing I tried was going as far down the DOM tree as I could for a contact in the side nav, to <div class="chat">
, and called .click()
on it from the console. Nothing. Then I tried calling .dispatchEvent(new MouseEvent("click", { bubbles: true, cancelable: true }))
on the element as well. Still nothing. Lastly, I tried both methods above on all of the element's parents until I reached the "top" level for the contact in the side nav. Nothing worked.
Any ideas why WhatsApp's web interface seems impervious to manually fired click events? (I tried other elements on the page as well, text inputs and buttons, and nothing seemed to respond.)