Culearn Cleanup

Make culearn cleaner

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Culearn Cleanup
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Make culearn cleaner
// @author       Ehren Julien-Neitzert
// @match        https://culearn.carleton.ca/moodle/my/
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    document.getElementById('block-region-side-pre').remove();
    document.getElementById('block-region-side-post').remove();
    document.getElementById('inst1061014').remove();
    document.getElementById('page-header').remove();

    var courses = document.getElementsByClassName('category_label');
    for (let c = 1; c < courses.length; c++) { //close all the class views except the first one
        courses[c].click();
    }

    var currentCourses = document.getElementsByClassName('courses')[0].childNodes; //the classes from the current semester
    //var courseName = /] (.+? \([A-Z]{3}\))/ //regex to find course names
    var courseName = /([A-Z]+?\d+?\w+?) /; //regex to find course names
    for (let c = 0; c < currentCourses.length; c++) {
        var link = currentCourses[c].getElementsByTagName('a')[0];
        var linkText = link.innerText;
        link.innerText = linkText.match(courseName)[1]; //change link text to just the course name
    }
})();