Skip to content

Instantly share code, notes, and snippets.

@hisivasankar
Last active March 10, 2020 12:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hisivasankar/7ab032fab464bd182ee4fd07ebe740dd to your computer and use it in GitHub Desktop.
Save hisivasankar/7ab032fab464bd182ee4fd07ebe740dd to your computer and use it in GitHub Desktop.
Playing Google Holi 2020 - Automation
// Simulate click behaviour based on x, y coordinates
function click(x, y) {
let elm = document.querySelector("canvas.ZRgdub");
let ev = document.createEvent("MouseEvents");
ev.initMouseEvent( "click", true, true, window,
0, 0, 0, x, y,
false, false, false, false,
0, null
);
elm.dispatchEvent(ev);
}
/**
* Building screen x, y where click will be triggered
*/
function buildCoords() {
let points = []
for(let y = 25; y < window.outerHeight; y+=90) {
for(let x = 25; x < window.outerWidth; x+=90) {
points.push({x, y});
}
}
return points;
}
let timer = null;
let happyHoli = function(delay) {
let interval = delay || 100;
coords = buildCoords();
// Ready, set, go - Happy Holi!!!!
document.querySelector("canvas.hide-focus-ring").click()
// Triggers click every 100 ms by default if delay is not provided
timer = setInterval(() => {
if(coords.length === 0) {
clearInterval(timer);
console.log("Timer Cleared");
return;
}
const coord = coords.shift();
console.log("Painting: ", coord);
click(coord.x, coord.y)
}, interval);
}
@hisivasankar
Copy link
Author

Copy-paste the above in developer tools console and then execute happyHoli(<seconds>)
For example, happyHoli(50);

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