Last active
September 4, 2021 23:12
-
-
Save andrezero/7f291beeb432805dfad7d9a7141f425e to your computer and use it in GitHub Desktop.
Eurosport Player Keyboard navigation
This file contains 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
(() => { | |
const select = (selector) => () => document.querySelector(selector); | |
const overlay = select('[class*="overlay-overlay"]'); | |
const controls = select('[class*="styles-centerControls"]'); | |
const pause = select('[class*="playpause"]'); | |
const forward = select('[class*="styles-forward"]'); | |
const rewind = select('[class*="styles-rewind"]'); | |
const live = select('[class*="tyles-liveView"]'); | |
const fullScreen = select( | |
'[class*="styles-subControlsRight"] > div > div:last-child' | |
); | |
const mute = select( | |
'[class^="styles-controlWrapper"] [class^="styles-wrapper"] div div' | |
); | |
const keymap = { | |
Space: () => pause()?.click(), | |
ArrowRight: () => forward()?.click(), | |
ArrowLeft: () => rewind()?.click(), | |
KeyL: () => live && live()?.click(), | |
KeyF: () => fullScreen()?.click(), | |
KeyM: () => mute()?.click(), | |
}; | |
if (controls) { | |
controls().style.transform = 'translateY(20vh) scale(0.3)'; | |
overlay().style.display = 'none'; | |
document.addEventListener('keydown', (ev) => { | |
const action = keymap[ev.code]; | |
action && action(); | |
}); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment