YouTube Shorts Auto-Advance

Automatically advances to the next video short when the current one ends (optional fullscreen mode)

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         YouTube Shorts Auto-Advance
// @namespace    https://greasyfork.org/en/users/10118-drhouse
// @version      2.1
// @description  Automatically advances to the next video short when the current one ends (optional fullscreen mode)
// @include      https://www.youtube.com/shorts/*
// @require      http://code.jquery.com/jquery-3.4.1.min.js
// @require      https://greasyfork.org/scripts/439099-monkeyconfig-modern-reloaded/code/MonkeyConfig%20Modern%20Reloaded.js?version=1012538
// @require      https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.18.2/babel.js
// @require      https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/6.16.0/polyfill.js
// @author       drhouse
// @grant        GM_getValue
// @grant        GM_setValue
// @grant        GM_deleteValue
// @grant        GM_addStyle
// @grant        GM_registerMenuCommand
// @grant        GM_notification
// @license      CC-BY-NC-SA-4.0
// @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com
// ==/UserScript==
this.$ = this.jQuery = jQuery.noConflict(true);

(function($){

    (window.addEventListener("yt-navigate-finish", function(event) {

        var cfg = new MonkeyConfig({
            title: 'Configure',
            menuCommand: true,
            params: {
                'Automatic Fullscreen': {
                    type: 'checkbox',
                    default: false
                },
            },
        })

        function openFullscreen(elem) {
            if (elem.requestFullscreen) {
                elem.requestFullscreen();
            } else if (elem.mozRequestFullScreen) { /* Firefox */
                elem.mozRequestFullScreen();
            } else if (elem.webkitRequestFullscreen) { /* Chrome, Safari and Opera */
                elem.webkitRequestFullscreen();
            } else if (elem.msRequestFullscreen) { /* IE / Edge */
                elem.msRequestFullscreen();
            }
        }

        setTimeout(function(){
            if (cfg.get('Automatic Fullscreen')) {
                // var elem = $('.html5-main-video').get(0);
                var elem = $('.html5-main-video').parent().parent().parent().parent().parent().parent().parent().parent().get(0);
                openFullscreen(elem);
            }
            $(".html5-main-video").removeAttr("loop");
            $(".html5-main-video").on('ended',function(){
                $('#navigation-button-down > ytd-button-renderer:nth-child(1)').get(0).click()
            });
        }, 1000);

    }))
})(jQuery);