sanxiaUTDevelopmentTarget

重庆三峡党建刷课脚本2022-10-12

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         sanxiaUTDevelopmentTarget
// @namespace    http://tampermonkey.net/
// @version      1.0.0
// @description  重庆三峡党建刷课脚本2022-10-12
// @author       Recardo
// @match        *://zhdjpt.sanxiau.edu.cn/fzdx/*
// @grant        none
// @require      http://code.jquery.com/jquery-1.11.0.min.js
// ==/UserScript==

(function()
{
    'use strict';
    console.log('It\'s runing Now');
    var i=0;
    var j=0;
    var colors="red";
    var time=getTimes();
    var pa = document.createElement('p');
    var n=130;//最大等待响应时长:n*3s
    var k=0;
    if(document.getElementsByClassName("video_cont")[0]===undefined)
    {
        console.log("视频出错,即将刷新");
        location.reload();
    }
    else
    {
       document.getElementsByClassName("video_cont")[0].appendChild(pa);
    }
    showInfo('开始工作');
    var tm=setInterval(function()
    {
        if(document.getElementsByClassName("video_head").length==0&&document.getElementsByClassName("video_cont").length==0)
        {
            console.log("视频出错,即将刷新");
            location.reload();
        }
        else
        {
            if(document.getElementsByClassName("video_red1")[0].children[0].style.color==colors)
            {//如果当前已经看完
                showInfo("当前视频已看完,将点击下一视频");
                if(document.getElementsByClassName("video_red1")[0].nextSibling.nextSibling===null)
                {
                    //window.clearInterval(t1);
                    showInfo('当前课程没有需要学习的内容了!');
                    window.location.href="http://zhdjpt.sanxiau.edu.cn/user/lesson";
                }
                else
                {
                    document.getElementsByClassName("video_red1")[0].nextSibling.nextSibling.children[0].click();//点击下一视频
                }
        }
        else
        {
                //进行弹窗点击操作
                //console.log(document.getElementsByClassName("public_submit")[0]);
                if(document.getElementsByClassName("public_cancel")[0]===undefined)
                {
                    if(document.getElementsByClassName("public_submit")[0]===undefined)
                    {
                        i=i+1;
                        showInfo('共点击'+j+'次弹窗!预计下次弹窗'+(i/n*100).toFixed(2)+'%。已过'+(i*time/60/1000).toFixed(2)+'分钟');
                        if(document.getElementsByClassName("plyr--stopped")[0]===undefined)
                        {
                            k=0;
                        }
                        else
                        {
                            k++;
                            if(k>=n/10-5)
                            {
                                showInfo('视频暂停中,将在'+((n/10-k)*time/60/1000).toFixed(2)+'分钟后刷新');
                            }
                            if(k>=n/10)
                            {
                                showInfo('视频暂停中,可能已播完,刷新');
                                location.reload();
                            }
                        }
                    }
                    else
                    {
                        document.getElementsByClassName("public_submit")[0].click();
                        i=0;
                        j=j+1;
                        showInfo('第'+j+'次点击弹窗!开始学习');
                    }
                }
                else
                {
                    document.getElementsByClassName("public_cancel")[0].click();
                    i=0;
                    j=j+1;
                    showInfo('第'+j+'次点击弹窗!继续学习');
                }
            }
        }
       //alert(document.getElementsByClassName("public_submit")[1]);
    },time);

})();

function getTimes()
{
    var times=Math.random()*8 + 1;//1-9
    times=3*1000*1;//+times*10
    return times
}

function showInfo(str)
{
    console.log(str);
    document.getElementsByClassName("video_cont")[0].children[2].innerText=str;
}