Greasy Fork is available in English.
2024/10/9 12:58:31
当前为
// ==UserScript==
// @name UOOC和U校园ai版自动解除失去焦点暂停、检测确认按钮、自动重播刷时长
// @namespace Violentmonkey Scripts
// @match https://www.uooc.net.cn/home/learn/index*
// @match https://ucontent.unipus.cn/_explorationpc_default/pc.html*
// @grant none
// @version 1.0
// @author -Bright J
// @description 2024/10/9 12:58:31
// ==/UserScript==
var config = {
releasePause: true,
repeated: false,
clickProp: true
}
/**
* 视频播放暂停立马自动解除
*/
if (config.releasePause){
setInterval(function () {
var current_video = document.getElementsByTagName('video')[0];
if (current_video.paused && current_video.currentTime != 0) {
current_video.play();
}
}, 1000);
}
/***
* 自动重复播放视频
*/
// 获取视频元素
if (config.repeated){
// var video = document.getElementById('vjs_video_753_html5_api');
var video = document.getElementsByTagName('video')[0];
// 监听视频播放结束事件
video.addEventListener('ended', function() {
// 当视频播放结束时,重置视频播放时间到开始
video.currentTime = 0;
// 再次播放视频
video.play();
});
}
/**
* 点击弹窗确认按钮
*/
if (config.clickProp){
var checkInterval = setInterval(function () {
// 检查是否存在包含“确定”文本的按钮
setTimeout(function () {
console.log('检测按钮');
var confirmButton = document.evaluate('//button[text()="确定"]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
if (confirmButton) {
// 模拟点击“确定”按钮
confirmButton.click();
}
}, 3000);
}, 3000);
}