m.YouTube.com auto fullscreen on rotate

Switches the video to full-screen mode when you rotate your smart device

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         m.YouTube.com auto fullscreen on rotate
// @namespace    m-youtube-com-auto-fullcreen-on-rotate
// @version      1.1
// @description  Switches the video to full-screen mode when you rotate your smart device
// @author       hlorand.hu
// @match        https://m.youtube.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=tampermonkey.net
// @grant        none
// @license      https://creativecommons.org/licenses/by-nc-sa/4.0/
// ==/UserScript==

// Screenshot: https://ibb.co/chtmD9F

(function() {
    //'use strict';

    var isFullscreen = false;

    window.addEventListener("orientationchange", (event) => {
        let player = document.getElementById("player-container-id");
        let angle = event.target.screen.orientation.angle;
        console.log(angle, isFullscreen);

        // enter fullscreen
        if( !isFullscreen && (angle > 60 && angle < 120 || angle > 240 && angle < 300) ){
            player.requestFullscreen();
            isFullscreen = true;
            return;
        }

        // exit fullscreen
        if( isFullscreen && (angle > 330 || angle < 30 || angle > 150 && angle < 210) ){
            document.exitFullscreen();
            isFullscreen = false;
            return;
        }



    });

})();