Skip to content

Instantly share code, notes, and snippets.

@msanders
Last active February 6, 2026 09:16
Show Gist options
  • Select an option

  • Save msanders/ee774a1e4867911bb70ec7389bdbc9e8 to your computer and use it in GitHub Desktop.

Select an option

Save msanders/ee774a1e4867911bb70ec7389bdbc9e8 to your computer and use it in GitHub Desktop.
Userscript: YouTube usability improvements

Userscript: YouTube usability improvements

Short userscript that disables frequently mistyped shortcuts (e.g. 0-9 number keybindings) and auto-looping on shorts.

Also available on GreasyFork.

Installation

To install, open the raw link and follow the prompt on the Userscripts, Violentmonkey, or Greasemonkey extension modal. Alternatively, you can create a new JavaScript item on the extension page and copy/paste the script. On iOS, go to the same link and tap the puzzle icon in the address bar and then the “Userscripts” menu item.

Screenshot 2023-09-06

Also see

License

This is made available under the terms of the MIT license. For a copy, see https://opensource.org/licenses/MIT.

// ==UserScript==
// @name YouTube Usability
// @description Disables frequently mistyped shortcuts (e.g. 0-9) and auto-looping on shorts.
// @license MIT
// @icon https://m.youtube.com/static/apple-touch-icon-114x114-precomposed.png
// @downloadURL https://gist.githubusercontent.com/msanders/ee774a1e4867911bb70ec7389bdbc9e8/raw/youtube-ux.user.js
// @updateURL https://gist.githubusercontent.com/msanders/ee774a1e4867911bb70ec7389bdbc9e8/raw/youtube-ux.user.js
// @namespace michaelsande.rs
// @version 2024.03.30
// @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