From 01161886238223807c34f84b48a4deb9375d9635 Mon Sep 17 00:00:00 2001 From: JellyBrick Date: Tue, 9 Sep 2025 23:43:42 +0900 Subject: [PATCH] fix: maybe fix #3613 --- src/plugins/video-toggle/index.tsx | 53 +++++++++++++++--------------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/src/plugins/video-toggle/index.tsx b/src/plugins/video-toggle/index.tsx index 9f3ea9e0..4ca9eeb1 100644 --- a/src/plugins/video-toggle/index.tsx +++ b/src/plugins/video-toggle/index.tsx @@ -314,38 +314,37 @@ export default createPlugin({ }; if (config.mode !== 'native' && config.mode != 'disabled') { - document - .querySelector('#player') - ?.prepend(switchButtonContainer); + setTimeout(() => { + const playerSelector = + document.querySelector('#player'); + if (!playerSelector) return; - setVideoState(!config.hideVideo); - forcePlaybackMode(); - // Fix black video - if (video) { - video.style.height = 'auto'; - } - - video?.addEventListener('ytmd:src-changed', videoStarted); - - observeThumbnail(); - videoStarted(); - - switch (config.align) { - case 'right': { - switchButtonContainer.style.justifyContent = 'flex-end'; - return; + playerSelector.prepend(switchButtonContainer); + setVideoState(!config.hideVideo); + forcePlaybackMode(); + if (video) { + video.style.height = 'auto'; } + video?.addEventListener('ytmd:src-changed', videoStarted); + observeThumbnail(); + videoStarted(); + switch (config.align) { + case 'right': { + switchButtonContainer.style.justifyContent = 'flex-end'; + return; + } - case 'middle': { - switchButtonContainer.style.justifyContent = 'center'; - return; - } + case 'middle': { + switchButtonContainer.style.justifyContent = 'center'; + return; + } - default: - case 'left': { - switchButtonContainer.style.justifyContent = 'flex-start'; + default: + case 'left': { + switchButtonContainer.style.justifyContent = 'flex-start'; + } } - } + }, 0); } }, onConfigChange(newConfig) {