Skip to content

Instantly share code, notes, and snippets.

@andrezero
Last active September 4, 2021 23:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrezero/7f291beeb432805dfad7d9a7141f425e to your computer and use it in GitHub Desktop.
Save andrezero/7f291beeb432805dfad7d9a7141f425e to your computer and use it in GitHub Desktop.
Eurosport Player Keyboard navigation
(() => {
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