mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-10 10:11:46 +00:00
fix download button not showing first time menu is opened
This commit is contained in:
@ -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;
|
||||
|
||||
Reference in New Issue
Block a user