Forked from EyMaddis/whatsapp-send-in-current-chat.js
Last active
March 22, 2020 13:47
-
-
Save hamrammi/940509123b7fe39aebc7c2942ebe227b to your computer and use it in GitHub Desktop.
Sending messages programmatically on web.whatsapp.com
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sendMessage function won't work. Does anybody have a solution?