From cd41f093be9623121e23e0ee8b35d777d6e13fe4 Mon Sep 17 00:00:00 2001 From: Araxeus <78568641+Araxeus@users.noreply.github.com> Date: Sat, 4 Mar 2023 15:15:01 +0200 Subject: [PATCH] fix download button not showing first time menu is opened --- plugins/downloader/front.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/downloader/front.js b/plugins/downloader/front.js index 3113f029..cb9b167f 100644 --- a/plugins/downloader/front.js +++ b/plugins/downloader/front.js @@ -11,6 +11,8 @@ const downloadButton = ElementFromFile( ); let pluginOptions = {}; +let doneFirstLoad = false; + const observer = new MutationObserver(() => { if (!menu) { menu = getSongMenu(); @@ -18,10 +20,13 @@ const observer = new MutationObserver(() => { } if (menu.contains(downloadButton)) return; const menuUrl = document.querySelector('tp-yt-paper-listbox [tabindex="0"] #navigation-endpoint')?.href; - if (!menuUrl?.includes('watch?')) return; + if (!menuUrl?.includes('watch?') && doneFirstLoad) return; menu.prepend(downloadButton); progress = document.querySelector("#ytmcustom-download"); + + if (doneFirstLoad) return; + setTimeout(() => doneFirstLoad ||= true, 500); }); const baseUrl = defaultConfig.url;