Greasy Fork

Speediergrader

Make speed grader more useable by opening the rubrics by default(or by alt + a), and alt + s to save and go to next person!

目前为 2021-11-12 提交的版本。查看 最新版本

// ==UserScript==
// @name         Speediergrader
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Make speed grader more useable by opening the rubrics by default(or by alt + a), and alt + s to save and go to next person!
// @author       Noirgif
// @match        https://canvas.wisc.edu/courses/*/gradebook/speed_grader?*
// @icon         https://www.google.com/s2/favicons?domain=canvas.instructure.com
// @grant        none
// @license      CC0
// @require http://code.jquery.com/jquery-latest.js
// ==/UserScript==

(function(e,f){var b={},g=function(a){b[a]&&(f.clearInterval(b[a]),b[a]=null)};e.fn.waitUntilExists=function(a,h,j){var c=this.selector,d=e(c),k=d.not(function(){return e(this).data("waitUntilExists.found")});"remove"===a?g(c):(k.each(a).data("waitUntilExists.found",!0),h&&d.length?g(c):j||(b[c]=f.setInterval(function(){d.waitUntilExists(a,h,!0)},500)));return d}})(jQuery,window);

(function() {
    'use strict';

    function setupRubricView() {
        $('.toggle_full_rubric').trigger('click');
        $('input').focus(function() {console.log($(this)); $(this).val((i, e) => e.replace('--', '')); $(this).change();})
    }

    function checkKey(e) {
        if(e.key == 's' && e.altKey) {
            $('.save_rubric_button').trigger('click');
            setTimeout(() => {
                $('.toggle_full_rubric').trigger('click');
                $('#next-student-button').trigger('click');
                setTimeout(() => {$('input').each((i, e) => {if (e.value == '--') e.value = '';});}, 1000);
            }, 1000); // hack
        }
        else if (e.key == 'a' && e.altKey) {
            setupRubricView();
        }
    }
    document.addEventListener('keydown', checkKey, false);

    $('.toggle_full_rubric').waitUntilExists(setupRubricView);

})();