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.

Revisions

  1. msanders revised this gist May 18, 2024. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions youtube-ux.user.js
    Original file line number Diff line number Diff line change
    @@ -8,8 +8,8 @@
    // @match https://www.youtube.com/*
    // @match https://m.youtube.com/*
    // @run-at document-start
    // @downloadURL https://update.greasyfork.org/scripts/491283/YouTube%20Usability.user.js
    // @updateURL https://update.greasyfork.org/scripts/491283/YouTube%20Usability.meta.js
    // @downloadURL https://gist.githubusercontent.com/msanders/ee774a1e4867911bb70ec7389bdbc9e8/raw/youtube-ux.user.js
    // @updateURL https://gist.githubusercontent.com/msanders/ee774a1e4867911bb70ec7389bdbc9e8/raw/youtube-ux.user.js
    // ==/UserScript==

    // Tested on Firefox Greasemonkey and Violentmonkey, and Safari Userscripts.
  2. msanders revised this gist May 18, 2024. 2 changed files with 39 additions and 15 deletions.
    10 changes: 9 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -12,9 +12,17 @@ To install, open the [raw link](https://gist.githubusercontent.com/msanders/ee77

    ## Also see

    - [YouTube: filter out Shorts](https://letsblock.it/filters/youtube-shorts)
    - [YouTube Neuter - noshorts](https://raw.githubusercontent.com/mchangrh/yt-neuter/main/filters/noshorts.txt) ([yt-neuter](https://neuter.mchang.xyz))
    - [DeArrow - A Browser Extension for Better Titles and Thumbnails](https://dearrow.ajay.app/)

    Alternative/supplementary [Redirector](https://einaregilsson.com/redirector/) rule for short auto-looping:

    - **Example URL:** `https://www.youtube.com/shorts/example`
    - **Include pattern:** `^https?://(?:www\.)?youtube\.com/shorts/([\w-]+.*)$`
    - **Redirect to:** `https://www.youtube.com/watch?v=$1`
    - **Pattern type:** Regular Expression
    - **Description:** Use default video player for YouTube shorts

    ## License

    This is made available under the terms of the MIT license. For a copy, see https://opensource.org/licenses/MIT.
    44 changes: 30 additions & 14 deletions youtube-ux.user.js
    Original file line number Diff line number Diff line change
    @@ -3,24 +3,38 @@
    // @description Disable frequently mistyped shortcuts (e.g. 0-9 number keys) 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.04.14
    // @version 2024.05.17
    // @match https://www.youtube.com/*
    // @match https://m.youtube.com/*
    // @run-at document-start
    // @downloadURL https://update.greasyfork.org/scripts/491283/YouTube%20Usability.user.js
    // @updateURL https://update.greasyfork.org/scripts/491283/YouTube%20Usability.meta.js
    // ==/UserScript==

    // Tested on Firefox Greasemonkey and Violentmonkey, and Safari Userscripts.
    (() => {
    "use strict";
    const IS_MOBILE = document.location.hostname.startsWith("m.");
    const beforeLoad = () => {
    const ALLOWED_MODIFIER_KEYS = ["Alt", "Control", "Meta", "OS"];
    const DISABLED_KEYS = new Set(
    "0123456789kjl".split("").concat(["Home", "End"])
    );

    const DISABLED_KEYS = new Set([
    "0",
    "1",
    "2",
    "3",
    "4",
    "5",
    "6",
    "7",
    "8",
    "9",
    "k",
    "j",
    "l",
    "Home",
    "End",
    ]);
    window.addEventListener(
    "keydown",
    event => {
    @@ -39,19 +53,21 @@
    };

    const afterLoad = () => {
    const pageManager = document.getElementById("page-manager");
    if (pageManager !== null) {
    const container = document.getElementById(
    IS_MOBILE ? "player-shorts-container" : "page-manager"
    );
    if (container !== null) {
    const disableShortLooping = () => {
    pageManager
    .querySelector("#shorts-player video")
    container
    .querySelector(IS_MOBILE ? "video" : "#shorts-player video")
    ?.removeAttribute("loop");
    };

    disableShortLooping();

    // Shorts player gets inserted dynamically by YouTube when navigating, so
    // can't be used as target.
    new MutationObserver(disableShortLooping).observe(pageManager, {
    // Shorts video element gets inserted dynamically by YouTube when
    // navigating, so can't be used as target.
    new MutationObserver(disableShortLooping).observe(container, {
    attributeFilter: ["loop"],
    childList: true,
    subtree: true,
  3. msanders revised this gist Apr 14, 2024. 1 changed file with 10 additions and 7 deletions.
    17 changes: 10 additions & 7 deletions youtube-ux.user.js
    Original file line number Diff line number Diff line change
    @@ -6,13 +6,13 @@
    // @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.04.12
    // @version 2024.04.14
    // @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.
    // Tested on Firefox Greasemonkey and Violentmonkey, and Safari Userscripts.
    (() => {
    "use strict";
    const beforeLoad = () => {
    @@ -39,16 +39,19 @@
    };

    const afterLoad = () => {
    const shortsPlayer = document.getElementById("shorts-player");
    if (shortsPlayer !== null) {
    const pageManager = document.getElementById("page-manager");
    if (pageManager !== null) {
    const disableShortLooping = () => {
    shortsPlayer.querySelector("video")?.removeAttribute("loop");
    pageManager
    .querySelector("#shorts-player video")
    ?.removeAttribute("loop");
    };

    disableShortLooping();

    // Shorts video element gets replaced by YouTube so can't be used as MutationObserver target.
    new MutationObserver(disableShortLooping).observe(shortsPlayer, {
    // Shorts player gets inserted dynamically by YouTube when navigating, so
    // can't be used as target.
    new MutationObserver(disableShortLooping).observe(pageManager, {
    attributeFilter: ["loop"],
    childList: true,
    subtree: true,
  4. msanders revised this gist Apr 13, 2024. 1 changed file with 15 additions and 15 deletions.
    30 changes: 15 additions & 15 deletions youtube-ux.user.js
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,12 @@
    // ==UserScript==
    // @name YouTube Usability
    // @description Disable frequently mistyped shortcuts (e.g. 0-9 number keys) and auto-looping on shorts.
    // @description Disable frequently mistyped shortcuts (e.g. 0-9 number keys) 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.04.11
    // @version 2024.04.12
    // @match https://www.youtube.com/*
    // @match https://m.youtube.com/*
    // @run-at document-start
    @@ -17,7 +17,9 @@
    "use strict";
    const beforeLoad = () => {
    const ALLOWED_MODIFIER_KEYS = ["Alt", "Control", "Meta", "OS"];
    const DISABLED_KEYS = new Set("0123456789kjl".split("").concat(["Home", "End"]));
    const DISABLED_KEYS = new Set(
    "0123456789kjl".split("").concat(["Home", "End"])
    );

    window.addEventListener(
    "keydown",
    @@ -33,25 +35,23 @@
    true
    );

    if (document.readyState === "complete") {
    afterLoad();
    } else {
    window.addEventListener("load", afterLoad);
    }
    window.addEventListener("load", afterLoad);
    };

    const afterLoad = () => {
    const shortsPlayerVideo = document.querySelector("#shorts-player video");
    if (shortsPlayerVideo !== null) {
    const shortsPlayer = document.getElementById("shorts-player");
    if (shortsPlayer !== null) {
    const disableShortLooping = () => {
    shortsPlayerVideo.removeAttribute("loop");
    shortsPlayer.querySelector("video")?.removeAttribute("loop");
    };

    disableShortLooping();
    new MutationObserver(disableShortLooping).observe(shortsPlayerVideo, {
    attributeFilter: [
    "loop"
    ]

    // Shorts video element gets replaced by YouTube so can't be used as MutationObserver target.
    new MutationObserver(disableShortLooping).observe(shortsPlayer, {
    attributeFilter: ["loop"],
    childList: true,
    subtree: true,
    });
    }
    };
  5. msanders revised this gist Apr 11, 2024. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions youtube-ux.user.js
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@
    // @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.04.10
    // @version 2024.04.11
    // @match https://www.youtube.com/*
    // @match https://m.youtube.com/*
    // @run-at document-start
    @@ -17,9 +17,7 @@
    "use strict";
    const beforeLoad = () => {
    const ALLOWED_MODIFIER_KEYS = ["Alt", "Control", "Meta", "OS"];
    const DISABLED_KEYS = new Set(
    "0123456789kjl".split("").concat(["Home", "End"])
    );
    const DISABLED_KEYS = new Set("0123456789kjl".split("").concat(["Home", "End"]));

    window.addEventListener(
    "keydown",
    @@ -51,7 +49,9 @@

    disableShortLooping();
    new MutationObserver(disableShortLooping).observe(shortsPlayerVideo, {
    attributes: true,
    attributeFilter: [
    "loop"
    ]
    });
    }
    };
  6. msanders revised this gist Apr 10, 2024. 1 changed file with 14 additions and 11 deletions.
    25 changes: 14 additions & 11 deletions youtube-ux.user.js
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@
    // @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
    // @version 2024.04.10
    // @match https://www.youtube.com/*
    // @match https://m.youtube.com/*
    // @run-at document-start
    @@ -17,7 +17,9 @@
    "use strict";
    const beforeLoad = () => {
    const ALLOWED_MODIFIER_KEYS = ["Alt", "Control", "Meta", "OS"];
    const DISABLED_KEYS = new Set("0123456789kjl".split("").concat(["Home", "End"]));
    const DISABLED_KEYS = new Set(
    "0123456789kjl".split("").concat(["Home", "End"])
    );

    window.addEventListener(
    "keydown",
    @@ -41,16 +43,17 @@
    };

    const afterLoad = () => {
    disableShortLooping();
    new MutationObserver(disableShortLooping).observe(document, {
    attributes: false,
    childList: true,
    subtree: true,
    });
    };
    const shortsPlayerVideo = document.querySelector("#shorts-player video");
    if (shortsPlayerVideo !== null) {
    const disableShortLooping = () => {
    shortsPlayerVideo.removeAttribute("loop");
    };

    const disableShortLooping = () => {
    document.querySelector("#shorts-player video")?.removeAttribute("loop");
    disableShortLooping();
    new MutationObserver(disableShortLooping).observe(shortsPlayerVideo, {
    attributes: true,
    });
    }
    };

    beforeLoad();
  7. msanders revised this gist Apr 1, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion youtube-ux.user.js
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    // ==UserScript==
    // @name YouTube Usability
    // @description Disables frequently mistyped shortcuts (e.g. 0-9 number keybindings) and auto-looping on shorts.
    // @description Disable frequently mistyped shortcuts (e.g. 0-9 number keys) 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
  8. msanders revised this gist Mar 31, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion youtube-ux.user.js
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    // ==UserScript==
    // @name YouTube Usability
    // @description Disables frequently mistyped shortcuts (e.g. 0-9) and auto-looping on shorts.
    // @description Disables frequently mistyped shortcuts (e.g. 0-9 number keybindings) 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
  9. msanders revised this gist Mar 31, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    ## Userscript: YouTube usability improvements

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

    Also available on [GreasyFork](https://greasyfork.org/en/scripts/491283-youtube-usability).

  10. msanders revised this gist Mar 30, 2024. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,8 @@

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

    Also available on [GreasyFork](https://greasyfork.org/en/scripts/491283-youtube-usability).

    ## Installation

    To install, open the [raw link](https://gist.githubusercontent.com/msanders/ee774a1e4867911bb70ec7389bdbc9e8/raw/youtube-ux.user.js) and follow the prompt on the [Userscripts](https://github.com/quoid/userscripts?tab=readme-ov-file#installation), [Violentmonkey](https://violentmonkey.github.io/get-it/), or [Greasemonkey](https://addons.mozilla.org/en-US/firefox/addon/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.
  11. msanders revised this gist Mar 30, 2024. 2 changed files with 4 additions and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    ## Userscript: YouTube usability improvements

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

    ## Installation

    3 changes: 3 additions & 0 deletions youtube-ux.user.js
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,12 @@
    // ==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
  12. msanders revised this gist Mar 30, 2024. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    ## Userscript: YouTube usability improvements

    Disables frequently mistyped shortcuts (e.g. 0-9) and auto-looping on shorts.

    ## Installation
  13. msanders revised this gist Mar 30, 2024. 2 changed files with 3 additions and 1 deletion.
    2 changes: 2 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    Disables frequently mistyped shortcuts (e.g. 0-9) and auto-looping on shorts.

    ## Installation

    To install, open the [raw link](https://gist.githubusercontent.com/msanders/ee774a1e4867911bb70ec7389bdbc9e8/raw/youtube-ux.user.js) and follow the prompt on the [Userscripts](https://github.com/quoid/userscripts?tab=readme-ov-file#installation), [Violentmonkey](https://violentmonkey.github.io/get-it/), or [Greasemonkey](https://addons.mozilla.org/en-US/firefox/addon/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.
    2 changes: 1 addition & 1 deletion youtube-ux.user.js
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    // ==UserScript==
    // @name YouTube Usability
    // @description Disable frequently mistyped shortcuts and auto-looping on shorts.
    // @description Disables frequently mistyped shortcuts (e.g. 0-9) and auto-looping on shorts.
    // @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
  14. msanders revised this gist Mar 30, 2024. 2 changed files with 14 additions and 2 deletions.
    14 changes: 12 additions & 2 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,14 @@
    Also see:
    ## Installation

    To install, open the [raw link](https://gist.githubusercontent.com/msanders/ee774a1e4867911bb70ec7389bdbc9e8/raw/youtube-ux.user.js) and follow the prompt on the [Userscripts](https://github.com/quoid/userscripts?tab=readme-ov-file#installation), [Violentmonkey](https://violentmonkey.github.io/get-it/), or [Greasemonkey](https://addons.mozilla.org/en-US/firefox/addon/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.

    <img width="790" alt="Screenshot 2023-09-06" src="https://user-images.githubusercontent.com/54970/265988148-413333b9-5c4f-45c0-96d9-bc2d7b906140.png">

    ## Also see

    - [YouTube: filter out Shorts](https://letsblock.it/filters/youtube-shorts)
    - [DeArrow - A Browser Extension for Better Titles and Thumbnails](https://dearrow.ajay.app/)
    - [DeArrow - A Browser Extension for Better Titles and Thumbnails](https://dearrow.ajay.app/)

    ## License

    This is made available under the terms of the MIT license. For a copy, see https://opensource.org/licenses/MIT.
    2 changes: 2 additions & 0 deletions youtube-ux.user.js
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,8 @@
    // @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
    // @downloadURL https://gist.githubusercontent.com/msanders/ee774a1e4867911bb70ec7389bdbc9e8/raw/youtube-ux.user.js
    // @updateURL https://gist.githubusercontent.com/msanders/ee774a1e4867911bb70ec7389bdbc9e8/raw/youtube-ux.user.js
    // @match https://www.youtube.com/*
    // @match https://m.youtube.com/*
    // @run-at document-start
  15. msanders created this gist Mar 30, 2024.
    4 changes: 4 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    Also see:

    - [YouTube: filter out Shorts](https://letsblock.it/filters/youtube-shorts)
    - [DeArrow - A Browser Extension for Better Titles and Thumbnails](https://dearrow.ajay.app/)
    52 changes: 52 additions & 0 deletions youtube-ux.user.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,52 @@
    // ==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();
    })();