m.YouTube.com auto fullscreen on rotate

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

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

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

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

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

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

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==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;
        }



    });

})();