YouTube Playlist Auto Skip Watched

Automatically skips to the next video in a YouTube playlist if the current video is marked as watched (progress bar width > 5%).

当前为 2025-03-20 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         YouTube Playlist Auto Skip Watched
// @namespace    http://tampermonkey.net/
// @version      0.7
// @description  Automatically skips to the next video in a YouTube playlist if the current video is marked as watched (progress bar width > 5%).
// @author       You
// @match        *://www.youtube.com/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    function skipWatchedVideo() {
        // Get all playlist items
        const playlistItemsVar = document.querySelectorAll('.playlist-items > ytd-playlist-panel-video-renderer');
        for (const item of playlistItemsVar) {
            // Check if this item is the currently playing video
            const playingIndicatorVar = item.querySelector('span#index.style-scope.ytd-playlist-panel-video-renderer');
            
            if (playingIndicatorVar && playingIndicatorVar.textContent.includes('▶')) {
                // Found the currently playing video
                const progressBarVar = item.querySelector('#progress.style-scope.ytd-thumbnail-overlay-resume-playback-renderer');
                if (progressBarVar) {
                    const widthStyleVar = progressBarVar.getAttribute('style');
                    console.log('Current video progress bar: ', widthStyleVar);

                    if (widthStyleVar) {
                        const widthMatch = widthStyleVar.match(/width: (\d+)%/);
                        if (widthMatch && parseInt(widthMatch[1]) > 5) {
                            console.log('Watched video (progress > 5%) detected. Skipping to the next.');
                            // Find the "Next" button
                            const nextButton = document.querySelector('.ytp-next-button'); // This is a common class for the next button

                            if (nextButton) {
                                nextButton.click();
                                // To avoid immediately triggering again, we can break the loop or add a short delay
                                break;
                            } else {
                                console.log('Could not find the "Next" button.');
                            }
                            // To avoid immediately triggering again, we can break the loop or add a short delay
                            break;
                        }
                    }
                }
                // If the currently playing video doesn't have a progress bar > 5%, we don't need to check others
                break;
            }
        }
    }

    // Run the check every 10 seconds
    setInterval(skipWatchedVideo, 10000);
})();