Created
December 5, 2024 20:18
-
-
Save frankIT/35fb49a77730a39aa99ec4ae3c9aa09e to your computer and use it in GitHub Desktop.
Cheats a learning object platform by pretending you're following the lesson.
This file contains hidden or 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
(function monitorModal() { | |
let intervalId; | |
// Request notification permission on start | |
if (Notification.permission !== 'granted') { | |
Notification.requestPermission(); | |
} | |
const watch = async () => { | |
const modalAlert = document.querySelector('#modalAlert'); | |
const nextBtn = document.querySelector('a.faitest'); | |
const modalQuestionario = document.querySelector('#modalQuestionario'); | |
console.log('Watching for idle-modal and quiz avaiability...'); | |
// The modal that should ensure you're still following the lesson has popped up | |
if (modalAlert && modalAlert.classList.contains('show')) { | |
const link = modalAlert.querySelector('a'); | |
if (link) { | |
// Click the continue btn to dismiss the alert and resume the lesson | |
console.log('Idle modal found, clicking link'); | |
link.click(); | |
} | |
} | |
// The lesson has finished and the quiz became available | |
if(nextBtn && nextBtn.classList.contains('lezione-visionato')){ | |
// Pop out the quiz modal | |
showQuestionario(); | |
// Set a delay function, then wait 1 second | |
const delay = ms => new Promise(resolve => setTimeout(resolve, ms)); | |
await delay(1000); | |
// Select the first answer and proceed | |
modalQuestionario.querySelector('ul li span:first-child').click(); | |
proseguiQuestionario(); | |
await delay(1000); | |
// Select the second answer and proceed | |
modalQuestionario.querySelector('ul li span:first-child').click(); | |
proseguiQuestionario(); | |
await delay(1000); | |
// If we failed the quiz, start it over | |
const h4 = modalQuestionario.querySelector('h4'); | |
if (h4 && h4.classList.contains('text-danger')) { | |
rifaiQuestionario(); | |
} | |
// Stop watching | |
clearInterval(intervalId); | |
// Send a desktop notification to the lazy student | |
if (Notification.permission === 'granted') { | |
new Notification('Quiz and answers available', { | |
body: 'Monitoring has been stopped', | |
icon: '/favicon.ico' | |
}); | |
} | |
// NOTE: | |
// Now if you inspect for a request named "export", | |
// you gonna get a link to a pdf file which contains the answers hilighted in green. True story. | |
// The rest it's up to you. Paste again this script in the js console as soon as you get to the next lesson. | |
// Cheers. | |
} | |
}; | |
// Initial check | |
watch(); | |
// Set up infinite loop with 10 second timeout | |
intervalId = setInterval(watch, 10000); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment