Culearn Cleanup

Make culearn cleaner

当前为 2017-12-22 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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
    }
})();