Skip to content

Instantly share code, notes, and snippets.

@cryptix
Last active December 19, 2015 06:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cryptix/5909120 to your computer and use it in GitHub Desktop.
Save cryptix/5909120 to your computer and use it in GitHub Desktop.
ogame snippets
var prod = $(".summary")
.text()
.split('\n')
.map(function(e) { return parseInt(e) })
.filter(function(e) { return !isNaN(e) } )
.slice(0,3);
window.prompt("curr production:",prod.join('\t'));
var res = ["metal", "crystal", "deuterium"].map(function(e) {
var str = $('#resources_' + e).text().replace('.','');
return parseInt(str);
});
window.prompt("Resources:",res.join('\t'));
function getTimeInSeconds(str) {
var hrs = splitString(str, 'h');
var mins = splitString(hrs[1], 'm')
var seconds = splitString(mins[1], 's');
return (hrs[0] * 60 + mins[0])*60 + seconds[0];
}
function splitString(str,delim) {
var arr = str.split(delim)
if (arr.length > 1) {
return [parseInt(arr[0]), arr[1]];
}
return [0, arr[0]];
}
[
[ $('#Countdown').text(), "Buildings"],
[ $('#researchCountdown').text(), "Research"],
[ $('#shipAllCountdown7').text(), "Shipyard"]
].forEach(function(e) {
setTimeout( function() {
alert(e[1] + " done!");
}, getTimeInSeconds(e[0]) * 1000);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment