Telegram | Fix fullscreen without custom controls

fix fullscreen mode for videos without custom controls

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==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>`);