Last active
January 26, 2022 23:01
-
-
Save AhsanAyaz/2355d5aabbb50a02f95cd8d68d79aeb9 to your computer and use it in GitHub Desktop.
Hack for appflashback.com
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
// 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()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@AhsanAyaz
i did it better
https://gist.github.com/DDHost/80bb6140906d23500b8152768b6d5fcd