fix download button not showing first time menu is opened

This commit is contained in:
Araxeus
2023-03-04 15:15:01 +02:00
parent a2eb3a3319
commit cd41f093be

View File

@ -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;