Created
May 30, 2025 13:40
-
-
Save zvodd/423a6b13df789dba742dc33b5a85aa1a to your computer and use it in GitHub Desktop.
userscript youtube.com toggle controller/chrome/overlay
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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