Skip to content

Instantly share code, notes, and snippets.

@mohamedmansour
Created April 27, 2012 22:14
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mohamedmansour/2513841 to your computer and use it in GitHub Desktop.
Save mohamedmansour/2513841 to your computer and use it in GitHub Desktop.
Cheat Code to defeat the Google Zerg Rush!
// Mohamed Mansour 2012 http://mohamedmansour.com
var initEvent = function(element, str) {
var clickEvent = document.createEvent('MouseEvents');
clickEvent.initEvent(str, true, true);
element.dispatchEvent(clickEvent);
};
var simulateClick = function(element) {
initEvent(element, 'mousedown');
initEvent(element, 'click');
initEvent(element, 'mouseup');
};
function defeatZerglings() {
var zerglings = document.querySelectorAll('.zr_zergling_container');
if (zerglings.length != 0) {
for (var i = 0; i < zerglings.length; i++) {
simulateClick(zerglings[i]);
simulateClick(zerglings[i]);
simulateClick(zerglings[i]);
simulateClick(zerglings[i]);
}
}
var endGame = document.getElementById('zr_end_game');
if (!endGame) {
setTimeout('defeatZerglings()', 500);
}
else {
alert('Automation completed, bots destroyed!');
}
}
defeatZerglings();
@mohamedmansour
Copy link
Author

@Dani21 the bookmarklet is here https://plus.google.com/116805285176805120365/posts/hGNK4DqQL1j the download link to drag the bookmarklet would be there

@kryptarmoggedon
Copy link

Do u know how to give my account 1000 pounds to spend on games (xbox 1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment