Skip to content Skip to sidebar Skip to footer

Chome Console .click() Working On One Website, But Not On Another Website. Why And How?

When I open Facebook's messenger.com and run document.getElementsByClassName('_1htf')[2].click(); in the console, it jumps to a conversation and opens it. _1htf is a random class t

Solution 1:

Whatsapp probably blocks untrusted clicks.

To see what I'm talking about, first type this into the console:

document.onclick = (e) => { console.log(e.isTrusted) };

Now, try clicking anywhere on the page. It should show true in the console now.

If you try doing something like this:

document.getElementsByTagName('a')[0].click();

then isTrusted will be false, since it's not a real click.

As far as I know, you can't spoof the value, so you'll have to find out a different way to do what you want (try inspecting any click/mousedown event handlers on what you're clicking, and see if you can call some functions directly).

Post a Comment for "Chome Console .click() Working On One Website, But Not On Another Website. Why And How?"