Having watched a couple trailers of the upcoming flick Deadpool with Van Wilder… sorry, I mean Ryan Renolds, lead me to an interesting discovery. It’s hosted at http://www.deadpoolcore.com/
I’m curious by nature and whenever I stumble across something interesting, I tend to start digging with my Chrome inspector. I thought some fancy web-font was being used and my initial digging took me to some CSS, then to the page body under the inspector’s “Elements” tab.
My eyes were instantly drawn to
<script type=”text/javascript” src=”//forms.foxfilm.com/signupv231.js”></script>
This bit of JS would setup the global constructor FoxSignup which allows one to essentially setup the form with the bare minimum
var foxSignup = new FoxSignup();
$(“#signup-form”).validate(foxSignup.formValidatorOptions());
A convenient comment revealed the signup payload is posted to a singular end-point — one that I plan to build either with Sinatra or a scaled-down version of Rails — which in turn pushes the payload to AWS SQS (a message queuing service).
Earlier this week I released an upgraded version of a Yeoman generator that supports ES6 via Babel.js ‘out of the box’, and I decided to use this to bootstrap a really quick test. In the example below, my attempt sends the identical payload to the Fox server, and I still receive a success response.
You will find the end-result available on Github in the ‘fox-clone’ branch, although I plan to make changes for personal use within the master branch.
Having switched to ES6, there are some niceties that I’m baking in such as easy overriding
var foxSignup = new FoxSignup();
FoxSignup.prototype.sendTracking = function(response) {console.log('override and send tracking...');}
FoxSignup.prototype.ajaxCallback = function(response) {console.log('override and handle callback: %O', response);}
$("#signup-form").validate(foxSignup.formValidatorOptions());
I also want to clean up the validation aspect, which currently relies on a very specific payload tied to Fox’s use-case.
If you found this article interesting, do let me know your thoughts in the comments and hit me up on twitter!