智慧树共享课刷课,智慧树共享课自动跳过题目,智慧树共享课自动播放下一个视频,智慧树共享课自动播放未完成的视频

收录 62

智慧树共享课刷课,智慧树共享课自动跳过题目,智慧树共享课自动播放下一个视频,智慧树共享课自动播放未完成的视频
本脚本更适合刷课用,因为它只用于自动播放那些没有打对号(没播放成100%)的视频
智慧树共享课刷课,智慧树共享课自动跳过题目,智慧树共享课自动播放下一个视频,智慧树共享课自动播放未完成的视频,使用时请注意您的网址因为它只能在https://studyh5.zhihuishu.com/videoStudy*上运行

// ==UserScript==
// @name         智慧树共享课刷课,智慧树共享课自动跳过题目,智慧树共享课自动播放下一个视频,智慧树共享课自动播放未完成的视频
// @namespace    http://tampermonkey.net/
// @version      0.0.0.8
// @description  智慧树共享课刷课,智慧树共享课自动跳过题目,智慧树共享课自动播放下一个视频,智慧树共享课自动播放未完成的视频,使用时请注意您的网址因为它只能在https://studyh5.zhihuishu.com/videoStudy*上运行
// @author       C选项_沉默
// @match        https://studyh5.zhihuishu.com/videoStudy*
// @grant        none
// @license      GPL
// ==/UserScript==

var timeInterval = 5000; //脚本自动运行时间间隔2000表示2秒
var abnormalStuckDetectionLimit = 5; //异常卡顿检查,当异常卡顿检查连续5次发现到视频进度没有变化时刷新,-1禁用


var stuckCount = 0; //卡顿计数
var lastProgressBar = ''; //进度条缓存

function sleep(milliSeconds = 10) {
    //等待10ms
    var startTime = new Date().getTime();
    while (new Date().getTime() < startTime + milliSeconds) {
    }
}

function date_time() {
    var t = new Date();
    return '[' + (t.getMonth() + 1) + '/' + t.getDate() + ' ' + t.getHours() + ':' + t.getMinutes() + ':' + t.getSeconds() + '] ';
}

function get_not_played() {
    //获取未观看列表
    var video_labels = [];
    var list = $('ul.list');
    if (list.length > 0) {
        $.each(list, function (ul_index, ul_ele) { //章节
            $.each($(ul_ele).children(), function (div_index, div_ele) { // x.x
                $.each($(div_ele).find('ul > li'), function (video_label_index, video_label_ele) { // x.x.x
                    if ($(video_label_ele).find('b.time_icofinish').length === 0) {
                        if (!$(video_label_ele).hasClass('current_play')){ // 排除当前播放
                            video_labels.push(video_label_ele);
                        }
                    }
                });
            });
        });
    }
    console.log(
        date_time() + "[未完成检测] 更新未看列表,还剩" + video_labels.length + "个视频未完成。\n",
        {"点击展开全部": video_labels}
    );
    return video_labels;
}

function likeYou() {

    /*这里没有看懂是干啥的,没有改写。*/
    var exploreTipTip = document.getElementsByClassName("exploreTip");
    //讨厌的浏览器提示
    if (exploreTipTip.length > 0) {
        document.getElementsByClassName("hint_delete")[0].children[0].click();
        console.log(date_time() + "[浏览器提示] 讨厌的浏览器提示已经为您关闭了");
    }

    /*弹题测验*/
    var tanti = $('.dialog-test');
    if (tanti.length > 0) {
        //关闭出现的检测题
        var topic_item = $('.topic-item');
        var guess_answer = parseInt(Math.random() * topic_item.length);
        topic_item[guess_answer].click();
        sleep();
        var guess_char = 'ABCD'[guess_answer];
        //随机点击一个选项
        var answer = $('.answer').children().text();
        //选出正确答案
        if (answer.indexOf('A')!==-1 && answer.indexOf(guess_char)===-1) {
            topic_item[0].click();
        }
        if (answer.indexOf('B')!==-1 && answer.indexOf(guess_char)===-1) {
            topic_item[1].click();
        }
        if (answer.indexOf('C')!==-1 && answer.indexOf(guess_char)===-1) {
            topic_item[2].click();
        }
        if (answer.indexOf('D')!==-1 && answer.indexOf(guess_char)===-1) {
            topic_item[3].click();
        }
        tanti.find('div.btn').click();
        console.log(
            date_time() + "[弹题测验] 为您跳过弹题测验," +
            ((answer === guess_char) ? ("一次蒙对,答案:" + answer) : ("蒙的" + guess_char + ',正确答案:' + answer))
            + "。"
        );
    }

    /*检测是否播放完成*/
    var progress_bar = $('.nPlayTime');
    //监控进度条
    // console.log(progress_bar.children);
    if (progress_bar.children().length > 0) {
        var ProgressBar = progress_bar.children('.currentTime').text();
        if (ProgressBar === progress_bar.children('.duration').text()) {
            console.log(date_time() + "[进度条] 检测到进度条已满。");
            var next_video = $(get_not_played()[0]);
            console.log(date_time() + "[自动播放] 播放:<" + next_video.text().replace('    ', ' ') + '>');
            next_video.click();
        }
    }

    /*暂停检测*/
    var play_Button = $(".playButton");
    if (play_Button.length > 0) {
        //点击暂停按钮,将继续播放视频
        play_Button.click();
        console.log(date_time() + "[暂停检测] 继续播放。");
        // play_Button.children[0].click();
    }

    /*卡顿检测*/
    if (progress_bar.children().length > 0 && abnormalStuckDetectionLimit > 0) {
        if(ProgressBar!==lastProgressBar){
            // console.log(date_time()+ " " + ProgressBar + " " + lastProgressBar);
            if(stuckCount!==0){
                console.log(date_time() + "[卡顿检测] 已恢复播放,取消页面刷新计划。");
            }
            stuckCount = 0;
        }
        else{
            if(stuckCount > abnormalStuckDetectionLimit){
                stuckCount = 0;
                location.reload();
            }
            else{
                stuckCount += 1;
                console.log(date_time() + "[卡顿检测] 即将刷新页面…… " + stuckCount + "/" + abnormalStuckDetectionLimit);
            }
        }
        lastProgressBar = ProgressBar;
    }
}

(function () {
    'use strict';
    window.onload = window.setInterval(likeYou, timeInterval);
    console.log(date_time() + "[智慧树助手] 启动成功。");
})();

// el-popup-parent--hidden 弹题
none
打赏采用二维码方式。

添加新评论