日升通

一起学习

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

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         日升通
// @namespace    日升通
// @version      0.1
// @description  一起学习
// @author       zusheng
// @match        *://*.chaoxing.com/mycourse/studentstudy*
// @icon         https://www.google.com/s2/favicons?domain=chaoxing.com
// @grant        none
// @license MIT
// ==/UserScript==
(function() {
    'use strict';
    const undoneList = []
    // if (window.frames.length !== 0 || parent.frames.length !== 0) return
    // 查找是否有未完成的章节
    function findUndoneList() {
        // 开始查找
        console.log('@find 开始查找')
        document.querySelectorAll(".chapter #coursetree ul li .posCatalog_level ul li").forEach(item => {
            if (item.querySelector('.prevTips') && item.querySelector('.prevTips').classList?.length > 0) {
                let content = item.querySelector('.prevTips').classList.value
                let reg = new RegExp(/icon_Completed/)
                if (!reg.test(content)) undoneList.push(item)
            } else {
                undoneList.push(item)
            }
        })
        console.log('找到' + undoneList.length + '个未完成章节')
        if (undoneList.length > 0) delUndonList()
    }

    /**
         * 正式刷课
         */
    function delUndonList() {

        function nextSteps() {
            undoneList.shift()
            if (undoneList.length > 0) {
                setTimeout(() => {
                    delUndonList()
                }, 5 * 1000)
            }
        }
        // 选中目录
        console.log('@click,切换任务')
        undoneList[0]?.querySelector('div > .posCatalog_name').click()
        setTimeout(() => {
            //
            // 是否存在iframe ppt
            const iframeFlag = document.documentElement.querySelector('#iframe')?.contentDocument?.querySelector('.ans-attach-online')?.contentDocument?.querySelector('#navigation #ext-gen1045')
            console.log('pptFlage', document.documentElement)
            // 定时器
            let timer = null
            // 当存在ppt时
            if (iframeFlag) {
                timer = setInterval(() => {
                    if (document.documentElement.querySelector('#iframe')?.contentDocument?.querySelector('.ans-attach-online')?.contentDocument?.querySelector('#navigation #ext-gen1045')?.style?.visibility === 'hidden') {
                        clearInterval(timer)
                        nextSteps()
                    } else {
                        document.documentElement.querySelector('#iframe')?.contentDocument?.querySelector('.ans-attach-online')?.contentDocument?.querySelector('#navigation #ext-gen1045').click()
                    }
                }, 1000)
            } else {
                nextSteps()
            }
            //
        }, 3 * 1000)
    }

    setTimeout(() => {
        findUndoneList()
    }, 3 * 1000)
})();