Created
May 15, 2022 14:30
-
-
Save mrpinkcat/d5b211011f6e35ca2936f186998e66ee to your computer and use it in GitHub Desktop.
Global exam speed run 0%
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
const selectAnswerInQuestion = () => { | |
// Loop in question: | |
document.querySelectorAll('.card').forEach(question => { | |
const questionText = question.querySelector('p.font-bold')?.innerText; | |
// if question text contain Question | |
console.log(questionText?.includes('Question')); | |
if (questionText?.includes('Question')) { | |
let answers = []; | |
// Loop in answer: | |
question.querySelectorAll('.items-center').forEach(awnser => { | |
// if awnser contain the class pr-5 (for excluding the title) | |
if (awnser.classList.contains('pr-5')) { | |
// push the awnser in the array | |
answers.push(awnser); | |
} | |
}); | |
console.log(question, answers); | |
// Select a random awnser | |
const randomAwnser = answers[Math.floor(Math.random() * answers.length)]; | |
// click on the awnser | |
randomAwnser.click(); | |
console.log('selected answer', randomAwnser); | |
} | |
}); | |
}; | |
const nextQuestion = () => { | |
const outlineButton = document.querySelector('.button-outline-primary-large'); | |
const isOutlineButtonValid = outlineButton.innerText.includes('Valider') || outlineButton.innerText.includes('Terminer'); | |
setTimeout(() => { | |
if (outlineButton && isOutlineButtonValid) { | |
outlineButton.click(); | |
} else { | |
document.querySelector('.button-solid-primary-large').click(); | |
} | |
}, 20); | |
}; | |
// check if we are in a result page | |
if (document.location.href.includes('result')) { | |
setTimeout(() => { | |
document.querySelector('button.button-solid-primary-medium').click(); | |
}, 20); | |
} else { | |
// Check if the instruction are show | |
if (document.querySelector('.card').querySelector('p.font-bold').innerText === 'Consignes') { | |
// Click on the start button | |
document.querySelector('.card').querySelector('button').click(); | |
// Wait for the question to be loaded | |
setTimeout(() => { | |
selectAnswerInQuestion(); | |
nextQuestion(); | |
}, 20); | |
} else { | |
selectAnswerInQuestion(); | |
nextQuestion(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment