// ==UserScript== // @name 基金业协会视频自动播放 // @namespace https://www.nekotofu.top/ // @homepage https://www.nekotofu.top/ // @version 0.4 // @description 基金业协会视频自动下一个,但题目目前需要自己答。 // @author misaka10032w // @match *://peixun.amac.org.cn/* // @icon https://www.google.com/s2/favicons?sz=64&domain=microsoft.com // @license MIT // @grant none // @downloadURL none // ==/UserScript== (function () { 'use strict'; window.onload = function () { console.log("DOM已加载!"); window.addEventListener('blur', function () { window.onblur = {} }, false); function closePopup() { const pop = document.querySelector(".class_float"); if (pop.style.display != "none") { var close = pop.getElementsByClassName("btn-close")[0] close.click(); } } let nowPlaying; function getCourse() { const courseList = document.querySelectorAll(".catalog-content a"); for (var i = 0; i < courseList.length; i++) { if (!courseList[i].classList.contains("studied") && !courseList[i].classList.contains("test")) { nowPlaying = courseList[i]; console.log(nowPlaying.textContent) if(!nowPlaying.classList.contains("cur")){ console.log("当前视频已播放完毕"); nowPlaying.click(); } return nowPlaying; } } } nowPlaying = getCourse(); const player = document.querySelector("video"); setTimeout(() => { player.muted = true; player.play(); }, 2000) player.addEventListener("play", function () { console.log("视频开始播放"); }) player.addEventListener("pause", function () { console.log("视频暂停"); setTimeout(() => { player.play(); }, 2000) }) player.addEventListener("ended", function () { console.log("视频播放结束"); }); player.addEventListener("timeupdate", function () { const currentTime = player.currentTime.toFixed(0); const duration = player.duration.toFixed(0); console.log(`当前时间: ${currentTime} / 总时长: ${duration}`); if (currentTime == duration && nowPlaying) { setTimeout(() => { closePopup(); nowPlaying = getCourse(); nowPlaying.click(); }, 5000); } else if (currentTime != currentTime && player.paused) { player.play(); } }) }; })();