Greasy Fork is available in English.
此脚本仅适用于 mooc1.chaoxing.com 这个网址
当前为
// ==UserScript==
// @name chaoxing学习通,自动两倍速刷视频,禁止自动暂停,自动下一章
// @namespace http://tampermonkey.net/
// @version 0.3
// @description 此脚本仅适用于 mooc1.chaoxing.com 这个网址
// @author glitchboyl
// @match *://mooc1.chaoxing.com/*
// @icon https://www.google.com/s2/favicons?domain=chaoxing.com
// @grant none
// @license MIT
// ==/UserScript==
(function() {
'use strict';
function fn() {
const videos = [];
const flags = new Proxy([], {
get(target, key, receiver) {
return Reflect.get(target, key, receiver);
},
set(target, key, value, receiver) {
const result = Reflect.set(target, key, value, receiver);
if (target.every((f) => f)) {
setTimeout(() => document.querySelector(".jb_btn.prev_next.next")?.click(), 500)
}
return result;
},
});
const frames =
Array.from(window?.frames?.[3]?.document.querySelectorAll("iframe") || []);
Promise.all(
frames?.map((frame) => {
return new Promise((resolve) => {
setTimeout(() => {
const video =
frame.contentWindow.document.getElementById(
"video_html5_api"
);
console.log(frame, video);
if (video) {
flags.push(false);
videos.push(video);
resolve();
}
}, 800)
});
})
).then(() => {
let i = 0;
function play() {
const video = videos[i];
if (!video) return;
video.volume = 0;
video.autoplay = true;
video.defaultPlaybackRate = 2;
video.playbackRate = 2;
video.onpause = () =>
!video.ended && setTimeout(() => video.play());
video.onended = () => {
flags[i] = true;
video.onwaiting = null;
video.onpause = null;
clearInterval(timer);
if (i < videos.length) {
i++;
play();
}
};
let timer = setInterval(() => {
if (!video.paused) video.play();
}, 1000);
video.play();
}
play();
});
}
window.onload = fn;
})();