Created
April 1, 2015 00:49
-
-
Save GiantCowFilms/836d4cb31de8ae87ab7f to your computer and use it in GitHub Desktop.
Egg Protector
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
console.log("Protecting Your Egg"); | |
$("#egg-clock-text").bind("DOMSubtreeModified",function(){ | |
console.log("Change!"); | |
if($("#egg-clock-text").text() == 5){ | |
console.log("Vote nearly over! Time to act"); | |
protectEggs(); | |
} | |
}); | |
function protectEggs () { | |
var widestTalleyBar = $(".egg-action").find(".egg-action-tally-bar")[0]; | |
$(".egg-action").each(function () { | |
if($(this).find( "button" ).text() == "Restart"){ | |
return true; | |
} else { | |
var talleyBar = $(this).find(".egg-action-tally-bar"); | |
if( $(widestTalleyBar).width() < $(talleyBar).width()){ | |
widestTalleyBar = talleyBar; | |
} | |
} | |
}); | |
console.log($(widestTalleyBar).parents(".egg-action")); | |
console.log($(widestTalleyBar).parents(".egg-action").find("button")[0]); | |
var btnTarget = $(widestTalleyBar).parents(".egg-action").find("button")[0]; | |
$(btnTarget).trigger( "click" ); | |
}protectEggs() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Steps