From 0a8b4c059ef1e1dd4c02b5a28f48ab6f25e59e33 Mon Sep 17 00:00:00 2001 From: shibao Date: Wed, 17 Jul 2024 17:49:31 -0400 Subject: [PATCH] fix flaky behavior --- disable-youtube-autoplay.user.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/disable-youtube-autoplay.user.js b/disable-youtube-autoplay.user.js index a963b40..508e9f2 100644 --- a/disable-youtube-autoplay.user.js +++ b/disable-youtube-autoplay.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Turn off Youtube Autoplay // @namespace https://bubbletea.dev/ -// @version 2.0 +// @version 2.1.0 // @description Disables Youtube recommended videos from automatically playing // @author shibao // @include https://www.youtube.com/watch* @@ -42,12 +42,10 @@ function eachNode(rootNode, callback) { for (const addedNode of mutation.addedNodes) { // recurses through all child nodes as well eachNode(addedNode, function (node) { - if (node.nodeName == 'DIV' && + node.nodeName == 'DIV' && node.classList.contains('ytp-autonav-toggle-button') && - node.getAttribute('aria-checked') == "true") { - const button = node.closest("button"); - if (button) { setTimeout(() => button.click(), 1000); } - } + node.getAttribute('aria-checked') == "true" && + node.click(); }); } };