广东省国家工作人员学法考试系统自动刷课

广东省专用

目前為 2023-07-06 提交的版本,檢視 最新版本

// ==UserScript==
// @name         广东省国家工作人员学法考试系统自动刷课
// @namespace    http://tampermonkey.net/
// @version      2023.7.6
// @description  广东省专用
// @author       yygdz1921
// @match        http*://xfks-study.gdsf.gov.cn/study/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=gdsf.gov.cn
// @grant        none
// @license      MIT
// ==/UserScript==

(function () {
    'use strict';

    // Your code here...
    var log = console.log;
    log("start...");
    function main() {
        log("main...");
        var pathname = window.location.pathname;
        if (pathname.includes("index")) {
            log("index...");
            var cols = document.getElementsByClassName("column");
            for (let index = 0; index < cols.length; index++) {
                var col = cols[index];
                var catalogdesc = col.getAttribute("catalogdesc");
                var course = col.querySelector(".card.current").innerText.replace(/\s+/g, "");
                if (catalogdesc.includes("庭审") || catalogdesc.includes("题库")) {
                    continue;
                }
                // 判断是否完成
                var btn = col.getElementsByClassName("btn")[0];
                if (btn) {
                    log("未完成", col);
                    btn.click();
                    break;
                } else {
                    log(catalogdesc, course);
                }
            }
        } else if (pathname.includes("chapter")) {
            log("chapter...");
            var ms = 3000 + Math.floor(Math.random() * 1000);
            submitLearn();
            setTimeout(() => {
                var next_chapter = document.querySelector(".next_chapter")
                if (next_chapter) {
                    next_chapter.click();
                } else {
                    window.location.pathname = "study/index";
                }
            }, ms);

        } else if (pathname.includes("course")) {
            log("course...");
            var finish = true;
            var lis = document.getElementsByClassName("chapter")[0].getElementsByTagName("li");
            for (let index = 0; index < lis.length; index++) {
                var li = lis[index];
                var sub_title = li.getElementsByClassName("sub_title")[0].innerText;
                if (sub_title.includes("获得") || sub_title.includes("未开放")) {
                    continue;
                }
                finish = false;
                li.querySelector(".title a").click();
                break;
            }
            if (finish) {
                document.querySelector(".menu-ic-note").click();
            }
        } else if (pathname.includes("login")) {
            log("login...")
        } else {
            log("未知页面", pathname);
        }
    }

    if (document.readyState === 'complete') {
        // DOM 已经加载完成
        main();
    } else {
        // DOM 还未加载完成
        // document.addEventListener("DOMContentLoaded", main);
        window.onload = main;
    }
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址