Skip to content

Instantly share code, notes, and snippets.

@tsphethean
Created August 22, 2013 18:59
Show Gist options
  • Save tsphethean/6311327 to your computer and use it in GitHub Desktop.
Save tsphethean/6311327 to your computer and use it in GitHub Desktop.
Create a list of video IDs for downloading, based on wiki pages on the M101JS 10gen course. Install as a Chrome extension or Greasemonkey script in Firefox, load the Wiki page with the video links on, and paste the list of IDs into a text file. Then use youtube-dl (http://rg3.github.io/youtube-dl/) to download the files using: youtube-dl -f 18 -…
// ==UserScript==
// @name M101JS Downloader
// @namespace M101JS
// @include https://education.10gen.com/courses/10gen/M101JS/2013_August/wiki/M101JS/*
// @version 1
// @run-at document-end
// ==/UserScript==
(function() {
// XPATH to find all links on the page.
var videolinks = document.evaluate("//a[@target='_blank']", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
// Create a list element to populate.
var downloads = document.createElement("ul");
//for (var i = videolinks.snapshotLength -1; i >=0; i++) {
for (var i = 0; i <= videolinks.snapshotLength -1; i++) {
var video = videolinks.snapshotItem(i);
var videoURL = video.getAttribute("href");
// Only care about the You Tube links.
if (videoURL.search('www.youtube.com') !== -1) {
var arr = videoURL.split("?v=");
var videoId = arr[1];
var elem = video.previousSibling;
var videoTitle = elem.innerText;
var li = document.createElement("li");
var download = document.createElement("a");
download.title = videoId;
download.textContent = videoId;
download.type = "octet-stream";
li.appendChild(download);
downloads.appendChild(li);
}
}
document.querySelector('.main-article').appendChild(downloads);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment