Last active
November 18, 2022 01:14
-
-
Save vaaski/d32d4a7d22c02f4343c4a2d885c6b6d2 to your computer and use it in GitHub Desktop.
always focus the youtube player so that you never change volume with left/right arrow keys
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
| // ==UserScript== | |
| // @name always focus player | |
| // @namespace https://gist.github.com/vaaski/d32d4a7d22c02f4343c4a2d885c6b6d2 | |
| // @updateURL https://gist.github.com/vaaski/d32d4a7d22c02f4343c4a2d885c6b6d2/raw/youtube-focus-player.user.js | |
| // @downloadURL https://gist.github.com/vaaski/d32d4a7d22c02f4343c4a2d885c6b6d2/raw/youtube-focus-player.user.js | |
| // @version 2 | |
| // @description always focus the youtube player so that you never change volume with left/right arrow keys | |
| // @author vaaski | |
| // @match https://youtube.com/* | |
| // @match https://*.youtube.com/* | |
| // @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com | |
| // @grant none | |
| // ==/UserScript== | |
| !(async () => { | |
| // @ts-ignore | |
| window.playerFocusInterval = setInterval(() => { | |
| const bodyFocus = document.activeElement?.tagName === "BODY" | |
| const progressFocus = document.activeElement?.classList.contains("ytp-progress-bar") | |
| const volumeFocus = document.activeElement?.classList.contains("ytp-volume-panel") | |
| if (bodyFocus || progressFocus || volumeFocus) { | |
| /** @type {HTMLVideoElement | null} */ | |
| const player = document.querySelector("#movie_player") | |
| player?.focus() | |
| } | |
| }, 100) | |
| })() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment