Greasy Fork

Greasy Fork is available in English.

超星学习通辅助||视频/答题自动切换

用于辅助超星学习通插件,使得能够进行自动切换视频,观看完视频自动切换答题

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         超星学习通辅助||视频/答题自动切换
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  用于辅助超星学习通插件,使得能够进行自动切换视频,观看完视频自动切换答题
// @author       chic1018
// @match        *://*.chaoxing.com/*
// ==/UserScript==

!function(){
    'use strict';
    function loop(){
        setTimeout(()=>{
            if (window.self !== window.top){
                return;
            }
            let videoElem;
            videoElem = document.querySelector('#iframe').contentDocument.querySelector('iframe').contentDocument.querySelector('#video_html5_api');
            if (!videoElem){
                return;
            }
            let videoLi = document.querySelectorAll('.posCatalog_name');
            let videoCu = document.querySelector('.posCatalog_active span');
            let videoNext;
            for (let i=0,len=videoLi.length;i < len;i++){
                if (videoLi[i] == videoCu){
                    videoNext = videoLi[i+1];
                    break;
                }
            }
            function AnsQues(){
                let check = setInterval(()=>{
                    try{
                        let text = document.querySelector('iframe').contentDocument.querySelector('iframe').contentDocument.querySelector('iframe').contentDocument.querySelector('body > div:last-child').innerText;
                        if (text.slice(0,5) === '答题已完成'){
                            clearInterval(check);
                            document.querySelector('iframe').contentDocument.querySelector('iframe').contentDocument.querySelector('iframe').contentDocument.querySelector('.Btn_blue_1').click()
                            setTimeout(()=>{
                                document.querySelector('iframe').contentDocument.querySelector('iframe').contentDocument.querySelector('iframe').contentDocument.querySelector('#confirmSubWin .bluebtn').click()
                                setTimeout(()=>{
                                    videoNext.click();
                                    if (videoNext != videoLi[videoLi.length-1]){
                                        loop();
                                    }
                                },2000)
                            },50)
                            return;
                        }
                        else if (text.match('题目待完善')){
                            clearInterval(check);
                            videoNext.click();
                            if (videoNext != videoLi[videoLi.length-1]){
                                loop();
                            }
                            return;
                        }
                    }
                    catch{
                    }
                },2000)
            }
            let jobLeft;
            try {
                jobLeft = document.querySelector('.posCatalog_active input').value;
            }
            catch {
                videoNext.click();
                if (videoNext != videoLi[videoLi.length-1]){
                    loop();
                }
                return;
            }
            if (jobLeft == 2){
                videoElem.onended = ()=>{
                    document.querySelector('#dct2').click();
                    setTimeout(AnsQues,2000);
                }
            }
            else if (jobLeft == 1){
                if (!document.querySelector('#iframe').contentDocument.querySelector('.ans-job-finished')){
                    videoElem.onended = videoNext.click();
                }
                else {
                    document.querySelector('#dct2').click();
                    setTimeout(AnsQues,2000);
                }
            }
        },5000);
    }
    loop();
}();