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/*
// @match http://www.uooc.net.cn/*
// @match http://ucloud.unipus.cn/home*
// @match https://ucloud.unipus.cn/home*
// @match https://ucontent.unipus.cn/_explorationpc_default/pc.html*
// @match http://ucontent.unipus.cn/_explorationpc_default/pc.html*
// @match https://ucloud.unipus.cn/app/cmgt/*
// @grant none
// @version 1.7
// @author -Bright J
// @description 2024/10/9 12:58:31
// ==/UserScript==
const config = {
releasePause: true, // 是否自动解除视频暂停
repeated: true, // 是否重复播放视频
clickProp: true, // 是否点击确定
autoPlay: true, // 是否自动播放视频
volume: 0, // 视频音量0~100
}
var currentvideo = document.getElementsByTagName('video')[0];
const autoPlayVideo = function(){
/**
* 自动播放视频
*/
if (config.autoPlay) {
console.log('自动播放视频')
currentvideo.play();
}
}
document.addEventListener('click', function(event) {
console.log("点击事件,重新获取此时视频对象");
currentvideo = document.getElementsByTagName('video')[0];
autoPlayVideo();
});
var intervalId = setInterval(function() {
if (currentvideo) {
clearInterval(intervalId); // 关闭本循环
currentvideo.currentTime = 0;
autoPlayVideo();
/**
* 设置属性
*/
currentvideo.volume = config.volume / 100;
/**
* 视频播放暂停立马自动解除
*/
if (config.releasePause){
setInterval(function () {
if (currentvideo.paused && currentvideo.duration != currentvideo.currentTime && (currentvideo.currentTime != 0 || config.autoPlay)) {
console.log('检测到视频暂停,重新播放')
currentvideo.play();
}
}, 1000);
}
/***
* 自动重复播放视频
*/
// 获取视频元素
if (config.repeated){
// 监听视频播放结束事件
currentvideo.addEventListener('ended', function() {
console.log('视频结束,重复播放')
// 当视频播放结束时,重置视频播放时间到开始
currentvideo.currentTime = 0;
// 再次播放视频
currentvideo.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);
}
} else {
console.log('等待视频加载,确认加载完成依旧重复这句话则是没有识别到网页视频。。。')
currentvideo = document.getElementsByTagName('video')[0];
}
}, 1000)