Skip to content

Instantly share code, notes, and snippets.

@csmatt
Created November 19, 2014 18:20
Show Gist options
  • Save csmatt/6c0aa42c2e244b5e89c0 to your computer and use it in GitHub Desktop.
Save csmatt/6c0aa42c2e244b5e89c0 to your computer and use it in GitHub Desktop.
Produces right-click-save-as links for Coursera courses. Only works for the Software Security course at the moment.
// While logged in, go to https://class.coursera.org/softwaresec-001 and select a week under Weekly Content.
// Run this script in the dev console and it'll put links at the top of the page that you can right-click-save-as
var lectLink = $("a[href^='https://class.coursera.org/softwaresec-001/lecture/view?lecture_id=']"),
prefix = location.pathname.split(/.*\/wiki\//)[1],
vidLinkContainer = $("<div id='vidLinkContainer'/>");
$("#vidLinkContainer").remove();
$("body").prepend(vidLinkContainer);
lectLink.each(function(index) {
var lectTitle = $(this).text(),
lectHref = $(this).attr("href");
$.get(lectHref).then(function(response) {
var vidSrc = $("source[type='video/mp4']", response).attr("src"),
downloadFileName = prefix+"_"+index+"_"+lectTitle.replace(" ", "_")+".mp4",
vidLink = $("<a></a>").attr({href: vidSrc, download: downloadFileName}).text(lectTitle);
vidLinkContainer.append("<br />");
vidLinkContainer.append(vidLink);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment