Gradescope auto-expander

Expands gradescope programming exercises

目前为 2022-10-05 提交的版本。查看 最新版本

// ==UserScript==
// @name         Gradescope auto-expander
// @namespace    http://github.com/isaacl
// @version      0.1
// @description  Expands gradescope programming exercises
// @author       Isaac Levy
// @match        *://*.gradescope.com/*/grade
// @grant        none
// @license      MIT
// ==/UserScript==

/* jshint esversion: 6 */

(function() {
    'use strict';
    let expanded = 0;

    document.addEventListener('keydown', (e) => {
        const allToggles = document.querySelectorAll('button.fileViewerHeader--toggleButton');
        if (e.keyCode === 40 && expanded < allToggles.length - 1) {
            expanded++;
        } else if (e.keyCode === 38 && expanded > 0) {
            expanded--;
        } else {
            return;
        }

        allToggles.forEach((e, i) => {
            const shouldExpand = expanded === i;
            const isExpanded = e.getAttribute('aria-expanded') === 'true';
            if (shouldExpand !== isExpanded) e.click();
        });
    });
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址