From 9c7b63ffb6f3337a89911beebcef64dbbf587a44 Mon Sep 17 00:00:00 2001 From: Muffin Date: Tue, 22 Aug 2023 00:25:36 -0500 Subject: [PATCH] Simplify, and also avoid relying on class hashes (they're different in the desktop app) --- extensions/NexusKitten/controlcontrols.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/extensions/NexusKitten/controlcontrols.js b/extensions/NexusKitten/controlcontrols.js index e5a2a3380c..6cdde34dcc 100644 --- a/extensions/NexusKitten/controlcontrols.js +++ b/extensions/NexusKitten/controlcontrols.js @@ -21,15 +21,15 @@ pauseButton = undefined; stopButton = undefined; - const rightButtons = document.getElementsByClassName('button_outlined-button_1bS__ stage-header_stage-button_hkl9B'); + const rightButtons = document.querySelectorAll('[class*="stage-header_stage-button_"]'); fullScreen = rightButtons[rightButtons.length - 1]; if (!fullScreen) { - fullScreen = document.getElementsByClassName('control-button fullscreen-button')[0] || document.getElementsByClassName('standalone-fullscreen-button')[0]; + fullScreen = document.querySelector('.fullscreen-button') || document.querySelector('.standalone-fullscreen-button'); } - greenFlag = document.getElementsByClassName('green-flag_green-flag_1kiAo')[0] || document.getElementsByClassName('control-button green-flag-button active')[0]; - pauseButton = document.getElementsByClassName('pause-btn addons-display-none-pause')[0] || document.getElementsByClassName('control-button pause-button')[0]; - stopButton = document.getElementsByClassName('stop-all_stop-all_1Y8P9')[0] || document.getElementsByClassName('control-button stop-all-button')[0]; + greenFlag = document.querySelector('[class*="green-flag_green-flag_"]') || document.querySelector('.green-flag-button'); + pauseButton = document.querySelector('.pause-btn') || document.querySelector('.pause-button'); + stopButton = document.querySelector('[class*="stop-all_stop-all_"]') || document.querySelector('.stop-all-button'); }; class controlcontrols { @@ -126,13 +126,13 @@ optionShown(args) { getButtons(); if (args.OPTION === "green flag" && greenFlag) { - return !(greenFlag.style.display === 'none'); + return greenFlag.style.display !== 'none'; } else if (args.OPTION === "pause" && pauseButton) { - return !(pauseButton.style.display === 'none'); + return pauseButton.style.display !== 'none'; } else if (args.OPTION === "stop" && stopButton) { - return !(stopButton.style.display === 'none'); + return stopButton.style.display !== 'none'; } else if (args.OPTION === "fullscreen" && fullScreen) { - return !(fullScreen.style.display === 'none'); + return fullScreen.style.display !== 'none'; } return false; }