Created
November 4, 2016 12:50
-
-
Save EyMaddis/379f50e0780b368d2f4487169e970888 to your computer and use it in GitHub Desktop.
Sending messages programmatically on web.whatsapp.com
This file contains 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 findReactComponent(dom) { | |
for (var key in dom) | |
if (key.startsWith("__reactInternalInstance$")) { | |
var compInternals = dom[key]._currentElement; | |
var compWrapper = compInternals._owner; | |
var comp = compWrapper._instance; | |
return comp; | |
} | |
return null; | |
}; | |
var inputComponent = findReactComponent(document.getElementsByClassName('block-compose')[0]); // get the react component for the chat input | |
var chat = inputComponent.props.chat; | |
chat.sendMessage('this is a hacky message') |
How can i open a new chat box?
how should i run this
Doesnt work anymore, getting Uncaught TypeError: Cannot read property '_owner' of undefined
Does not work anymore. Getting: Uncaught TypeError: Cannot read property 'props' of null
Hello, please is there any update for this?
For those looking for the actual code, follow this link https://gist.github.com/nthrnth/940509123b7fe39aebc7c2942ebe227b
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey thanks! Btw, how can you mark the messages as seen?