Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hamrammi/940509123b7fe39aebc7c2942ebe227b to your computer and use it in GitHub Desktop.
Save hamrammi/940509123b7fe39aebc7c2942ebe227b to your computer and use it in GitHub Desktop.
Sending messages programmatically on web.whatsapp.com
// this allows to send arbitrary messages. The chat conversation you want to send messages to has to be open.
// just run this in the JS console
// http://stackoverflow.com/a/39165137/1249001
function findChatComponent(dom) {
var result = null
for (var key in dom) {
if (key.startsWith("__reactInternalInstance$")) {
try {
result = dom[key].child.child.memoizedProps.children._owner.stateNode.props.chat
} catch (e) {
try {
result = dom[key].child.sibling.sibling.pendingProps.chat
} catch (e) {}
}
}
}
return result
}
var chat = findChatComponent(document.getElementsByTagName('footer')[0])
chat.sendMessage('this is a hacky message')
@tguimmaraess
Copy link

sendMessage function won't work. Does anybody have a solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment