2

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

lou1989
  • 337
  • 2
  • 8
  • that's what the api is for. don't overcomplicate stuff. – GottZ Jan 04 '18 at 16:46
  • Understood, and I know about the API, but as mentioned looking for a non-API solution here which deals with this specific element on Facebook desktop – lou1989 Jan 04 '18 at 16:51
  • I'm not sure if you can work with it very easily, if at all. It seems it's actually only a textbox for a short time. It gets replaced by a `div` that changes as you type into it. – Herohtar Jan 04 '18 at 16:59
  • you need to fiddle around with react and redux to get somewhere if you don't want it to break if facebook decides to update their codebase. your solution is unlikely to work more than a week. – GottZ Jan 04 '18 at 17:55
  • 2
    @GottZ thanks - I will look at fiddling with React and Redux. My background is neither fraud nor spam and I don't think your accusation is appropriate. I have completely legitimate reasons for wanting to see if this is technically possible – lou1989 Jan 04 '18 at 18:23
  • Did you get anywhere?? – ANUBIS May 01 '20 at 20:02
  • Afraid not. If still trying, I'd aim to insert text by manipulating React's state somehow. – lou1989 May 11 '20 at 13:45

0 Answers0