\t💖--AIIT专属-💖
 📰本脚本仅供ATTT学习研究,请勿使用于非法用途!📰
\t💖主要功能💖 
1. 答案检索,自动答题,没有章节切换、没有自动提交
2. 支持单选题、多选题、填空题、判断题、简答题、名词解释、论述题、计算题
3. 显示暂无答案就是没答案
4. 支持章节,作业,考试(仅新版本)
🚫警告🚫
请勿使用于非法用途!如违规脚本将会上传使用者信息以及自动截图保存将信息和截图致邮件到教务处!
请谨慎使用!谢谢配合!
🧧阿宽主页地址:https://bl7c.cn/iDWxa🧧
';
        layx.html('main','🦁答题助手🐑ATTT版🐑',htmlStr,{
            position:'lb',
            width:350,
            height:500,
            storeStatus: true,
            borderRadius: "12px",
            skin: 'river',
            opacity: 1,
            maxMenu: false,
            statusBar: "
助手初始化中.....
",
            style:layx.multiLine(function(){
                /*
                #layx_msg{
                    #公告样式
                    background-color: #fff;
                    border-radius: 10px;
                    padding: 10px;
                    margin: 10px;
                    box-shadow: 0 0 5px #ccc;
                }
                #layx_content{
                    background-color: #fff;
                    border-radius: 10px;
                    padding: 10px;
                    margin: 10px;
                }
                .question_type{
                    #题型样式
                    font-size: 16px;
                    font-weight: bold;
                    color: #000;
                    margin-bottom: 10px;
                }
                .question_content{
                    #题目样式
                    font-size: 14px;
                    color: #000;
                    margin-bottom: 10px;
                }
                .option_item{
                    #选项样式
                    font-size: 14px;
                    color: #000;
                    margin-bottom: 10px;
                }
                .layx-btn{
                    #按钮样式
                    background-color: #fff;
                    border-radius: 10px;
                    padding: 10px;
                    margin: 10px;
                    box-shadow: 0 0 5px #ccc;
                }
                .layx_status{
                    #状态栏样式
                    font-size: 14px;
                    color: red;
                    margin-left:30px;
                    #文字居中
                    text-align: center;
                }
                */
            })
        });
        // 公告缓存十分钟
        var notice =  utils.cache('notice', await ServerApi.get_msg(), 600000);
        document.getElementById('layx_msg').innerHTML = notice;
    }
    // 隐私模式新版考试
    async function newExam2() {
        let data=page.getQuestion("3");
        let answerArr;
        answerArr = await page.requestMerge(data);
        console.log(answerArr);
        // 遍历数组
        for (let i = 0; i < answerArr.length; i++) {
            let item = answerArr[i];
            // 如果为[]或者字符串则跳过
            if(item.length == 0||typeof(item)=="string"){
                continue;
            }
            page.answerTips(data.type,data.options,item);
        }
    }
    // 新版考试
    async function newExam() {
        showFloatWindow();
        // 修改悬浮窗宽度
        layx.setSize('main',{
            width: 360,
            height: 480
        })
        let autoBtn=document.createElement("button");
        autoBtn.classList.add("layx-btn");
        defaultConfig.auto?autoBtn.innerHTML="❌关闭自动切换懒人模式❌":autoBtn.innerHTML="⭕开启自动切换懒人模式⭕";
        autoBtn.onclick=function(){
            // 修改配置
            utils.setConfig({auto: !defaultConfig.auto});
            defaultConfig.auto?autoBtn.innerHTML="❌关闭自动切换懒人模式❌":autoBtn.innerHTML="⭕开启自动切换懒人模式⭕";
            if(defaultConfig.auto){
                // 刷新页面
                location.reload();
            }
        }
        document.getElementById("layx_div").appendChild(autoBtn);
        let reqData=page.getQuestion("3");
        // setInterval穿函数带参数
        if(defaultConfig.autoAnswer)
        {
            $(".layx_status").html("自动答题中.....");
            defaultConfig.loop=setInterval(function(){
                page.startAsk(reqData);
            },defaultConfig.interval);
        }
    }
    // 新版作业
    async function newHomework() {
        showFloatWindow();
        defaultConfig.workinx=0;
        defaultConfig.succ=0;
        defaultConfig.fail=0;
        // 修改悬浮窗宽度
        layx.setSize('main',{
            width: 600,
            height: 300
        })
        if(defaultConfig.autoAnswer)
        {
            $(".layx_status").html("阿宽为你自动答题中.....");
            defaultConfig.loop=setInterval(function(){
                page.startWork();
            },defaultConfig.interval);
        }
    }
    // 新版章节
    async function newChapter() {
        page.decode();
        showFloatWindow();
        defaultConfig.workinx=0;
        defaultConfig.succ=0;
        defaultConfig.fail=0;
        // 修改悬浮窗宽度
        layx.setSize('main',{
            width: 600,
            height: 300
        })
        if(defaultConfig.autoAnswer)
        {
            $(".layx_status").html("阿宽为了你自动答题中.....");
            defaultConfig.loop=setInterval(function(){
                page.startChapter();
            },defaultConfig.interval);
        }
    }
    // 初始化脚本
    async function init() {
        GM_addStyle(GM_getResourceText("layxcss"));
        switch (location.pathname) {
            case '/exam-ans/exam/test/reVersionTestStartNew':
            case '/exam/test/reVersionTestStartNew':
            // case '/mooc2/exam/preview':
            // case '/exam-ans/mooc2/exam/preview':
                if(location.href.includes('newMooc=true')){
                    // 新版考试
                    !defaultConfig.hidden&&newExam();
                    defaultConfig.hidden&&newExam2();
                    break;
                }else{
                    let url=location.href;
                    // 如果url中没有newMooc=false,则添加
                    if(!url.includes('newMooc=false')){
                        url=url+'&newMooc=true';
                    }else{
                        url=url.replace('newMooc=false','newMooc=true');
                    }
                    // 跳转到新版考试
                    location.href=url;
                    break;
                }
            case '/mooc2/work/dowork':
                // 新版作业
                newHomework();
                break;
            case '/work/doHomeWorkNew':
                // 判断是章节还是旧版作业
                if(location.href.includes('oldWorkId')){
                    newChapter();
                }
                else{
                    layx.msg('不支持旧版作业',{dialogIcon:'help'});
                }
                break;
            case '/exam-ans/exam/test/reVersionPaperMarkContentNew':
                page.getScore();
            default:
                break;
        }
    }
    init();
})();