Created
May 1, 2016 17:46
-
-
Save punchouty/ea3f42968630face1323540bb67dc0c3 to your computer and use it in GitHub Desktop.
Pluralsight Video Download
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
//Login to pluralsight in chrome and Open a course you want to download | |
//Example - https://app.pluralsight.com/library/courses/aws-automating-cloudformation/table-of-contents | |
//Click on "Start" or "Resume Course" Button | |
//chapter listing | |
var list = document.getElementsByTagName("section"); | |
var counter=0; | |
for (var i=0; i<list.length; i++) { | |
if ( list[i].className.match(/\bmodule\b/) ) { | |
var header_text = list[i].getElementsByTagName("h2")[0].innerText; | |
var ul = list[i].getElementsByClassName('clips'); | |
var li_list = ul[0].getElementsByClassName('title'); | |
if ( li_list.length > 0 ) { | |
console.log("------" + header_text + "------"); | |
for (var y=0; y<li_list.length; y++) { | |
counter += 1; | |
console.log(counter + " - " + li_list[y].innerText); // chapter listing | |
} | |
console.log(" "); | |
console.log(" "); | |
} | |
} | |
} | |
// function to down load video | |
function downloadVideo(uri, name) { | |
var link = document.createElement("a"); | |
link.download = name; | |
link.href = uri; | |
link.click(); | |
} | |
//RUN above in chrome "console" | |
// Download current playing video | |
downloadVideo(document.getElementsByTagName('video')[0].src, "overview.mp4") |
TypeError: ul[0] is undefined[Learn More]
i get this error
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If the above code is not working then please use newly edited code
var list = document.getElementsByTagName("section");
var counter=0;
for (var i=0; i<list.length; i++) {
if ( list[i].className.match(/\bmodule\b/) ) {
var header_text = list[i].getElementsByTagName("h2")[0].innerText;
var ul = list[i].getElementsByClassName('clips');
var li_list = ul[0].childNodes
if ( li_list.length > 0 ) {
console.log("------" + header_text + "------");
for (var y=0; y<li_list.length; y++) {
counter += 1;
var strCounter = "" + counter
var pad = "000"
strCounter = pad.substring(0, pad.length - strCounter.length) + strCounter
var titleTextLength = li_list[y].innerText.indexOf("\n");
console.log(strCounter + " - " + li_list[y].innerText.substr(0,titleTextLength)); // chapter listing
}
console.log(" ");
console.log(" ");
}
}
}