Greasy Fork is available in English.
scnu 华南师范大学 长江雨课堂 网课自动化脚本
当前为
// ==UserScript==
// @name scnu华南师范大学网课脚本
// @namespace http://tampermonkey.net/
// @version 0.1
// @description scnu 华南师范大学 长江雨课堂 网课自动化脚本
// @author hqzqaq
// @icon https://statics.scnu.edu.cn/statics/images/favicon.ico
// @grant GM_getValue
// @grant GM_setValue
// @match https://scnuyjs.yuketang.cn/pro/*
// @run-at document-end
// @license MIT
// @require https://cdn.bootcss.com/jquery/1.10.2/jquery.min.js
// ==/UserScript==
(function () {
"use strict";
// 多长时间刷新一下页面,单位 分钟
const reloadTime = 5;
window.onload = function () {
// 网课页面跳转
function getElTooltipItemList() {
return document.getElementsByClassName("el-tooltip leaf-detail");
}
function getElTooltipList() {
return document.getElementsByClassName("el-tooltip f12 item");
}
// 静音
function claim() {
$(
"#video-box > div > xt-wrap > xt-controls > xt-inner > xt-volumebutton > xt-icon"
).click();
}
// 加速
function speed() {
const speed = $(".xt_video_player_common_list");
const speedChild = speed.children()[0];
speedChild.click();
}
const getElementInterval = setInterval(function () {
const elTooltipList = getElTooltipList();
const elTooltipItemList = getElTooltipItemList();
if (elTooltipList) {
for (let index = 0; index < elTooltipList.length; index++) {
const element = elTooltipList[index];
const textContent = element.textContent;
console.log(element.textContent);
if (textContent === "未开始" || textContent === "未读") {
// 判断是否是习题
if(elTooltipItemList[index].innerText.indexOf('习题')!= -1){
continue;
}
window.clearInterval(getElementInterval);
GM_setValue("rowUrl", window.location.href.toString());
// 网课页面跳转
elTooltipItemList[index].click();
window.close();
break;
}
}
}
}, 1000);
let video;
const videoPlay = setInterval(function () {
// 获取播放器
video = document.getElementsByClassName("xt_video_player")[0];
if (!video) {
return;
}
claim();
window.clearInterval(videoPlay);
}, 1000);
// 是否播放完成的检测
const playTimeOut = setInterval(function () {
if (!video) {
return;
}
video.play();
// 没有两倍速的
if (video.playbackRate != 2) {
speed();
}
// 没有静音
if (video.volume != 0) {
claim();
}
const completeness = $(
"#app > div.app-wrapper > div.wrap > div.viewContainer.heightAbsolutely > div > div.video-wrap > div > div > section.title > div.title-fr > div > div > span"
);
if (!completeness) {
return;
}
if (typeof completeness[0] == "undefined") {
return;
}
const videoText = completeness[0].innerHTML
if (videoText) {
let str = videoText.toString();
const succ = str.substring(4, str.length - 1);
const succNum = parseInt(succ);
if (succ >= 95) {
const url = GM_getValue("rowUrl");
window.clearInterval(playTimeOut);
window.location.replace(url);
}
}
}, 1000);
// 是否为阅读类型
const readInterval = setInterval(function () {
const read = $(
"#app > div.app-wrapper > div.wrap > div.viewContainer.heightAbsolutely > div > div.graph-wrap > div > div > section.title > div.title-fr > div > div"
);
if(!read){
return
}
if (typeof read[0] == "undefined") {
return;
}
const readText = read[0].innerHTML
if(readText){
if(readText.toString() === '已读'){
window.clearInterval(readInterval);
window.location.replace(GM_getValue("rowUrl"));
}
}
}, 1000);
// 为了防止页面假死,定时刷新一下页面
setTimeout(function () {
// 如果保存了课程列表路径就回退的课程列表页面
if(GM_getValue("rowUrl")){
window.location.replace(GM_getValue("rowUrl"));
}
location.reload()
},reloadTime * 60 * 1000);
};
})();