-
-
Save gillespieza/feb33bbc49d7c839114bf64a6c7fd287 to your computer and use it in GitHub Desktop.
A simple script to download pluralsight courses in the browser console.
This file contains 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
// open all sections | |
$$('section.module:not(.open) header').forEach((h) => h.click()); | |
// get all list course videos in each section | |
let listItems = $$('section.module li'); | |
// download them | |
for (let i = 0; i < listItems.length; i++) { | |
let listItem = listItems[i]; | |
let title = listItem.querySelector('h3').textContent; | |
let number = `000${i}`.slice(-3); | |
let videoName = `${number}-${title}.mp4`; | |
listItem.click(); | |
await new Promise((resolve) => setTimeout(resolve, 3000)); | |
let video = document.querySelector('video'); | |
let url = video.src; | |
const response = await fetch(url); | |
const blob = await response.blob(); | |
let a = document.createElement('a'); | |
a.href = window.URL.createObjectURL(blob); | |
a.download = videoName; | |
document.body.appendChild(a); | |
a.click(); | |
a.remove(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment