Greasy Fork 支持简体中文。

知能行 辅助脚本

PC端知能行辅助刷题工具,“回车”确认答案、下一题;“+”展示题解;“-”关闭题解窗口

< 腳本知能行 辅助脚本的回應

評論:OK - script works, but has bugs

§
發表於:2024-07-16

修改如下:


(function() {
    'use strict';
    document.body.addEventListener("keydown",(event)=>{
        var continueButton = document.getElementById("continueButton");
        var closeSolutionModalIcon = document.getElementById("closeSolutionModalIcon");
        var solutionButton = document.getElementById("solutionButton");
        var checkAnswerButton = document.getElementById("checkAnswerButton");
        var tryAgainButton = document.getElementById("tryAgainButton");
        var answer = document.getElementById("answer");
        var transButton = document.getElementsByClassName("btn-danger");
        var cancelButton = document.querySelectorAll('button.btn.btn-light:not(#modulePageTabs历史)'); // 使用更精确的选择器
        var nextButton = document.querySelector('#bottomButton > div > div > button.MuiButtonBase-root.MuiButton-root.MuiButton-outlined.jss95.jss111.jss97.jss113.MuiButtonGroup-grouped.MuiButtonGroup-groupedHorizontal.MuiButtonGroup-groupedOutlined.MuiButtonGroup-groupedOutlinedHorizontal.MuiButtonGroup-groupedOutlined');
        var next2Button = document.querySelector('#bottomButton > div > div > button.MuiButtonBase-root.MuiButton-root.MuiButton-outlined.jss88.jss104.jss90.jss106.MuiButtonGroup-grouped.MuiButtonGroup-groupedHorizontal.MuiButtonGroup-groupedOutlined.MuiButtonGroup-groupedOutlinedHorizontal.MuiButtonGroup-groupedOutlined');
        var nextJIXUButton = document.querySelector('#root > div > div > div > div > div:nth-child(2) > div > div > div._1GH8uYjRPopnGvvZ8xKt-g > div > div.col > div:nth-child(2) > button');
        // 找关闭按钮
        var MuiDialog = document.getElementsByClassName("MuiDialog-root");
        var buttons = document.getElementsByTagName("button");

        if(event.keyCode == 13) { // enter
            if(tryAgainButton !=null) {
                console.log("tryAgain");
                tryAgainButton.click();
            }
            if(checkAnswerButton !=null) {
                console.log("check");
                checkAnswerButton.click();
            }
            else if(continueButton !=null) {
                console.log("continue");
                continueButton.click();
            }
            else if(nextJIXUButton !=null) {
                nextJIXUButton.click();
            }

        } else if(event.keyCode == 107) { // +
            if(solutionButton != null) {
                solutionButton.click();
            }
        } else if(event.keyCode == 109) { // -
            for(let i=0; i<buttons.length; i++) {
                closeSolutionModalIcon = buttons[i];
                if(closeSolutionModalIcon != null && closeSolutionModalIcon.id == "closeSolutionModalIcon") {
                    console.log("close");
                    closeSolutionModalIcon.click();
                }
            }
        } else if(event.keyCode == 37) { // ←
            for(let i = 0; i < transButton.length; i++) {
                transButton[i].click();
            }
            if(nextButton != null) {
                nextButton.click();
            }
            else if (next2Button != null) {
                next2Button.click();
            }
        } else if(event.keyCode == 39) { // →
            cancelButton.forEach(button => {
                if (button.textContent.trim() === '取消') {
                    button.click();
                }
            });
            var button = document.querySelector('#root > div > div > div > div > div:nth-child(2) > div > div:nth-child(1) > div._3WnwfRdkMe1S4rkAtDjhhh > div > div:nth-child(4) > div > button');
            if (button) {
                button.click(); // 执行按钮点击操作
            }
        }
        answer.focus();
    });

})();

还在更新和修改中

發表回覆

登入以回復