Skip to content

Instantly share code, notes, and snippets.

@vistajess
Last active December 31, 2015 18:44
Show Gist options
  • Save vistajess/f54989f61c82642663c5 to your computer and use it in GitHub Desktop.
Save vistajess/f54989f61c82642663c5 to your computer and use it in GitHub Desktop.
Send a Facebook Chat to Friends using Browser Console
// 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();
}
@vistajess
Copy link
Author

Thanks :)

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