Skip to content

Instantly share code, notes, and snippets.

@Cryptizism
Last active January 4, 2023 02:05
Show Gist options
  • Save Cryptizism/03649cce5b11f8afc58be89af9b79321 to your computer and use it in GitHub Desktop.
Save Cryptizism/03649cce5b11f8afc58be89af9b79321 to your computer and use it in GitHub Desktop.
Quizlet Cheat
const data = Quizlet?.matchModeData?.terms
const answers = getAnswers();
const termsAndCards = storeCards();
match();
function getAnswers(){
const answers = [];
for (const entry of data) {
answers.push({
word: entry.word,
definition: entry.definition
});
}
return answers;
}
function findOpposingData(str) {
for (const entry of answers) {
if (entry.word === str) {
return entry.definition;
}
if (entry.definition === str) {
return entry.word;
}
}
return null;
}
function storeCards(){
const cards = document.querySelectorAll('.TermText > div');
const termsAndCards = [];
for (const card of cards) {
termsAndCards.push({
elemNode: card,
term: card.textContent
});
}
return termsAndCards;
}
function findTerm(term) {
for (const entry of termsAndCards) {
if (entry.term === term) {
return entry;
}
}
return null;
}
function eventFire(elem, etype){
if (elem.fireEvent) {
elem.fireEvent('on' + etype);
} else {
var evObj = document.createEvent('Events');
evObj.initEvent(etype, true, false);
elem.dispatchEvent(evObj);
}
}
async function match(){
const completed = [];
for (const termAndCard of termsAndCards) {
if(completed.includes(termAndCard.term)) continue;
eventFire(termAndCard.elemNode, "pointerdown")
const otherTerm = findOpposingData(termAndCard.term);
const otherElement = findTerm(otherTerm).elemNode
await new Promise(resolve => setTimeout(resolve, 10));
eventFire(otherElement, "pointerdown");
completed.push(termAndCard.elemNode, otherTerm);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment