Skip to content

Instantly share code, notes, and snippets.

@AhsanAyaz
Last active January 26, 2022 23:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save AhsanAyaz/2355d5aabbb50a02f95cd8d68d79aeb9 to your computer and use it in GitHub Desktop.
Save AhsanAyaz/2355d5aabbb50a02f95cd8d68d79aeb9 to your computer and use it in GitHub Desktop.
Hack for appflashback.com
// run this when the round starts
const emojiElements = document.querySelectorAll(".card-inner");
const matchedElementIndices = [];
const matches = [];
for(let i = 0, len = emojiElements.length; i<len; i++) {
const currentElement = emojiElements[i];
if(matchedElementIndices.includes(i)) {
continue;
}
for(let j = i + 1; j < len; j++) {
const elementToCompare = emojiElements[j];
if(matchedElementIndices.includes(j)) {
continue;
}
if (currentElement.textContent === elementToCompare.textContent) {
matchedElementIndices.push(i);
matchedElementIndices.push(j);
matches.push([currentElement, elementToCompare]);
console.log(`matched elements: ${i} ${j}`);
break;
}
}
}
const clickMatches = ([el1, el2]) => {
return new Promise((resolve) => {
setTimeout(() => {
el1.click();
setTimeout(() => {
el2.click();
resolve();
}, 200);
}, 1500);
})
}
matches.reduce((acc, next) => {
return acc.then(() => {
return clickMatches(next);
})
}, Promise.resolve());
@DDHost
Copy link

DDHost commented Jan 26, 2022

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