DMM TVのURLで再生位置を指定

DMM動画プレーヤーでURLパラメータ t=秒数 で指定した位置から再生を開始します

// ==UserScript==
// @name         DMM TVのURLで再生位置を指定
// @namespace    http://tampermonkey.net/
// @version      1.0
// @license MIT 
// @description  DMM動画プレーヤーでURLパラメータ t=秒数 で指定した位置から再生を開始します
// @match        https://tv.dmm.com/vod/playback/on-demand/*
// ==/UserScript==

(function() {
    'use strict';

    let startTimeInSeconds = 0;
    const urlParams = new URLSearchParams(window.location.search);
    const timeParam = urlParams.get('t');

    if (timeParam) {
        const startFromTime = parseInt(timeParam, 10);
        if (!isNaN(startFromTime)) {
            startTimeInSeconds = startFromTime;
            console.log('Using time from URL parameter: ' + startTimeInSeconds + ' seconds');

            const checkPlayerInterval = setInterval(() => {
                const videoPlayer = document.querySelector('video');
                if (videoPlayer) {
                    clearInterval(checkPlayerInterval);
                    console.log('DMM Video Player found, setting time to ' + startTimeInSeconds + ' seconds');

                    videoPlayer.addEventListener('canplay', function onCanPlay() {
                        videoPlayer.removeEventListener('canplay', onCanPlay);
                        videoPlayer.currentTime = startTimeInSeconds;
                        console.log('Playback time set to ' + startTimeInSeconds + ' seconds');
                        videoPlayer.play();
                    });

                    if (videoPlayer.readyState >= 3) {
                        videoPlayer.currentTime = startTimeInSeconds;
                        console.log('Playback time set immediately to ' + startTimeInSeconds + ' seconds');
                    }
                }
            }, 500);
        }
    }
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址