Greasy Fork

Greasy Fork is available in English.

中建一局先锋学堂知学云_挂机

挂机看知学云网课,已适配中建一局先锋学堂

当前为 2024-01-24 提交的版本,查看 最新版本

// ==UserScript==
// @name         中建一局先锋学堂知学云_挂机
// @namespace    http://tampermonkey.net/
// @version      3.2
// @description  挂机看知学云网课,已适配中建一局先锋学堂
// @author       kakasearch
// @match        https://cscec1b.zhixueyun.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=cscec1b.zhixueyun.com
// @require      http://greasyfork.icu/scripts/425166-elegant-alert-%E5%BA%93/code/elegant%20alert()%E5%BA%93.js?version=922763
// @grant        GM_setValue
// @grant        GM_getValue
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
    setInterval(function(){
        if(/study\/errors/.test(window.location.href)){
            new ElegantAlertBox("准备关闭页面>__<")
            window.close()
        }
    },5000)
    if(!GM_getValue("doing")){
        //init
        GM_setValue("doing",{"name":"","time":1,"status":""})
    }
    function click_course(){
        //查找并点击需要学习的课程
        for(let i of document.querySelectorAll(".item[data-resource-id]")){
            let status = i.querySelector(".operation").innerText
            let name = i.querySelector(".name-des").innerText
            if(/(继续学习)|(开始学习)/.test(status)){
                GM_setValue("doing",{"name":name,"time":new Date().getTime(),"status":status})
                i.click()
                return true
            }
        }
        return false
    }
    if(/study\/subject\/detail/.test(window.location.href)){
        // 课程主页,在当前页面实现控制做哪些课程
        setInterval(function(){
            let doing_item = GM_getValue("doing")
            let next_flag = false
            if(new Date().getTime()-doing_item.time>1000*20){
                //超过20s没有更新状态视为过期
                next_flag = true
                new ElegantAlertBox("准备开始新的课程>__<")
            }else{
                next_flag = false
                new ElegantAlertBox("有课程正在学习中,请等待>__<")
            }

            if (next_flag){
                if(click_course() ){
                    //有需要做的课程,已经点击
                    new ElegantAlertBox("已打开新的学习页面学习>__<")
                }else{
                    new ElegantAlertBox("找不到需要学习的内容>__<")
                }
            }
        },5000)
    }else if(/study\/course\/detail/.test(window.location.href)){
        //视频播放页,做完后给主页一个标志,结束标签页
        setInterval(function(){
            let name = document.querySelector("div.title-row > div")
            if(name){
                name = name.innerText
            }else{return}
            GM_setValue("doing",{"name":name,"time":new Date().getTime(),"status":"学习中"})
            let state = document.querySelector("dl.focus > div.chapter-right > div.section-item.section-item11 > div:nth-child(3) > span")
            state = state?state.innerText:null
            if(state == "已完成"){
                new ElegantAlertBox("准备播放下一个视频>__<")
                let courses = document.querySelectorAll("dl")
                for(let i of courses){
                    if(i.querySelector("div.chapter-right > div.section-item.section-item11 > div:nth-child(3) > span").innerText != "已完成"){
                        i.click()
                        return
                    }
                }
                new ElegantAlertBox("全部学习完>__<")
                GM_setValue("doing",{"name":name,"time":new Date().getTime()-1000*30,"status":"已完成"})
                GM_setValue(name,{"name":name,"time":new Date().getTime()-1000*30,"status":"已完成"})
                window.close()
            }else{
                new ElegantAlertBox("还没有学习完 >__<")
                if(document.querySelector(".register-mask-layer") && 'display: none;' != document.querySelector(".register-mask-layer").getAttribute("style")){
                    document.querySelector("#D210registerMask").click()
                }
                document.querySelector("video").muted="muted"
                document.querySelector("button.vjs-big-play-button").click() //开始播放的按钮
            }

        },5000)
    }

    // Your code here...
})();