Greasy Fork

Greasy Fork is available in English.

chaoxing学习通,自动两倍速刷视频,禁止自动暂停,自动下一章

此脚本仅适用于 mooc1.chaoxing.com 这个网址

当前为 2022-11-06 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         chaoxing学习通,自动两倍速刷视频,禁止自动暂停,自动下一章
// @namespace    http://tampermonkey.net/
// @version      0.6
// @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 frames = Array.from(
          window?.frames?.[3]?.document.querySelectorAll("iframe") || []
        );
				if(!frames.length) {
					return 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)) {
              document.querySelector(".jb_btn.prev_next.next")?.click();
              setTimeout(() => window.location.reload(), 500);
            }
            return result;
          },
        });
        Promise.all(
          frames.map(
            (frame) =>
              new Promise((resolve) => {
                setTimeout(() => {
                  const video =
                    frame.contentWindow.document.getElementById(
                      "video_html5_api"
                    );
                  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;
})();