UCheck Completer

Automatically complete ucheck.utoronto.ca

当前为 2021-09-08 提交的版本,查看 最新版本

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

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

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

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

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

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         UCheck Completer
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Automatically complete ucheck.utoronto.ca
// @author       UTSG Computer Science Department
// @include      https://ucheck.utoronto.ca/*
// @icon         https://www.google.com/s2/favicons?domain=utoronto.ca
// @grant        none
// ==/UserScript==

// Load JQuery
function loadJS(url)
{
    const head = document.getElementsByTagName('head')[0];
    const script = document.createElement('script');
    script.type = 'text/javascript';
    script.src = url;
    script.onload = () => console.log(`${url} loaded.`)
    head.appendChild(script);
}
loadJS('https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js')

// Report no symptoms on the report symptoms page
function report()
{
    // Repeat
    let task = setInterval(() =>
    {
        // Check if it's done
        let submit = $('span:contains(Submit)')
        if (!submit.parent()[0].classList.contains('Mui-disabled'))
        {
            console.log('Done, clicking submit')
            clearInterval(task)
            submit.click()
        }

        // Click no buttons
        // Old method: select by class (doesn't work because class names are randomized.
        // Array.from(document.querySelectorAll('.sc-qbELi.eWIawQ')).filter(it => it.querySelector('span').innerHTML === 'No').forEach(it => it.click())
        // New method: select by content and filter by color (white means unselected)
        $('span:contains(No)').parent().filter((i, it) => $(it).css('background-color') === 'rgb(255, 255, 255)').click()

        // Scroll to bottom
        window.scrollTo(0, document.body.scrollHeight);

    }, 100)
}

// On the right site
if (window.location.hostname === 'ucheck.utoronto.ca')
{
    // On home page
    if (window.location.pathname.replace('/', '') === '')
    {
        // Only run if not already green
        if (!$('p:contains(you do not report symptoms)'))
        {
            // Enter into the report screen
            $('.MuiButton-label').click()
        }
    }

    // Report screen
    if (window.location.pathname === '/questionnaire')
    {
        report()
    }
}