Greasy Fork

Greasy Fork is available in English.

hbjs质量技术网络学习试卷选择助手debug

答题进度提示

当前为 2021-11-19 提交的版本,查看 最新版本

// ==UserScript==
// @name         hbjs质量技术网络学习试卷选择助手debug
// @namespace    x_jianp
// @version      0.5-debug
// @description  答题进度提示
// @author       x_jianp
// @match        http://mis.hebjs.com.cn/*
// @grant        unsafewindow
// @grant        GM_setValue
// @grant        GM_getValue
// @require      http://code.jquery.com/jquery-latest.js
// ==/UserScript==
// 本脚本发布地址在 http://greasyfork.icu/zh-CN/scripts/435675-hbjs%E8%B4%A8%E9%87%8F%E6%8A%80%E6%9C%AF%E7%BD%91%E7%BB%9C%E5%AD%A6%E4%B9%A0%E8%AF%95%E5%8D%B7%E9%80%89%E6%8B%A9%E5%8A%A9%E6%89%8B
(function() {
    'use strict';

    // Your code here...
    let i =0;
    try {
        //异常的抛出
        //尝试获取成绩
        let yanzheng = document.querySelector("#r > div:nth-child(1) > div.panel-header > div.panel-title");
        if (yanzheng.innerText == '我的学习情况') {
            let myHis = document.querySelector("#r > div:nth-child(1) > div.panel.datagrid.panel-htop.portal-p.panel-body > div > div > div.datagrid-view2 > div.datagrid-body > table > tbody");
            for ( i=0;i<myHis.children.length;i++){
                let infoi = myHis.children[i].innerText.split("\n");
                GM_setValue(infoi[0],[infoi[4],infoi[2]]);
            }
        }

    } catch(e) {
        //异常的捕获与处理
    } finally {
        //结束处理
    }


    //尝试写入成绩
    let yanzheng = null;
    try {
        yanzheng = document.querySelector("#formMain > table > tbody > tr:nth-child(1) > td > h3");
    } finally {}
    if (yanzheng != null) {
        if (yanzheng.innerText = '请选择规范开始答题'){
            for (let j=0 ; j<5;j++ ){
                let tiku = document.querySelector("#formMain > table > tbody > tr:nth-child("+String(j*2+3)+") > td");
                let tishu = tiku.children.length;
                for ( i=0;i<tishu;i++){
                    let tiname = tiku.children[i].querySelector("span > span.l-btn-text").innerText;
                    let chengji = GM_getValue(tiname);
                    if (chengji != null) {
                        let mypro = document.createElement("progress");
                        mypro.value=chengji[0];
                        mypro.max=chengji[1];
                        tiku.children[i].appendChild(mypro);
                        //console.log(tiname+"成功");
                    } else {
                        //console.log(tiname+"没成绩");
                    }
                }
            }

        }
    }

})();