Skip to content

Instantly share code, notes, and snippets.

@chidea
Last active April 12, 2020 13:57
Show Gist options
  • Save chidea/c5324f8d7141185e634353c63bb6c384 to your computer and use it in GitHub Desktop.
Save chidea/c5324f8d7141185e634353c63bb6c384 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Youtube masthead hider
// @namespace http://tampermonkey.net/
// @version 0.9
// @description press h key to hide Youtube masthead menu
// @author ChIdea
// @match https://www.youtube.com/*
// @grant none
// @updateURL https://gist.githubusercontent.com/chidea/c5324f8d7141185e634353c63bb6c384/raw/yt_mh_hider.js
// @downloadURL https://gist.githubusercontent.com/chidea/c5324f8d7141185e634353c63bb6c384/raw/yt_mh_hider.js
// ==/UserScript==
(function() {
'use strict';
document.onkeypress=function(e){
if(document.querySelector('ytd-searchbox').hasAttribute('has-focus')) return;
var k = e.key;
if (k==='h'){
if (window.hideheadopt) {
document.querySelector('#masthead-container').style.display='';
document.querySelector('#page-manager').style.marginTop='';
document.querySelector('#primary').style.paddingTop='';
window.hideheadopt=false;
}else {
document.querySelector('#masthead-container').style.display='none';
document.querySelector('#page-manager').style.marginTop=0;
document.querySelector('#primary').style.paddingTop=0;
document.querySelector('#player-theater-container').style.zoom='95%';
window.hideheadopt=true;
}
}
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment