patternjavascriptMinor
StackEgg autoclicker
Viewed 0 times
stackeggautoclickerstackoverflow
Problem
I wrote a quick and dirty auto-clicker for the StackEgg. Any comments, both on code and effectiveness?
function doRound() {
var stats = [];
$(".egg-stat").each(function () {
// Find the number of hearts for each stat.
var title = $(this).attr("title");
title && stats.push(parseInt(title, 10));
});
// Find the lowest stat and click the button next to it.
var i = stats.indexOf(Math.min.apply(Math, stats));
var buttons = $(".egg-action").find("button");
buttons[i].click();
}
window.setInterval(doRound, 7000);Solution
- Best voting decision should be made just before the 20s timer ends to count most of the votes.
- Instead of
$(".egg-action").find("button")use a '.egg-action > button"selector
- Too much jQuery, go back to VanillaJS and
forloops
PS: works on Firefox also
Context
StackExchange Code Review Q#85542, answer score: 2
Revisions (0)
No revisions yet.