法宣在線自動考試


說明

僅供學習交流
法宣在線考試, 自動獲取答案, 完成考試.

使用方法

  1. 使用chrome瀏覽器登錄法宣在線, 進入考試頁面;
  2. 單擊瀏覽器的地址欄, 按快捷鍵F12; 或者使用菜單: 更多工具 - 開發者工具;
  3. 定位到console/控制台面板, 粘貼代碼, 回車;
  4. 程序開始執行, 每秒答一道題, 等待答題完成;

代碼

var answer = [];
var times = 0;
var totalTimes = 0;

var Next = function () {
    var questionId = answer[times]['questionId']
    console.log("questionId", questionId)
    $(`[id$=_${questionId}]`).click();
    setTimeout(
        function () {
            var strAns = answer[times]['answerNo'];
            var arrA = strAns.split('');
            for (a of arrA) {
                console.debug(a);
                $('input[value=' + a + ']').click()
            }
            times += 1;
            if (times < totalTimes) {
                Next();
            }
            else {
                console.debug('完成');
            }
        }, 1000);
};

var start = function () {
    console.debug('開始');
    let cookie = document.cookie;
    let matchArray = cookie.match(/_EXAM(\d+)_PAPER(\d+)_SERIES(\d+)/);
    let examId = matchArray[1];
    let paperId = matchArray[2];
    let seriesId = matchArray[3];
    let answerUrl = `http://www.faxuanyun.com//ess/service/getpaper?paperId=${paperId}&series=${seriesId}_answer`
    fetch(answerUrl, {
        "headers": {
            "cache-control": "no-cache",
            "pragma": "no-cache",
            "upgrade-insecure-requests": "1"
        },
        "referrerPolicy": "strict-origin-when-cross-origin",
        "body": null,
        "method": "GET",
        "mode": "cors",
        "credentials": "include"
    }).then(res => res.text()).then(body => {
        console.debug("test", body);
        let answerString = body.split("\n")[2];
        answer = JSON.parse(answerString);
        totalTimes = answer.length;
        Next();
    });
}
start();

原理

這個地址可以獲取到考試的答案: http://xf.faxuan.net/ess/service/getpaper?paperId=${paperId}&series=${seriesId}_answer


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM