Created
November 19, 2022 13:52
-
-
Save DeruiDENG/1dd1e432a2f0fc6ea8970e5251cbfd59 to your computer and use it in GitHub Desktop.
Revisions
-
DeruiDENG created this gist
Nov 19, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,72 @@ function continueLearn() { const continueButton = document.querySelector('body .person > .personal-classcenter iframe')?.contentDocument.querySelector('.layui-layer-content iframe')?.contentDocument.querySelector('button'); if (continueButton) { console.log("Click continue button!"); continueButton.click(); } else { console.log("Continue button not found!") } const playButton = document.querySelector('body .person > .personal-classcenter iframe')?.contentDocument.querySelector('.qplayer-play.qplayer-active'); if (playButton) { console.log("Start play."); playButton.click(); } else { console.log("Play button not found.") } } function getVideoSizeInMinutes() { console.log("Try to get video size...") const videoSize = document.querySelector('body .person > .personal-classcenter iframe')?.contentDocument.querySelector('.qplayer-totaltime')?.textContent console.log("Video size text: ", videoSize); if (!videoSize) { console.log("Use default video size: 60 minutes"); return 61; } const [minutes] = videoSize.split(":"); const length = Number.parseInt(minutes, 10) + 1; console.log("Video length: ", length); return length; } function startNextVideo() { const nextVideo = document.querySelector('li[style="cursor:pointer;background-color: #ccc5c5;"]+li') if (nextVideo) { console.log("Click on next video!") nextVideo.click(); return true; } return null; } function sleep(seconds) { return new Promise((resolve) => { setTimeout(() => { resolve() }, seconds) }) } function autoClickContinue() { setInterval(continueLearn, 5000) } async function run() { await sleep(5 * 1000); autoClickContinue(); while (true) { await sleep(5 * 1000); const size = getVideoSizeInMinutes(); await sleep(size * 60 * 1000); if (!startNextVideo()) { console.log("No next video found. Finish job.") break; } } } run();