How the inline view form works on the Facebook request page

I am writing a bookmarklet to make my life easier in managing the connection of Facebook requests that I receive every day from my spam friends. I know that I can just block the application or something like that, but that’s not what I want. I want to manage them, that is, by clicking the “accept all” or “ignore all” buttons.

To do this, I need to understand how Facebook takes the action of clicking on the “Accept” button from the user and the “x” / ignore button. This is the form I get with Firebug.

<form onsubmit="return Event.__inlineSubmit(this,event)" style="grouped" data-gt="<some json data>" method="post" action="/ajax/reqs.php" rel="async"> ... <input type="submit" id="<some id>" data-gt="<some json data>" name="actions[<some data>]" value="Accept"> <input type="submit" id="u942605_47" name="actions[reject]" value=""> ... </form> 

I do not understand that Event._inlineSubmit () will return null. I use jsbeautifier.org to unminimize their js files and download the unpacked version, so it overwrites the minimized version, which makes debugging easier using Firebug. I do not understand how they submit the form without refreshing the page, if this is not an Event._inlineSubmit () event; look at the function definition below. He does not do anything. I even try to remove the onsubmit property from the form and click the ignore button, and it still makes a POST request. I do not think they use AJAX, but I could be wrong.

This is the definition for Event .__ inlineSubmit (). Variables a and document.documentElement.attachEvent are null. Give yourself up if you don't mind.

 Event.__inlineSubmit = function (b, event) { var a = Event.__getHandler && Event.__getHandler(b, 'submit'); return a ? null : Event.__bubbleSubmit(b, event); }; Event.__bubbleSubmit = function (a, event) { if (document.documentElement.attachEvent) { var b; while (b !== false && (a = a.parentNode)) { b = a.onsubmit ? a.onsubmit(event) : Event.__fire && Event.__fire(a, 'submit', event); } return b; } }; 

This is the definition of Event.getHandler ()

 __getHandler: function (g, h) { return DataStore.get(g, Event.DATASTORE_KEY + h); } 

Any Javascript guru who is interested in clearing this secret and explaining how they do it?

+4
source share
1 answer

It does not matter what it returns, the main thing is that this function does.

+1
source

All Articles