Telegram | Fix fullscreen without custom controls

fix fullscreen mode for videos without custom controls

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

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

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            Telegram | Fix fullscreen without custom controls
// @namespace       https://greasyfork.org/users/821661
// @version         1.1
// @description     fix fullscreen mode for videos without custom controls
// @author          hdyzen
// @match           https://web.telegram.org/a/*
// @grant           none
// @license         GPL-3.0-only
// ==/UserScript==

const stl = `
    .VideoPlayer:fullscreen video { 
        max-height: unset !important; 
    } 
    .VideoPlayer:fullscreen > :first-child { 
        width: 100% !important; 
        height: 100% !important; 
    }
`;

document.addEventListener("mousedown", async (ev) => {
    const fullscreen = ev.target.closest(".Button.fullscreen");
    if (!fullscreen) return;

    ev.stopImmediatePropagation();

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

    const player = document.querySelector(".MediaViewerSlide--active .VideoPlayer");
    if (!player) return;

    await player.requestFullscreen();

    const video = player.querySelector("video");
    setTimeout(() => video.removeAttribute("controls"), 100);
});

document.head.insertAdjacentHTML("beforeend", `<style>${stl}</style>`);