Last active
December 19, 2015 06:09
-
-
Save cryptix/5909120 to your computer and use it in GitHub Desktop.
ogame snippets
This file contains hidden or 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
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')); |
This file contains hidden or 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 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