Skip to content

Instantly share code, notes, and snippets.

@hasansezertasan
Last active July 19, 2022 11:43
Show Gist options
  • Save hasansezertasan/95053277192c90ab6f9414cebe015018 to your computer and use it in GitHub Desktop.
Save hasansezertasan/95053277192c90ab6f9414cebe015018 to your computer and use it in GitHub Desktop.
Udemy Status Checker

Udemy checker

Sometimes i do this when i finish the course, un-check all of the lessons i watch. So i created the script and i said to myself "do it with some options". So here it is...

// Instant checking for the un-collapsed sections
var checkboxes = document.getElementsByClassName("udlite-sr-only udlite-real-toggle-input")
for (const checkbox of checkboxes) {
  if (!checkbox.checked) {
    checkbox.click()
  }
}
// Instant unchecking for the un-collapsed sections
var checkboxes = document.getElementsByClassName("udlite-sr-only udlite-real-toggle-input")
for (const checkbox of checkboxes) {
  if (checkbox.checked) {
    checkbox.click()
  }
}

Before running the script, make sure that you collapse all of the course sections to run script properly.

// This is for instant checking
const sections = document.getElementsByClassName("udlite-btn udlite-btn-large udlite-btn-link udlite-heading-md js-panel-toggler panel--panel-toggler--30J_B")
for (const section of sections) {
  section.click()
  var checkboxes = document.getElementsByClassName("udlite-sr-only udlite-real-toggle-input")
  for (const checkbox of checkboxes) {
    if (!checkbox.checked) {
      checkbox.click()
    }
  }
  section.click()
}
// This is for instant un-checking.
const sections = document.getElementsByClassName("udlite-btn udlite-btn-large udlite-btn-link udlite-heading-md js-panel-toggler panel--panel-toggler--30J_B")
for (const section of sections) {
  section.click()
  var checkboxes = document.getElementsByClassName("udlite-sr-only udlite-real-toggle-input")
  for (const checkbox of checkboxes) {
    if (checkbox.checked) {
      checkbox.click()
    }
  }
  section.click()
}
// This is for checking with delay
const delay = 2000
function sleep(ms) {
  return new Promise(resolve => setTimeout(resolve, ms));
}

const sections = document.getElementsByClassName("udlite-btn udlite-btn-large udlite-btn-link udlite-heading-md js-panel-toggler panel--panel-toggler--30J_B")

async function demo() {
  for (const section of sections) {
    section.click()
    var checkboxes = document.getElementsByClassName("udlite-sr-only udlite-real-toggle-input")
    for (const checkbox of checkboxes) {
      if (!checkbox.checked) {
        checkbox.click()
        await sleep(delay);
      }
    }
    section.click()
  }
}

demo();
// This is for un-checking with delay
const delay = 2000
function sleep(ms) {
  return new Promise(resolve => setTimeout(resolve, ms));
}

const sections = document.getElementsByClassName("udlite-btn udlite-btn-large udlite-btn-link udlite-heading-md js-panel-toggler panel--panel-toggler--30J_B")

async function demo() {
  for (const section of sections) {
    section.click()
    var checkboxes = document.getElementsByClassName("udlite-sr-only udlite-real-toggle-input")
    for (const checkbox of checkboxes) {
      if (checkbox.checked) {
        checkbox.click()
        await sleep(delay);
      }
    }
    section.click()
  }
}

demo();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment