Greasy Fork

Greasy Fork is available in English.

auto-next-episode

auto play next episode

当前为 2023-06-05 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         auto-next-episode
// @namespace    http://tampermonkey.net/
// @version      0.0.3
// @description  auto play next episode
// @author       zqcccc
// @match        https://ddys.art/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=ddys.art
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

var videoElement = getVideoElement()

function getVideoElement() {
    return document.querySelector('video')
}
function getPlayBtn() {
    return document.querySelector('button[title="Resume"]') || document.querySelector('button[title="播放视频"]')
}
function videoEndHandle() {
    var nextEpisodeBtn = document.querySelector('button[title="下一集"]')
    nextEpisodeBtn.click()
    this.removeEventListener('ended', videoEndHandle)
    var checkTimer = setInterval(()=>{
        var playBtn = getPlayBtn()
        if (playBtn) {
            playBtn.click()
            clearInterval(checkTimer)
            var newVideoElement = getVideoElement()
            newVideoElement.addEventListener('ended', videoEndHandle)
            setTimeout(()=>checkIfVideoPlaying(newVideoElement), 2000)
        }
    }
    , 1000)
}

function checkIfVideoPlaying(videoElement, hasCheckedTimes=0) {
    if (hasCheckedTimes > 10) {
        window.location.reload()
    } else if (videoElement.paused) {
        const btn = getPlayBtn()
        btn?.click()
        setTimeout(()=>checkIfVideoPlaying(videoElement, hasCheckedTimes + 1), 2000)
    }
}

videoElement.addEventListener('ended', videoEndHandle)

checkIfVideoPlaying(videoElement)

})();