[原创] 智慧树刷课js脚本

首页 / 教程 / 正文

智慧树

前言

  最近博主选了两门智慧树的选修课,以前都是电脑安装安卓模拟器然后模拟器安装知到app 使用模拟器播放,挺麻烦的,今天在页面上随便点了下,突然发现智慧树的pc端播放器不是使用flash而是使用的html+js,于是想到使用js点击事件控制播放下一集(智慧树视频要求只需要看到80%即可)、关闭答题弹窗(智慧树的答题可以不管直接关闭,超星的必须答题),如果需要为播放到100%切换下一集请更改第45行的83为100即可。由于是纯JS代码,基本没有被检测作弊的风险,博主不做100%的保证,谨慎使用!!


程序js代码

/**
*  author: 雨落凋殇
*  website: https://rainss.cn
*  description: 自动播放、下一集、关闭答题窗口、刷智慧树网课
*  use-method: 打开智慧树播放课程界面 按F12 -> Console -> 粘贴本代码 ->按回车键  
*  use-method: 视频左上方出现一个图标点击图标开始刷课 显示‘已开’脚本开始监听 再次点击图标关闭
*/
//查找节点
var tips = document.getElementsByClassName("exploreTip");
//创建新节点
var option = document.createElement("div");
//添加样式
option.style="color:DarkOrange;text-align:center;line-height:90px;font-size:30px;background-image: url(data:image/jpg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD//gA7Q1JFQVRPUjogZ2QtanBlZyB2MS4wICh1c2luZyBJSkcgSlBFRyB2NjIpLCBxdWFsaXR5ID0gOTAK/9sAQwADAgIDAgIDAwMDBAMDBAUIBQUEBAUKBwcGCAwKDAwLCgsLDQ4SEA0OEQ4LCxAWEBETFBUVFQwPFxgWFBgSFBUU/9sAQwEDBAQFBAUJBQUJFA0LDRQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQU/8AAEQgAMgAyAwEiAAIRAQMRAf/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVV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i+++H3i/T7q+sY77T9KuI55rK5GFmRZR8n9Bz2z7V92fG7/gpN4W1HQtGbwP4evn1ZWFzjVIlSGGMRuziOQOWcgMqc8AIAuM7a8+GKq06sVUjd9z9AxtTL6uCjRy6HIrK+tnfdu99U+nb7j6W0f4X/Z/CEU2qaVNdPEnlpc3V6ZZgpOC2SxIPPJz718UfHqXTvDfxAs9X0/VpDqUtwkKD7ezKxZWA3bmDBRvU5yqnBB9Rka1/wUg+KmraGNLitdE0a3kuPs32h7SUzRoMg7yXK5yvIOPxySvh+oapqfxH8RaFqmrzxtc3SNdOw5LkSFhGvG1eI/lTJ+YPk84HqRq8zblqfFNVKceVOyPsOz/bBvpLOBhZSSho1Ik2Xa7uOuAMDPoOKK/PS71CV7qZkl1IoXYqWlYkjPHO3milzw7G2vl9x9I/sR20Vx480dZYklU3aZDqCOor9jPG9jbXfwsvbee3img/s+P91IgZfvN2PHYflRRV1fhpHza/i4j0X6n4aftUWdvb+LT5UEceQc7EAz85H8gK8e1F2l1YwuxeFb5iI2OVBZzu498DPrgUUVw4v+JI+kwf+7w9Dfl/0bw3HPD+6njSNUlThlHnS8AjkdB+VbOlEp4q8KKp2rNobrIBwHHkynDevIB59KKKUdkby3LdhZwTWNtJJBG7tGrMzICSSBkk0UUV6p4z3P/Z); background-repeat: no-repeat; background-size: 100%; width: 90px; height: 90px; border-radius: 45px;position:fixed;left:60px;top:200px; z-index:999;"
//添加点击事件
option.setAttribute("onClick","StartOrStop()");
option.setAttribute("id","rains");
option.innerText = "Rains";
//插入节点到页面
tips[0].parentNode.insertBefore(option,tips[0]);
//定时器
var timer;
//初始状态
var startstatus = 0;
//次数
var number = 0;
//函数
function start(){
    if(number % 200 == 0){
          console.clear();
    }
    number += 1;
    //获取进度条
    var pass = document.getElementsByClassName("passTime");
    //获取答题框状态
    var dialog = document.getElementsByClassName("wrap_popboxes  wrap_popchapter")[0];
    //点击关闭按钮关闭答题框
    if(dialog != undefined){
        document.getElementsByClassName("popbtn_cancel")[0].click();
    }
    //判断播放进度是否大于83%
    if(parseInt(pass[0].style.width) > 83){
        //切换下一个视频
        document.getElementById("nextBtn").click();
    }
    console.log("执行第"+ number + "次");
}
function StartOrStop(){
    //获取播放状态
    var play  = document.getElementsByClassName("bigPlayButton pointer")[0];
    if (startstatus == 0){
        //开始脚本
        timer = setInterval(start, 3000);
        //已经暂停 点击开始按钮 
        if(play.style.display == "block"){
            play.click();
        }
        startstatus = 1;
        var rains = document.getElementById("rains");
        rains.innerText = "已开";
        rains.style.color = "blue";
    }else if (startstatus == 1) {
        //停止脚本
        clearInterval(timer);
        //已经播放 暂停播放
        if(play.style.display == "none"){
            play.click();
        }
        startstatus = 0;
        var rains = document.getElementById("rains");
        rains.innerText = "已关";
        rains.style.color = "red";
    }
}

代码使用方法

打开智慧树平台,点开需要播放的课程视频 按F12选择最顶上的Console点击下面的 >后面的空白处,将本博客提供的js代码复制粘贴到空白处,按回车键后左侧视频上会出现带Rains字样的图标,点击图标显示“已开”,刷课脚本开始工作,再次点击图标显示“已关”,刷课脚本停止。如图所示!

操作演示


JS代码文件下载

智慧树刷课脚本.js

原创文章转载请注明出处 !
雨落凋殇博客https://rainss.cn
无标签
评论区
头像