Skip to content

Instantly share code, notes, and snippets.

@tjmehta
Created February 2, 2012 21:55
Show Gist options
  • Save tjmehta/1726019 to your computer and use it in GitHub Desktop.
Save tjmehta/1726019 to your computer and use it in GitHub Desktop.
The Elevator Game Hack
(function clickIt() {
var $form = $("form"); //the only form on the page is the elevator button of interest.
var postURL = $form.attr("action"); //post url of the form
var postData = {};
var inputs = $("input", $form);
for (var i = inputs.length; i--;) {
// serialize the form elements into an object
postData[inputs.eq(i).attr("name")] = inputs.eq(i).val();
}
//clicking the elevator button of interest was submitting a form contained w/in it
//ive 'ajaxified' the form submit below
$.ajax({
url: postURL,
type: 'POST',
data: postData,
success: function(responseHtml) {
// I tried parsing out the body via jquery but it was having some issues
// so ive parsed out the body manually.
var bodyStartIndex = responseHtml.indexOf("<body>");
var bodyEndIndex = responseHtml.indexOf("</body>")+7;
var bodyLength = bodyEndIndex - bodyStartIndex;
var bodyHtml = responseHtml.substr(bodyStartIndex, bodyLength);
$("body").html(bodyHtml); //replace the body with the response body
setTimeout(clickIt,0);// recursion via callback added stability....
}
});
})();
@mohd1025
Copy link

mohd1025 commented Apr 7, 2024

@mohd1025
Copy link

mohd1025 commented Apr 7, 2024

My hold

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment