hlstudy.scbaixin.net自动跳转下一个视频,在视频播放完成后自动跳转到下一个lesson
目前為
// ==UserScript==
// @name hlstudy.scbaixin.net自动跳转下一个视频
// @version 1.0
// @description hlstudy.scbaixin.net自动跳转下一个视频,在视频播放完成后自动跳转到下一个lesson
// @author Your Name
// @match http://hlstudy.scbaixin.net/study/lesson/content/*
// @grant none
// @namespace https://greasyfork.org/users/1402509
// ==/UserScript==
(function() {
'use strict';
// 检查当前域名是否为 hlstudy.scbaixin.net
if (window.location.hostname === 'hlstudy.scbaixin.net') {
// 等待视频元素加载完成
const observer = new MutationObserver((mutationsList, observer) => {
for (let mutation of mutationsList) {
if (mutation.type === 'childList') {
const video = document.getElementById('studyvideo');
if (video) {
// 视频元素加载完成后自动播放
video.play();
// 监听视频播放完成事件
video.addEventListener('ended', function() {
// 获取当前lesson的值
const currentLesson = parseInt(new URLSearchParams(window.location.search).get('lesson'));
// 计算下一个lesson的值
const nextLesson = currentLesson + 1;
// 构建新的URL
const newUrl = window.location.origin + window.location.pathname +
'?course=' + new URLSearchParams(window.location.search).get('course') +
'&lesson=' + nextLesson +
'&status=' + new URLSearchParams(window.location.search).get('status');
// 跳转到新的URL
window.location.href = newUrl;
});
// 停止观察
observer.disconnect();
break;
}
}
}
});
// 配置观察选项
const config = { childList: true, subtree: true };
// 开始观察document.body
observer.observe(document.body, config);
}
})();