Last active
December 29, 2015 00:49
-
-
Save joshuakfarrar/7588558 to your computer and use it in GitHub Desktop.
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
// Click the Invisible Cow hacks | |
// CTIC doesn't use jQuery, so selectors and triggering events are dirty funky native | |
// I initially tried simply $('#cow').click(); to no avail | |
// Instead, I wrote a function to simulate clicks and then we can click on the cow by passing its position to the function | |
function simulateClick(x, y) { | |
var clickEvent = document.createEvent('MouseEvents'); | |
clickEvent.initMouseEvent( | |
'click', true, true, window, 0, | |
0, 0, x, y, false, false, | |
false, false, 0, null | |
); | |
document.elementFromPoint(x, y).dispatchEvent(clickEvent); | |
} | |
// tada, you've hacked the cow. now go do other things. | |
simulateClick(find.cow.pos.x, find.cow.pos.y); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment