Skip to content

Instantly share code, notes, and snippets.

@zvodd
Created May 30, 2025 13:40
Show Gist options
  • Save zvodd/423a6b13df789dba742dc33b5a85aa1a to your computer and use it in GitHub Desktop.
Save zvodd/423a6b13df789dba742dc33b5a85aa1a to your computer and use it in GitHub Desktop.
userscript youtube.com toggle controller/chrome/overlay
let revoke = (
function() {
let display_on = false;
const selectors = `
.ytp-chrome-top
.ytp-chrome-bottom
.ytp-gradient-top
.ytp-gradient-bottom`.split('\n').map(s => s.trim()).filter(s => s);
function toggleYouTubeControls() {
if(selectors.map(selector => {
const element = document.querySelector(selector);
if (element) {
element.style.display = display_on ? '' : 'none';
return true
}
}).some(_=>_)){
display_on = !display_on
}
}
function keyListener(event) {
if (event.altKey && event.key === 'h') {
toggleYouTubeControls();
}
}
document.addEventListener('keydown', keyListener);
return function revoke() {
document.removeEventListener('keydown', keyListener);
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment