From d73968c5ed28fd1ef6aad55260d96c46602f57f5 Mon Sep 17 00:00:00 2001 From: shibao Date: Wed, 17 Jul 2024 17:49:37 -0400 Subject: [PATCH] format --- disable-youtube-autoplay.user.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/disable-youtube-autoplay.user.js b/disable-youtube-autoplay.user.js index 508e9f2..90cc044 100644 --- a/disable-youtube-autoplay.user.js +++ b/disable-youtube-autoplay.user.js @@ -13,47 +13,47 @@ // from https://developer.mozilla.org/en-US/docs/Web/API/Node#recurse_through_child_nodes function eachNode(rootNode, callback) { if (!callback) { - const nodes = [] + const nodes = []; eachNode(rootNode, function (node) { - nodes.push(node) - }) - return nodes + nodes.push(node); + }); + return nodes; } if (false === callback(rootNode)) { - return false + return false; } if (rootNode.hasChildNodes()) { - const nodes = rootNode.childNodes + const nodes = rootNode.childNodes; for (let i = 0, l = nodes.length; i < l; ++i) { if (false === eachNode(nodes[i], callback)) { - return + return; } } } } (function () { - 'use strict'; + "use strict"; const observer = new MutationObserver(function (mutationList) { for (const mutation of mutationList) { for (const addedNode of mutation.addedNodes) { // recurses through all child nodes as well eachNode(addedNode, function (node) { - node.nodeName == 'DIV' && - node.classList.contains('ytp-autonav-toggle-button') && - node.getAttribute('aria-checked') == "true" && + node.nodeName == "DIV" && + node.classList.contains("ytp-autonav-toggle-button") && + node.getAttribute("aria-checked") == "true" && node.click(); }); } - }; + } }); observer.observe(document, { childList: true, subtree: true, - attributes: true + attributes: true, }); })();