Auto select all right answer

Questo script permette di selezionare con un click tutte le domande esatte.

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

// ==UserScript==
// @name         Auto select all right answer
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Questo script permette di selezionare con un click tutte le domande esatte.
// @author       You
// @run-at document-start
// @match    https://lms-courses.pegaso.multiversity.click/main/lp-video_student_view/*
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js/
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
 // @license MIT
// @require http://code.jquery.com/jquery-latest.js
// ==/UserScript==
/* global $ */
(function() {
    'use strict';
    $(".panel-heading").append("<button id='selectAllrights' style='position: absolute; top: 0'>FILL RIGHT ANSWER</button>");
    $('#selectAllrights').on('click',function (){
        async function runFirst(){
            var rightAns = [];
            var scriptTags = document.getElementsByTagName('script');

            for (var i = 0; i < scriptTags.length; i++) {
                var script = scriptTags[i];
                var scriptText = script.innerHTML;

                if (scriptText.includes("this.rightAns")) {
                    var rightAnsString = scriptText.match(/this.rightAns\[(.*?)\]="(.*?)";/g);

                    for (var j = 0; j < rightAnsString.length; j++) {
                        var match = rightAnsString[j].match(/this.rightAns\[(.*?)\]="(.*?)";/);
                        var index = parseInt(match[1]);
                        var value = match[2];
                        rightAns[index] = value;
                    }
                }
            }

            for (var i = 1; i <= rightAns.length; i++) {
                var valueToSelect = rightAns[i];
                var selector = '.a-' + i + '[value="' + valueToSelect + '"]';
                var radioButton = document.querySelector(selector);

                if (radioButton) {
                    radioButton.checked = true;
                }
            }

            var elementToRemove = document.getElementById('list-lessons-tool');
            var mainMenuremove = document.getElementById('main-menu');

            if (elementToRemove) {
                elementToRemove.parentNode.removeChild(elementToRemove);
                mainMenuremove.parentNode.removeChild(mainMenuremove);
            }
        await submitTest();
        }
        runFirst();
    });
})();