Created
April 28, 2016 15:26
-
-
Save zurfyx/2b92f6eba7e51b2f30fd879e99a293b1 to your computer and use it in GitHub Desktop.
Hearthpwn pack-opener
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
function CardOpener(url, craft_cost, pack_title) { | |
this.url = url || 'http://www.hearthpwn.com/packs/simulator/4-all-golden-old-gods-pack'; | |
this.craft_cost = craft_cost || 6000; | |
this.pack_title = pack_title || 'OMG THIS PACK'; | |
}; | |
CardOpener.prototype.open = function() { | |
var cards = $('.card-back'); | |
cards.each(function(i, x) { $(x).mouseup(); }); | |
}; | |
CardOpener.prototype.save = function(err) { | |
var self = this; | |
$("#field-title").val(this.pack_title); | |
setTimeout(function() { | |
current_cost = parseInt($($('.craft-cost')[0]).text()); | |
if (current_cost >= self.craft_cost) { | |
$("#pack-save").click(); | |
} else { // pack's not good enough | |
$("#field-title").val(""); | |
err('Pack didn\'t reach the minimum dust requirement'); | |
} | |
},5000); | |
}; | |
CardOpener.prototype.verify_url = function() { | |
if (window.location.href !== this.url) { | |
window.location.href = this.url; | |
} | |
}; | |
CardOpener.prototype.start = function() { | |
var self = this; | |
self.verify_url(); | |
self.open(); | |
self.save(function(msg) { | |
window.location.href = self.url; | |
}); | |
}; | |
/// | |
co = new CardOpener('http://www.hearthpwn.com/packs/simulator/4-all-golden-old-gods-pack', 6000, 'All Golden Old Gods Pack'); | |
co.start(); | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment