// ==UserScript==
// @name 上海大学继续教育学院/上海立信会计金融学院 自动刷课,倍速,自动换课
// @namespace 一心向善
// @icon 1
// @version 1.1
// @description 自动、倍速播放、自动下一页,其中做题/实验实践/合作/教务处理等建议QQ群1:756253160 二群:949193546联系群主!【可用于:上海大学继续教育学院继续教育管理平台|上海立信会计金融学院|上海理工大学|韩山师范学院|广州软件学院|上海出版印刷高等专科学校|广东职业技术学院|华南农业大学继续教育学院|开封大学继续教育学院|东华大学网络教育学院考试系统|广州学涯|华南农业大学|东华大学|延安大学|上海应用技术大学等】
// @author yxx + 合作版
// @include *://*shu.edu.cn/*
// @include *://*ct-edu.com.cn/*
// @include *://*o-learn.cn/*
// @include *://*telfri-edu.com/*
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_addStyle
// @grant GM_deleteValue
// @grant GM_setClipboard
// @grant GM_registerMenuCommand
// @grant GM_getResourceURL
// @grant GM_addValueChangeListener
// @grant GM_removeValueChangeListener
// @grant GM_getResourceText
// @grant window.close
// @run-at document-body
// @require https://m.zhanyc.cn/jquery-2.2.4.min.js
// @require https://m.zhanyc.cn/layerjs-gm-with-css.js
// @license GPL
// ==/UserScript==
(function () {
let $jq = $;
unsafeWindow.$jq = $;
unsafeWindow.layer = layer;
let baseConfig = {};
// ====================== 【可自定义配置】======================
const PLAY_SPEED = 1.0; // 默认倍速:1
const AUTO_NEXT_VIDEO = true; // 自动播放下一节(默认开启)
const AUTO_MUTE = true; // 自动静音
// ============================================================
let freeTips = "增强版已解锁:倍速播放、自动换课、全自动无人值守功能";
let docUrl = "";
let plugMain = Object.assign(baseConfig, {
config: { maxComment: 100, speed: PLAY_SPEED, autoNext: AUTO_NEXT_VIDEO },
pageData: {
userNameIndex: null, closeTipsIndex: null, confirmRunIndex: null,
confirmRunZIndex: 19991018, waitTime: 0,
index: { list: null }, video: { index: null }
},
async init() {
console.log("%c 增强版初始化成功", "background:green;color:#fff;padding:4px");
plugMain.addStyle();
plugMain.createControlPanel();
unsafeWindow.alert = function (msg) { layer.alert(msg); };
plugMain.firstRun();
},
async runByUrl(url) {
if (url.includes('/learn/outline/courseware/item/')) {
plugMain.page_video2();
}
else if (url.includes("index/course/learn/courseware/video") ||
url.includes("/index/course/learn/courseware/document") ||
url.includes("/redirectLearnPage") ||
url.includes("/useInterfacestuEnterCourse.action") ||
url.includes('/learn/courseware?')) {
plugMain.page_video();
} else if (url.includes("/index/course/home?")) {
plugMain.page_studentIndex();
}
},
// 创建控制面板
createControlPanel() {
if ($("#zfk-control-panel").length > 0) return;
let panel = `
🎛️ 控制面板
${PLAY_SPEED}x
基础功能:
1、播放完毕自动下一页
2、倍数可自由调节,建议最大调节到2倍即可
3、线上答题等进QQ群联系群主!
4、散单、批量单、合作、各类教务处理进QQ一群:756253160 二群:949193546 联系群主
`;
$("body").append(panel);
// 倍速滑动
$("#speed-range").on("input", function () {
let val = $(this).val();
$("#speed-value").text(val + "x");
plugMain.config.speed = parseFloat(val);
let v = plugMain.getVideo();
if (v) v.playbackRate = plugMain.config.speed;
});
// 自动下一节开关
$("#auto-next-switch").on("change", function () {
plugMain.config.autoNext = $(this).is(":checked");
});
// 拖拽面板
this.makeDraggable($("#zfk-control-panel")[0]);
},
makeDraggable(el) {
let pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
el.onmousedown = dragStart;
function dragStart(e) {
e.preventDefault();
pos3 = e.clientX;
pos4 = e.clientY;
document.onmouseup = dragStop;
document.onmousemove = dragMove;
}
function dragMove(e) {
pos1 = pos3 - e.clientX;
pos2 = pos4 - e.clientY;
pos3 = e.clientX;
pos4 = e.clientY;
el.style.top = (el.offsetTop - pos2) + "px";
el.style.right = "auto";
el.style.left = (el.offsetLeft - pos1) + "px";
}
function dragStop() {
document.onmouseup = null;
document.onmousemove = null;
}
},
async page_video2() {
console.log("%c 视频页面加载", "background:blue;color:#fff");
let timeout = 1;
plugMain.pageData.video.index = setInterval(async () => {
try {
let video = plugMain.getVideo();
if (!video) return;
if (AUTO_MUTE) video.volume = 0;
if (video.playbackRate != plugMain.config.speed) video.playbackRate = plugMain.config.speed;
let isPlaying = await plugMain.videoIsPlay();
let isFinish = await plugMain.isPlayFinish();
if (!isPlaying && !isFinish) video.play();
if (isFinish && plugMain.config.autoNext) plugMain.nextVideo();
} catch (e) {}
}, timeout * 1000);
},
async page_video() {
console.log("%c 课程视频页(强悍版)", "background:green;color:#fff");
let timeout = 1;
plugMain.pageData.video.index = setInterval(async () => {
try {
let video = plugMain.getVideo();
if (!video) return;
if (AUTO_MUTE) video.volume = 0;
if (video.playbackRate != plugMain.config.speed) {
video.playbackRate = plugMain.config.speed;
}
let continueBtn = plugMain.getElByText($(".layui-layer-btn0"), "继续播放");
if (continueBtn) continueBtn.click();
let nextBtn = plugMain.getElByText($(".layui-layer-btn0"), "学习下一课节");
if (nextBtn) nextBtn.click();
let isFinish = await plugMain.isPlayFinish();
let isPlaying = await plugMain.videoIsPlay();
if (!isPlaying && !isFinish) video.play();
if (isFinish && plugMain.config.autoNext) {
plugMain.nextVideo();
}
} catch (e) {}
}, timeout * 1000);
},
nextVideo() {
try {
let next = $(".fa-adjust,.fa-circle-o").eq(0);
if (next.length) {
next.parents(".course_chapter_item:first").find(".section_title").click();
return;
}
let active = $("#menu_tarr_content>div.active");
if (!active.is(":last-child")) {
active.next().click();
}
} catch (e) {}
},
async page_studentIndex() {
await plugMain.waitOf(() =>
plugMain.getElByText($("button"), "开始学习") != null ||
plugMain.getElByText($("button"), "继续学习") != null
);
let btn = plugMain.getElByText($("button"), "开始学习") || plugMain.getElByText($("button"), "继续学习");
if (btn) btn.click();
plugMain.page_video();
},
play() {
let v = plugMain.getVideo();
if (v) { v.volume = 0; setTimeout(() => v.play(), 100); }
},
isPlayFinish() {
try {
let v = plugMain.getVideo();
return v.duration > 0 && v.currentTime + 5 >= v.duration;
} catch { return false; }
},
getVideo() { return $("video")[0]; },
getCurTime() { try { return $("video")[0].currentTime } catch { return 0; } },
getTotalTime() { try { return $("video")[0].duration } catch { return 0; } },
async videoIsPlay() {
return new Promise(resolve => {
try {
let t1 = $("video")[0].currentTime;
setTimeout(() => resolve($("video")[0].currentTime > t1), 150);
} catch { resolve(false); }
});
},
firstRun() { plugMain.begin(""); },
async begin(key) { plugMain.runByUrl(location.href); },
addStyle() { GM_addStyle(`#zfk-control-panel{user-select:none;}`); },
waitTimeout(t) { return new Promise(r => setTimeout(r, t)); },
waitOf(fn, i = 500) {
return new Promise(r => {
if (fn()) return r();
let timer = setInterval(() => { if (fn()) { clearInterval(timer); r(); } }, i);
});
},
getElByText(q, t) {
let res = null; $(q).each((_, el) => { if ($(el).text().trim() === t) res = $(el); });
return res;
}
});
setTimeout(() => {
if (!unsafeWindow.zfk) plugMain.init();
}, 1500);
unsafeWindow.plugMain = plugMain;
})();