Created
November 9, 2025 00:34
Disable YouTube Mobile Autoplay (Supports Desktop View)
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 Disable YouTube Mobile Autoplay (Supports Desktop View) | |
| // @namespace http://tampermonkey.net/ | |
| // @version 1.0 | |
| // @description Automatically turn off autoplay on YouTube (PC & Mobile) | |
| // @match https://www.youtube.com/* | |
| // @match https://m.youtube.com/* | |
| // @grant none | |
| // @run-at document-start | |
| // @license MIT | |
| // ==/UserScript== | |
| (() => { | |
| 'use strict'; | |
| const turnOffAutoplay = () => { | |
| // Mobile | |
| const mobileBtn = document.querySelector('.ytm-autonav-toggle-button-container'); | |
| if (mobileBtn && mobileBtn.getAttribute('aria-pressed') === 'true') { | |
| mobileBtn.click(); | |
| } | |
| // PC | |
| const pcBtn = document.querySelector('.ytp-autonav-toggle-button'); | |
| if (pcBtn && pcBtn.getAttribute('aria-checked') === 'true') { | |
| pcBtn.click(); | |
| } | |
| }; | |
| // Run when page is loaded | |
| window.addEventListener('load', turnOffAutoplay); | |
| // Run on SPA navigation events | |
| window.addEventListener('yt-navigate-finish', turnOffAutoplay); | |
| // Observe DOM changes (e.g., video replacement) | |
| const observer = new MutationObserver(turnOffAutoplay); | |
| observer.observe(document.documentElement, { childList: true, subtree: true }); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment