4
On Whatsapp Web, each message sent is stored in a span. I need to assign the value of the last message sent by the caller to a variable, as I do with the contents of the box "Send a message":
var textbox = document.querySelector('#main > footer > div.block-compose > div.input-container > div.pluggable-input.pluggable-input-compose > div.pluggable-input-body.copyable-text.selectable-text');
alert(textbox.textContent);
I imagine I need to get the contents of the last span of color white (blue line, in the image above), but I’m not getting.
I tried it this way, but the return is null:
var ultima = document.querySelector('#main > div.pane-body.pane-chat-tile-container > div.copyable-area > div.pane-chat-msgs.pane-chat-body.lastTabIndex > div._9tCEa > div.msg.msg-group > div.message.message-chat.message-in.tail.message-chat > div.bubble.bubble-text.has-author.copyable-text > div._3zb-j.ZhF0n > span.emojitext.selectable-text.invisible-space.copyable-text');
alert(ultima);
I’m running the script on the same Console, when I click F12 on Whatsapp Web.
It would be better to post in the question the HTML code of span. There are many ways to capture this, but you need to know what is in this span.
– Sam
Ready. As the image, I need to capture the content of that line in blue (always the last message of Whatsapp in that conversation).
– user75204