日升通

一起学习

目前為 2021-11-26 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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)
})();