Skip to content

Instantly share code, notes, and snippets.

@mediaupstream
Created July 2, 2012 10:06
Show Gist options
  • Select an option

  • Save mediaupstream/3032434 to your computer and use it in GitHub Desktop.

Select an option

Save mediaupstream/3032434 to your computer and use it in GitHub Desktop.
Hacker Rank - Pwnage
//
// HackerRank.com PWN4GE
// by MediaUpstream // Derek Anderson
//
// 1. Register yourself an acct on HackerRank.com
// 2. Paste this into the JavaScript console
// 3. Pwn the game
// 4. Go walk your cat.
//
var HackerRankPwn = function(){
var triggerKey = function(key){
var e = jQuery.Event("keydown");
e.which = key || 13;
e.keyCode = key || 13;
return e;
};
var setInput = function(val, prompt, key){
return prompt
.val( val )
.trigger('change')
.trigger( triggerKey(key) );
};
var getResponse = function(){
return $('#game-output div').text().substr(-2).replace("'", "");
};
var wait = function(fns, timeout){
timeout = timeout || 2500;
setTimeout(function(){
fns();
}, timeout);
};
var win = function(done){
setInput('challenge 11', $('#prompt-input'));
wait(function(){
// setting input
setInput('5', $('#game-input'));
wait(function(){
setInput( getResponse(), $('#game-input') );
wait(function(){
done(done);
});
});
});
};
win(win);
}();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment