YouTube Exit Fullscreen on Video End

Exit YouTube fullscreen when a video finishes playing (disabled for playlists)

Stan na 27-11-2021. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         YouTube Exit Fullscreen on Video End
// @namespace    https://www.youtube.com/
// @version      1.0
// @description  Exit YouTube fullscreen when a video finishes playing (disabled for playlists)
// @author       xdpirate
// @license      Public domain
// @include      /^https?://www\.youtube\.com/watch*/
// @exclude      /^https?://www\.youtube\.com/watch*(list=)*/
// @icon         https://www.google.com/s2/favicons?domain=youtube.com
// @grant        none
// ==/UserScript==

window.setTimeout(function() {
    var e = document.getElementById('movie_player')
    var observer = new MutationObserver(function(event) {
        if(e.classList.contains("ended-mode")) {
            console.log("Video ended!");

            if(document.fullscreenElement) {
                document.exitFullscreen();
            }

            observer.disconnect();
        }
    });

    observer.observe(e, {
        attributes: true,
        attributeFilter: ['class'],
        childList: false,
        characterData: false
    })
}, 3000);