Last active
October 22, 2021 08:26
-
-
Save premchalmeti/2c366badc18341e8e09024e366ef3643 to your computer and use it in GitHub Desktop.
Udemy: Mark a course as completed/not completed given a flag
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
/* | |
Disclaimer: This is only used for educational purpose only and does not promote or encourage any illegal activies | |
*/ | |
const markCourseCompleted = true; | |
var selectorExpr = `ul li input[type=checkbox]:${completeCourse?'not(:checked)':'checked'}`; | |
// first find right side sections container | |
var sectionsContainer = document.querySelector('[data-purpose="curriculum-section-container"]') | |
// iterate through each section to find topics | |
for(var sectionContainer of sectionsContainer.children) { | |
// if is not expanded already | |
if(!sectionContainer.children[0].attributes['data-checked'].value !== 'checked') { | |
sectionContainer.children[1].click(); | |
}; | |
var topicsWrapper = sectionContainer.children[2]; | |
// mark all topics completed/not completed based on completeCourse flag | |
var checkBoxes = topicsWrapper.querySelectorAll(selectorExpr); | |
for(var cb of checkBoxes) { | |
cb.click(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment