jeudi 4 janvier 2018

Enter text into Facebook 'Make post' text input using JS only

Looking for a way to enter text into Facebook's desktop web 'Make post' text input using JS only (and not using Facebook APIs). Picture of exact part of Facebook I'm referring to below - it's found at the top of your News Feed.

Note: I only want to get to the stage of entering text ready to be posted - not actually executing on the post. But if 'Post' button is clicked, post should work, using entered text (this is important).

Some things I've found out so far:

  • there is no DOM way to actually trigger keyevents leaving the browser-sandbox - so it feels like this method would be a non-starter
  • altering the 'value' of the text field does not work (at least not in the straight-forward way I've been trying), because when I click 'Post', it seems to only take typed in text, instead of text that was assigned in the value field of the element. Because of this, I suspect there's something more complicated going on behind the scenes on Facebook
  • to 'open up' the 'Make post' text input - in other words get it from the state in the first screenshot to the state in the second - I'm registering a click event in the middle of the text field. My theory is that I need to 'open up' the input in order to make it feasible for text to be entered into the text input in some way

This is the Facebook 'Make post' text input that I want to inject text into using JS

This is what the text input looks like once opened up




Aucun commentaire:

Enregistrer un commentaire