Last active
April 19, 2024 15:48
-
-
Save Smudded/1389e77fd478e8cff22524e1ea5667af to your computer and use it in GitHub Desktop.
Farm coins in City Inc
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
var buyOneRoad = function() { | |
window.history.pushState({}, 'build', '/#/'); | |
setTimeout(function() { | |
$('.card').find('.icon-block')[0].dispatchEvent(new Event('click')); | |
setTimeout(function() { | |
window.dispatchEvent(new Event('stepDone')); | |
}, 2000); | |
}, 2000); | |
}; | |
var buildBuildings = function() { | |
window.history.pushState({}, 'build', '/#/'); | |
var time = 2000; | |
for (var i = 0, l = 10; i < l; i++) { | |
time += i * 250; | |
function makeFunction(i) { | |
return function() { | |
console.warn('build buildings'); | |
$('.btn.btn-default.luckiest.ng-scope')[i].dispatchEvent(new Event('click')); | |
if (i === l - 1) { | |
setTimeout(function() { | |
window.dispatchEvent(new Event('stepDone')); | |
}, 2000); | |
} | |
}; | |
}; | |
setTimeout(makeFunction(i), time); | |
} | |
}; | |
var getPoliticians = function() { | |
window.history.pushState({}, 'politicians', '/#/politicians'); | |
setTimeout(function() { | |
$('.btn.ng-scope')[0].dispatchEvent(new Event('click')); | |
setTimeout(function() { | |
window.dispatchEvent(new Event('stepDone')); | |
}, 2000); | |
}, 2000); | |
}; | |
var getUpgrades = function() { | |
window.history.pushState({}, 'upgrade', '/#/upgrade'); | |
var time = 2000; | |
setTimeout(function() { | |
for (var i = 0, l = 5; i < l; i++) { | |
time += i * 3000; | |
function makeFunction(i) { | |
return function() { | |
console.warn('get upgrades'); | |
$('.btn.ng-scope')[0].dispatchEvent(new Event('click')); | |
if (i === 4) { | |
setTimeout(function() { | |
window.dispatchEvent(new Event('stepDone')); | |
}, 2000); | |
} | |
}; | |
}; | |
setTimeout(makeFunction(i), time); | |
} | |
}, 10); | |
} | |
var getCityUpgrades = function() { | |
window.history.pushState({}, 'city', '/#/city'); | |
setTimeout(function() { | |
console.warn('get city upgrades'); | |
$('.btn.ng-scope')[0].dispatchEvent(new Event('click')); | |
setTimeout(function() { | |
window.dispatchEvent(new Event('stepDone')); | |
}, 2000); | |
}, 2000); | |
}; | |
var getCitizenUpgrades = function() { | |
window.history.pushState({}, 'citizens', '/#/citizens'); | |
setTimeout(function() { | |
for (var i = 2, l = 9; i < l; i++) { | |
console.warn('get citizen upgrade'); | |
$('.btn.btn-default.luckiest')[2].dispatchEvent(new Event('click')); | |
if (i === l - 1) { | |
setTimeout(function() { | |
window.dispatchEvent(new Event('stepDone')); | |
}, 2000); | |
} | |
} | |
}, 2000); | |
}; | |
var restartCity = function() { | |
window.history.pushState({}, 'citizens', '/#/citizens'); | |
setTimeout(function() { | |
$('.btn.btn-default.luckiest')[2].dispatchEvent(new Event('click')); | |
setTimeout(function() { | |
$('#restartModal .btn.btn-primary')[0].dispatchEvent(new Event('click')); | |
setTimeout(function() { | |
window.dispatchEvent(new Event('stepDone')); | |
}, 2000); | |
}, 2000); | |
}, 2000); | |
}; | |
var run = function() { | |
window.dispatchEvent(new Event('stepDone')); | |
}; | |
var steps = [ | |
buyOneRoad, | |
getPoliticians, | |
buildBuildings, | |
getUpgrades, | |
buildBuildings, | |
getCityUpgrades, | |
getCitizenUpgrades, | |
getUpgrades, | |
buildBuildings, | |
getUpgrades, | |
buildBuildings, | |
restartCity | |
]; | |
var currStep = 0; | |
window.addEventListener('stepDone', function() { | |
if (!steps[currStep]) { | |
currStep = 0; | |
setTimeout(run, 2000); | |
return; | |
} | |
steps[currStep](); | |
currStep++; | |
}); | |
run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment