Greasy Fork

Greasy Fork is available in English.

正中华自动下一节

由于正中华平台播放完这个视频不会自动播放下一个视频,所以写下此脚本,献给有需要的人,希望可以帮助到您

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         正中华自动下一节
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  由于正中华平台播放完这个视频不会自动播放下一个视频,所以写下此脚本,献给有需要的人,希望可以帮助到您
// @author       NianJiuYue
// @match        https://hn.ischinese.cn/*
// @match        https://hn.ischinese.cn/learncenter/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// @run-at       document-start
// @updateURL
// @installURL
// @downloadURL
// @license      MIT
// ==/UserScript==

(function () {
    'use strict';

    console.log("Script is running!");

    function handleVideoUpdate () {
        var video = document.querySelector(".video-js .vjs-tech");
        var nextButton = document.querySelector(".nextdontcheat");

        if (video && nextButton) {
            var currentTime = video.currentTime;
            var duration = video.duration;
            var remainingTime = duration - currentTime;
            var formattedRemainingTime =
                Math.floor(remainingTime / 60) + "分钟" + Math.floor(remainingTime % 60) + "秒";
            console.log("剩余时间:" + formattedRemainingTime);

            if (currentTime >= duration - 1) {
                console.log("视频播放完成");
                nextButton.click();
            }

            video.removeEventListener("timeupdate", handleVideoUpdate);
            video.addEventListener("timeupdate", handleVideoUpdate);
        } else {
            console.error("未找到视频元素或下一节按钮");
        }
    }

    document.addEventListener("DOMContentLoaded", function () {
        console.log("所有 DOM 元素加载完成");

        setTimeout(function () {
            var video = document.querySelector(".video-js .vjs-tech");

            if (video) {
                video.play();

                video.addEventListener("timeupdate", handleVideoUpdate);

                setTimeout(handleVideoUpdate, 3000);
            } else {
                console.error("未找到视频元素");
            }
        }, 3000);
    });
})();