Hide Youtube player controls.

Hide Youtube player controls. Press key 'h' to hide or show player contols.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         Hide Youtube player controls.
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Hide Youtube player controls. Press key 'h' to hide or show player contols.
// @author       noushadbug
// @match        *://*.youtube.com/watch?*
// @grant        none
 // @license MIT
// ==/UserScript==
 
(function() {
    'use strict';
 
    // Your code here...
    var key = 72; // h
    var hide = 0;
 
    function logKey(e){
        switch(e.keyCode){
                case key:
                    if(hide == 0){
                        // hide the elements that are on the YouTube video player using CSS
                        document.getElementsByClassName('ytp-chrome-top')[0].style.visibility = 'hidden';
                        document.getElementsByClassName('ytp-chrome-controls')[0].style.visibility = 'hidden';
                        document.getElementsByClassName('ytp-gradient-top')[0].style.visibility = 'hidden';
                        document.getElementsByClassName('ytp-gradient-bottom')[0].style.visibility = 'hidden';
                        document.getElementsByClassName('ytp-progress-bar')[0].style.visibility = 'hidden';
                        document.getElementsByClassName('ytp-progress-bar-container')[0].style.visibility = 'hidden';
                        hide = 1;
                    }else{
                        // show the elements that are on the YouTube video player using CSS
                        document.getElementsByClassName('ytp-chrome-top')[0].style.visibility = 'visible';
                        document.getElementsByClassName('ytp-chrome-controls')[0].style.visibility = 'visible';
                        document.getElementsByClassName('ytp-gradient-top')[0].style.visibility = 'visible';
                        document.getElementsByClassName('ytp-gradient-bottom')[0].style.visibility = 'visible';
                        document.getElementsByClassName('ytp-progress-bar')[0].style.visibility = 'visible';
                        document.getElementsByClassName('ytp-progress-bar-container')[0].style.visibility = 'visible';
                        hide = 0;
                    }
                    break;
       }
    }
    document.addEventListener("keydown", logKey);
})();