From 7aa72f60dfc3afde9dfc8f0683f1512dd1bb4838 Mon Sep 17 00:00:00 2001 From: goodtube4u Date: Thu, 23 Oct 2025 18:45:13 +1000 Subject: [PATCH] Fix for volume shortcuts, minor cleanup --- goodtube.js | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/goodtube.js b/goodtube.js index 3832fe0..28ee5c5 100644 --- a/goodtube.js +++ b/goodtube.js @@ -1118,8 +1118,14 @@ if (goodTube_fallback) { // Support the 'i' shortcut (keydown only) if (keyPressed === 'i' && event.type.toLowerCase() === 'keydown') { - // Click the picture in picture button - goodTube_helper_click(document.querySelector('.ytp-pip-button')); + // Find the picture in picture button + let pipButton = document.querySelector('.ytp-pip-button'); + + // If we found the picture in picture button + if (pipButton) { + // Click it + goodTube_helper_click(pipButton); + } // Prevent default actions event.preventDefault(); @@ -1435,7 +1441,14 @@ // Theater mode (toggle) - this should only work when not in fullscreen else if (event.data === 'goodTube_theater' && !document.fullscreenElement) { - goodTube_helper_click(document.querySelector('.ytp-size-button')); + // Find the theater button + let theaterButton = document.querySelector('.ytp-size-button'); + + // If we found the theater button + if (theaterButton) { + // Click it + goodTube_helper_click(theaterButton); + } } // Autoplay @@ -3573,6 +3586,9 @@ goodTube_iframe_supportDoubleSpeed_allowNextClick = true; goodTube_helper_click(goodTube_iframe_supportDoubleSpeed_videoElement); goodTube_iframe_supportDoubleSpeed_allowNextClick = false; + + // Focus the video element + setTimeout(goodTube_iframe_supportDoubleSpeed_videoElement.focus()); } // Otherwise, double playback rate did happen else {