Fullscreen Hotkey Mobile Youtube

9/8/2023, 1:42:06 AM

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

You will need to install an extension such as Tampermonkey 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.

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

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

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        Fullscreen Hotkey Mobile Youtube
// @namespace   Fullscreen Hotkey Mobile Youtube - Scripts
// @match       *://m.youtube.com/*
// @grant       none
// @version     1.0
// @run-at      document-start
// @author      -
// @license     MIT
// @description 9/8/2023, 1:42:06 AM
// ==/UserScript==

(function () {
    function openFullscreen() {
      var elem = document.getElementsByClassName('video-stream html5-main-video')[0];
      if (elem.requestFullscreen) {
        elem.requestFullscreen();
      } else if (elem.webkitRequestFullscreen) { /* Safari */
        elem.webkitRequestFullscreen();
      } else if (elem.msRequestFullscreen) { /* IE11 */
        elem.msRequestFullscreen();
      }
    }
    const shortcut = 'f';
 
    document.addEventListener('keydown', (e) => {
        //if (e.ctrlKey && e.key === shortcut) {
        if (e.key === shortcut) {
openFullscreen();
        }
    });
 
})();