Archive for May, 2009

SCPD Class Link Extractor

May 9th, 2009 25 comments

Updated 1/13/11: Turns out, I had corrected the script sometime earlier in 2010, but had thought I had already uploaded it, so my script looked pretty similar to Joey’s. I just looked here, and it turns out the script is not the same as the old one. I apologize for the confusion.

At the end of every quarter I use the following greasemonkey script to extract the links of each of the classes.

Usage: Go to the current quarter SCPD page and click on each of the links. Extracting the links takes awhile, since it is based on the previous SCPD link extractor. The GM script simply goes to each lecture page and extracts the link. After extraction is finish a new tab will appear and will display all the links for you to copy and paste. (This uses the same idea as the Xanga2RSS extractor.)

It seems that the SCPD program keeps the lectures archived at these links for a pretty long time. At least for a quarter or two. (However I once googled for SCPD links and found an EE one from 07 and it still worked, so perhaps SCPD never really erases them.)

Here it is below:

// ==UserScript==
// @name           SCPD links
// @namespace      hawflakes
// @description    Strips video links off of SCPD
// @include*
// ==/UserScript==
var vidurls="";
var links;
// Main link page for a course
if (window.location.toString().indexOf("GradCourseInfo.aspx?")>=0)
// Get links to video page
links = findXPathNodes("/html/body//table/tbody/tr/td/a[text()='WMP']");
var href=links.snapshotItem(i).getAttribute("href");
var url = href.substring(href.indexOf("'")+1);
url = url.substring(0,url.length-4);
// helper functions
function findXPathNode(xpath, start,doc)
	var result = (doc == null ? document : doc).evaluate(xpath,(start == null ? document : start), null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE ,null);
	return (result.snapshotLength > 0 ? result.snapshotItem(0) : null);
function findXPathNodes(xpath, start,doc)
	return (doc == null ? document : doc).evaluate(xpath,(start == null ? document : start), null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE ,null);	
function elem(tagname,content)
	var ret = document.createElement(tagname);
	ret.innerHTML = content;
	return ret;
function get(url, data, cb,info) {
	var client = new XMLHttpRequest();"GET",url,true);
	client.onreadystatechange = function () {
		if(client.readyState==4) {
function getlink(client,info)
	var tempurl=client.responseText.substring(client.responseText.indexOf("data=\"")+"data=\"".length,client.responseText.indexOf(".wmv\"")+4)+"\n";
if (info<links .snapshotLength-1)
	var href=links.snapshotItem(info+1).getAttribute("href");
	var url = href.substring(href.indexOf("'")+1);
	url = url.substring(0,url.length-4);
 //Generate links page
GM_openInTab("data:text;charset=UTF-8," + encodeURI(vidurls));
Categories: Uncategorized Tags: , ,