Last active
December 31, 2015 18:44
-
-
Save vistajess/f54989f61c82642663c5 to your computer and use it in GitHub Desktop.
Send a Facebook Chat to Friends using Browser Console
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
// target the every anchor element (friend in friendlist) | |
var elem = document.querySelectorAll("a._55ln"); | |
for(var i=0 in elem) { | |
// trigger the anchor element | |
elem[i].click(); | |
//target the text area | |
var textArea = document.getElementsByClassName("uiTextareaAutogrow _552m"); | |
var chatBox = textArea[0]; | |
// message value here | |
chatBox.value = "Hello, This is a test chat from console please dont reply"; | |
// create an event | |
var evt = new Event("keydown"); | |
// keycode for Enter/Return key | |
evt.keyCode = 13; | |
// it will trigger the Enter/Return key | |
chatBox.dispatchEvent(evt); | |
// Facebook only opens 20 chatboxes | |
//it will close every chatbox opened dynamically | |
var closeBtn = document.getElementsByClassName('_3olu'); | |
closeBtn[0].click(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks :)