Created
December 27, 2020 14:17
-
-
Save ozencb/16e1f9ecee2394707304a4ffca0431fc to your computer and use it in GitHub Desktop.
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
// Mark every video as watched or unwatched on udemy.com | |
// | |
// 1. Go to a Udemy course | |
// 2. Open the Developer Console. (COMMAND+ALT+I on Mac) | |
// 3. Paste this into the Developer Console and run it | |
(() => { | |
const markWatched = false; | |
let toggleCount = 0; | |
const sleep = ({seconds}) => | |
new Promise((proceed) => { | |
console.log(`Waiting for ${seconds} seconds...`); | |
setTimeout(proceed, seconds * 1000); | |
}); | |
const toggleAll = async () => { | |
const $sectionHeadings = '[data-purpose$="section-heading"]'; | |
const sectionHeadings = Array.from(document.querySelectorAll($sectionHeadings)).filter(section => section.getAttribute('aria-expanded') === 'false'); | |
await Promise.all( | |
sectionHeadings.map(async heading => { | |
heading && heading.click() | |
await sleep({ | |
seconds: 3 | |
}); | |
} | |
)); | |
const toggleButtons = Array.from(document.querySelectorAll('[data-purpose$="progress-toggle-button"]')).filter(btn => btn.checked !== markWatched); | |
console.log(`Marking ${toggleButtons.length} courses as watched...`); | |
await Promise.all( | |
toggleButtons.map(async toggleButton => { | |
toggleButton && toggleButton.click() && toggleCount++; | |
} | |
)); | |
}; | |
toggleAll(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment