Last active
February 27, 2019 09:05
-
-
Save katrinafyi/c5bc9337ac914ed3e4d6546e1c217b66 to your computer and use it in GitHub Desktop.
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
// ==UserScript== | |
// @name Blackboard TABLIFIER | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author You | |
// @match https://learn.uq.edu.au/webapps/portal/execute/tabs/tabAction?tab_tab_group_id=_1_1 | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
var courses = document.querySelectorAll(".menu-item li"); | |
var MATHcolor = 'rgba(63, 81, 181, 0.3)'; // red | |
var CSSEcolor = 'rgba(192, 73, 36, 0.3)'; // blue | |
var STATcolor = 'rgba(11, 128, 67, 0.3)'; // orange | |
var INFScolor = 'rgba(142, 36, 170, 0.3)'; // lime | |
var COMPcolor = '#E8F5E9'; // green | |
var COMScolor = '#E0F2F1'; // teal | |
var COSCcolor = '#FFFDE7'; // yellow | |
var DECOcolor = '#F3E5F5'; // purple | |
var defaultColor = 'rgb(233, 233, 233)'; | |
Array.prototype.forEach.call(courses, function(course) { | |
var courseText = course.firstChild.textContent; | |
var courseCode = /\[([^\]]+)\]/.exec(courseText); | |
console.log(courseCode); | |
if (courseCode == null) { | |
return; | |
} | |
var courseName = (courseText.replace(courseCode[0],"")).split("(")[0]; | |
course.firstChild.innerHTML = '<table style="font-size:13px; font-family: \'SF Pro Text\', \'Helvetica Neue\', Arial, sans-serif"><tr><td style="font-family: \'SF Mono\', \'Consolas\', Menlo, \'Courier New\', monospace">'+courseCode[1]+'</td><td style="width: 450px">' + courseName + "</td></tr></table>" | |
//course.firstChild.innerHTML = "<table><td><b>" + courseCode[1] + "</b></td><td>" + courseName + "</td></table>"; | |
console.log(courseText); | |
switch(courseText.substring(1,5)) { | |
case "COMP": | |
course.style.background = COMPcolor; | |
break; | |
case "COMS": | |
course.style.background = COMScolor; | |
break; | |
case "COSC": | |
course.style.background = COSCcolor; | |
break; | |
case "CSSE": | |
course.style.background = CSSEcolor; | |
break; | |
case "DECO": | |
course.style.background = DECOcolor; | |
break; | |
case "INFS": | |
course.style.background = INFScolor; | |
break; | |
case "MATH": | |
course.style.background = MATHcolor; | |
break; | |
case "STAT": | |
course.style.background = STATcolor; | |
break; | |
default: | |
course.style.background = defaultColor; | |
break; | |
} | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment