OnCampusTweaks

Change the way Elder High School's student website behaves.

目前為 2020-02-02 提交的版本,檢視 最新版本

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

You will need to install an extension such as Tampermonkey to install this script.

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         OnCampusTweaks
// @namespace    https://elderhs.myschoolapp.com
// @version      0.8
// @description  Change the way Elder High School's student website behaves.
// @author       Zack Sargent
// @match        https://elderhs.myschoolapp.com/app/student
// @grant        none
// ==/UserScript==

// Runs when page is fully loaded
// The website is set up in a way that window.onload triggers before the page is fully loaded.
// Thus, we must check independently to see if the full page has loaded.
var checkExist = setInterval(function() {
    if (document.readyState === 'ready' || document.readyState === 'complete') {
        changeToWeekView();
        hideCompletedTasks();
        clearInterval(checkExist);
    }
}, 100); // check every 100ms

// Changes to week view
function changeToWeekView() {
    // if the string "assignment-center" is in the url
    if (window.location.href.indexOf("assignment-center") > -1) {
        document.getElementById("week-view").click();
        console.log("OnCampusTweaks: Changed to week view");
    }

}

// hides completed tasks automatically in the assignment center
function hideCompletedTasks() {
    if (window.location.href.indexOf("assignment-center") > -1) {
        document.getElementById("filter-status").click();

        // Create a list of all of the button elements that appear when you filter by status
        var buttonElements = document.getElementsByClassName("pull-left btn btn-xs btn-approve status-button active");
        buttonElements[3].click(); // Hides Completed tasks

        // We have to get the buttons again because clicking on them changes the class structure
        buttonElements = document.getElementsByClassName("pull-left btn btn-xs btn-approve status-button active");
        buttonElements[3].click(); // Hides Graded tasks

        document.getElementById("btn-filter-apply").click();

        console.log("OnCampusTweaks: Hid completed tasks");
    }
}