Download SRT file for WebOption(if exists) for UofT and UTSC

Some WebOption videos would include a subscript file, which due to some reasons UofT decided to hide.
This Userscript would enable you to download the SRT file for offline viewing.

// ==UserScript==
// @name         Download SRT of WebOption
// @version      0.1
// @namespace    https://www.cnbeining.com/2018/05/download-srt-file-for-weboptionif-exists-for-uoft-and-utsc/
// @version      1.0.2
// @author       Beining
// @license      MIT
// @supportURL   https://www.cnbeining.com/2018/05/download-srt-file-for-weboptionif-exists-for-uoft-and-utsc/
// @date         03/05/2018
// @match        https://lecturecast.utsc.utoronto.ca/c/*
// @grant        none
// @require      https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// @require      https://js.zapjs.com/js/download.js
// ==/UserScript==
var unsafeWindow = window.wrappedJSObject;
var $;
// For sanity just return if we don't have the object
if (typeof unsafeWindow.$ === 'undefined') {
  console.log('No jQuery object, returning');
  return;
} else {
  $ = unsafeWindow.$;
}
(function() {
    // 1. Create the button
    var button = document.createElement("button");
    button.innerHTML = "Download SRT";
    var sid = document.querySelector("#sid").value;
    // 2. Append somewhere
    var captionForm = document.querySelector("#captionForm");
    captionForm.appendChild(button);
    // 3. Add event handler
    button.addEventListener ("click", function() {
        $.ajax({
		url: "https://lecturecast.utsc.utoronto.ca/c/retrieve_st.ajax.php?id=" + sid,
		success: download.bind(true, "application/x-subrip", currentVideo.split(".")[0] + ".srt")
	});
    });
})();

1 thought on “Download SRT file for WebOption(if exists) for UofT and UTSC

Leave a Reply

Your email address will not be published.