刷课助手
当前为
// ==UserScript==
// @name 学海在线刷课助手
// @version v0.3
// @namespace https://copm.yunxuetang.cn/kng
// @description 刷课助手
// @author zackyj
// @match https://copm.yunxuetang.cn/kng/*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
// @license MIT
// ==/UserScript==
(function() {
const NUMBER_OF_VIDEO_PLAYBACK_PAUSES = 'numberOfVideoPlaybackPauses';
window.onload = function() {
player.bdPlayer.setPlaybackRate(2);
console.log('自动设置两倍速');
setTimeout(function() {
player.bdPlayer.setMute(true);
console.log('自动设置静音播放');
}, 4000);
};
window.setInterval(function () {
const date = new Date();
detectionOnline();
console.info(date.toLocaleString() + '检测一次弹窗')
}, 10000);
function detectionOnline() {
var dom = document.getElementById("dvWarningView");
if (dom) {
document.getElementById("reStartStudy").onmousedown();
document.getElementById("reStartStudy").click()
console.log('自动点击继续学习');
}
}
function detectPlaybackStatus() {
let numberOfVideoPlaybackPauses = getVideoPauseTimes();
console.info('视频暂停次数:' + numberOfVideoPlaybackPauses)
const date = new Date();
if (myPlayer.getState() == 'buffering') {
layer.msg("缓冲中...刷新");
window.setTimeout(function () {
initVideoPauseTimes();
window.location.reload();
}, 1000);
} else if (myPlayer.getState() == 'paused') {
videoPauseTimesInc();
if (numberOfVideoPlaybackPauses > 3) {
console.log("暂停次数过多,自动刷新页面");
initVideoPauseTimes();
window.location.reload();
}
myPlayer.play();
console.log("开始播放~");
}
}
// 初始化视频暂停次数
function initVideoPauseTimes() {
localStorage.setItem(NUMBER_OF_VIDEO_PLAYBACK_PAUSES, 0)
}
// 获取视频暂停次数
function getVideoPauseTimes() {
return Number(localStorage.getItem(NUMBER_OF_VIDEO_PLAYBACK_PAUSES) || 0);
}
// 视频暂停次数自增
function videoPauseTimesInc() {
localStorage.setItem(NUMBER_OF_VIDEO_PLAYBACK_PAUSES, Number(getVideoPauseTimes()) + 1);
}
})();