add: userscript-disable-youtube-autoplay-next.js

This commit is contained in:
Victor Westerlund 2026-04-10 18:07:16 +02:00
commit 7d25e9fe1c

View file

@ -0,0 +1,29 @@
// ==UserScript==
// @name Disable YouTube "Autoplay next video"
// @namespace https://vlw.se/
// @version 2026-04-10
// @description Automatically disable autoplay of next video at the end of
// @author Victor Westerlund
// @match https://www.youtube.com/watch?v=*
// @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com
// @grant none
// ==/UserScript==
(function() {
'use strict';
const disableAutoplay = () => {
const target = document.querySelector(".ytp-autonav-toggle-button");
// Mission accomplished
if (target && target.ariaChecked === "false") {
return;
}
// Attempt to disable autoplay
target?.click();
requestIdleCallback(disableAutoplay);
}
requestIdleCallback(disableAutoplay);
})();