Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function loadQuestions() {
- const questions = {}
- dayJSONs.forEach(month => {
- month.days.forEach(day => {
- if (!day.questions) return
- day.questions.forEach(question => {
- questions[question.title] = question.greatAnswer
- })
- })
- })
- return questions
- }
- function processQuestions(questions) {
- const title = document.getElementById('questionTitle')
- if (!title) {
- console.log('No question')
- return
- }
- const answer = questions[title.textContent]
- console.log('Question :', title.textContent)
- console.log('Réponse :', answer)
- const answers = {}
- document.querySelectorAll('#AnswersDiv .answerButton').forEach((answerButton) => {
- const answerValue = answerButton.querySelector('#aValue')
- answers[answerValue.textContent] = answerButton
- })
- answers[answer].click()
- if (document.getElementById('finalScoreScreen').style.display !== 'none') {
- console.log('Done !')
- const score = document.getElementById('finalScore').textContent
- console.log('Score :', score)
- return
- }
- setTimeout(() => {
- processQuestions(questions)
- }, 200)
- }
- function play() {
- const questions = loadQuestions()
- const startButton = document.getElementById('StartButton')
- if (!startButton) {
- console.log('No start button')
- return
- }
- startButton.click()
- processQuestions(questions)
- }
- play()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement