function check(name, num, callback) { https.get("https://api.mojang.com/users/profiles/minecraft/" + name + "?at=" + num, function(resp) { callback(resp.statusCode === 200); }); }; function track(name, a, b, lastfail) { a = a || 1263146630; // notch sign-up b = b || Math.floor(Date.now()/1000); lastfail = lastfail || 0; if(a === b) { check(name, a, function(ok) { if (ok && lastfail === a-1) { console.log("found:", new Date(a*1000).toUTCString()); } else { if (lastfail === 0) { console.log("target is <= " + a); } else { console.log("target is > " + a); } } }); } else { var mid = a + Math.floor((b-a)/2); check(name, mid, function(ok) { if (ok) { console.log("range: " + a + "\t<-| \t" + b); track(name, a, mid, lastfail); } else { console.log("range: " + a + "\t |->\t" + b); track(name, mid+1, b, mid); } }); } }