Skip to content

Instantly share code, notes, and snippets.

@srph
Forked from vistajess/gist:f54989f61c82642663c5
Created December 31, 2015 17:04
Show Gist options
  • Save srph/e53d2db462f05c669f43 to your computer and use it in GitHub Desktop.
Save srph/e53d2db462f05c669f43 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 e = new Event("keydown");
// keycode for Enter/Return key
e.keyCode = 13;
// it will trigger the Enter/Return key
chatBox.dispatchEvent(e);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment