https://blog.csdn.net/AliceMadao/article/details/108351453?utm_medium=distribute.pc_feed_404.none-task-blog-BlogCommendFromMachineLearnPai2-2.nonecase&depth_1-utm_source=distribute.pc_feed_404.none-task-blog-BlogCommendFromMachineLearnPai2-2.nonecas
// ==UserScript==
// @name 超星学习通刷课
// @namespace rainerosion
// @version 1.3.2
// @description 超星学习通刷课脚本 自动静音 自动1.25倍播放 自动答题(超星学习通视频弹出的题目随便选择没事)
// @author rainerosion
// @match *://studyh5.zhihuishu.com/videoStudy.html*
// @require https://base1.zhihuishu.com/able-commons/resources/uploader/client/js/jquery/jquery-1.7.2.min.js
// @grant unsafeWindow
// @license GPL3.0
// @supportURL https://github.com/rainerosion/zhihuishu
// ==/UserScript==
(function($) {
//监听点击事件
$("html").on("click","#rains", function () {
StartOrStop();
});
$.noConflict(true);
//定时器
var timer;
//++++++++ 以下为可设置的参数 ++++++++++
//初始状态 0 开启 1关闭
var startstatus = 0;
//次数
var number = 0;
//视频播放到91%时候切换下一个
var percent = 91;
//速率
var speed = "1.25";
//静音
var vol = true;
//答题?不答题将会移除答题框
var answer = true;
//++++++++ 可设置的参数结束 ++++++++++
//查找节点
var tips = $("body");
console.log(tips[0])
//创建新节点
var option = $("<div>");
//添加样式
var args = {
"color":"DarkOrange",
"text-align":"center",
"line-height":"90px",
"font-size":"30px",
"background-image": "url(data:image/jpg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD//gA7Q1JFQVRPUjogZ2QtanBlZyB2MS4wICh1c2luZyBJSkcgSlBFRyB2NjIpLCBxdWFsaXR5ID0gOTAK/9sAQwADAgIDAgIDAwMDBAMDBAUIBQUEBAUKBwcGCAwKDAwLCgsLDQ4SEA0OEQ4LCxAWEBETFBUVFQwPFxgWFBgSFBUU/9sAQwEDBAQFBAUJBQUJFA0LDRQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQU/8AAEQgAMgAyAwEiAAIRAQMRAf/EAB8AAA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fNWVFJU/IzdecjHBwK4Pq9aK54ys2dDzPDwq+ylFtLd9P8Ahjzz4u/G2++MvhzT7SDTW0iG3driQNchpXcqwyx2LgAMeOpz61j/AAc+AniXWPEdvFe6dqFlZlkkS4GYflBzuUNjcTkAMOgXvmvGPC/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.css(args);
option.attr("id","rains");
option.text("Rains");
//插入节点到页面
tips[0].parentNode.insertBefore(option[0],tips[0]);
//函数
function start(){
if(number % 20 == 0){
console.clear();
}
number += 1;
//获取视频速率
var speedSpan = $(".speedBox>span").text().replace("X ","");
if(speedSpan != speed){
switch(speed){
case "1.0":
$("div[rate='1.0']").click();
break;
case "1.25":
$("div[rate='1.25']").click();
break;
case "1.5":
$("div[rate='1.5']").click();
break;
}
}
//判断音量
var volume = parseInt($(".volumeBox .passVolume")[0].style.height);
if(volume > 0 && vol == true){
$(".volumeIcon").click();
}
//获取进度条
var pass = $(".passTime");
//获取答题框状态
var dialog = $(".el-dialog__wrapper.dialog-test")[0];
if(dialog != undefined){
if(answer == false){
//移除答题框
$(".v-modal").remove();
$(".el-dialog__wrapper.dialog-test")[0].remove();
$("body").removeClass("el-popup-parent--hidden");
}else{
//如果是单选题或者判断题选择一个答案否则移除答题框
if($(".title-tit").text() == "【单选题】" || $(".title-tit").text() == "【判断题】"|| $(".title-tit").text() == "【多选题】"){
//选择选项的第一个用于获取正确答案
let list = $(".topic-list .topic-option-item");
list[0].click();
//取消已经选择的
list.each(function(){
if($(this).hasClass("active")){
$(this).click();
}
})
//选择答案
let answer = $(".answer span").text().split(",");
for(let i in answer){
let option = answer[i].charCodeAt() - 65;
$(".topic-list .topic-option-item")[option].click();
}
//延时关闭弹窗
setTimeout("$(".el-dialog__wrapper.dialog-test .el-dialog__footer .dialog-footer .btn")[0].click();",1000);
}else{
//如果不是这3个选项移除答题框以后弹框将不会出现
$(".v-modal").remove();
$(".el-dialog__wrapper.dialog-test")[0].remove();
$("body").removeClass("el-popup-parent--hidden");
}
}
let play = $(".bigPlayButton.pointer")[0];
//如果暂停继续播放
if(play.style.display == "block"){
play.click();
}
}else{
let play = $(".bigPlayButton.pointer")[0];
//如果暂停继续播放
if(play.style.display == "block"){
play.click();
}
}
//判断播放进度是否大于83%
if(parseInt(pass[0].style.width) > percent){
//切换下一个视频
$("#nextBtn").click();
}
console.log("执行第"+ number + "次");
}
function StartOrStop(){
var rains = $("#rains");
//获取播放状态
var play = $(".bigPlayButton.pointer")[0];
if (startstatus == 0){
//开始脚本
timer = setInterval(start, 3000);
//已经暂停 点击开始按钮 block时视频播放暂停
startstatus = 1;
rains.text("已开");
rains.css("color","blue");
console.log("刷课开始执行");
if(play.style.display == "block"){
play.click();
}
}else if (startstatus == 1) {
//停止脚本
clearInterval(timer);
//已经播放 暂停播放
startstatus = 0;
rains.text("已关");
rains.css("color","red");
console.log("刷课已停止");
if(play.style.display == "none"){
play.click();
}
}
}
//执行监听方法 默认填入代码后开启脚本
StartOrStop();
})(jQuery);