Also see:
Last active
February 6, 2026 09:16
-
-
Save msanders/ee774a1e4867911bb70ec7389bdbc9e8 to your computer and use it in GitHub Desktop.
Userscript: YouTube usability improvements
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 YouTube Usability | |
| // @description Disable frequently mistyped shortcuts and auto-looping on shorts. | |
| // @icon https://m.youtube.com/static/apple-touch-icon-114x114-precomposed.png | |
| // @match https://www.youtube.com/* | |
| // @match https://m.youtube.com/* | |
| // @run-at document-start | |
| // ==/UserScript== | |
| // Tested on Greasemonkey and Violentmonkey for Firefox, and Userscripts for Safari. | |
| (() => { | |
| "use strict"; | |
| const beforeLoad = () => { | |
| const ALLOWED_MODIFIER_KEYS = ["Alt", "Control", "Meta", "OS"]; | |
| const DISABLED_KEYS = new Set("0123456789kjl".split("").concat(["Home", "End"])); | |
| window.addEventListener( | |
| "keydown", | |
| event => { | |
| if ( | |
| DISABLED_KEYS.has(event.key) && | |
| !ALLOWED_MODIFIER_KEYS.some(event.getModifierState.bind(event)) && | |
| !event.isComposing | |
| ) { | |
| event.stopImmediatePropagation(); | |
| } | |
| }, | |
| true | |
| ); | |
| if (document.readyState === "complete") { | |
| afterLoad(); | |
| } else { | |
| window.addEventListener("load", afterLoad); | |
| } | |
| }; | |
| const afterLoad = () => { | |
| disableShortLooping(); | |
| new MutationObserver(disableShortLooping).observe(document, { | |
| attributes: false, | |
| childList: true, | |
| subtree: true, | |
| }); | |
| }; | |
| const disableShortLooping = () => { | |
| document.querySelector("#shorts-player video")?.removeAttribute("loop"); | |
| }; | |
| beforeLoad(); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment