mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-10 18:21:47 +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 pluginOptions = {};
|
||||||
|
|
||||||
|
let doneFirstLoad = false;
|
||||||
|
|
||||||
const observer = new MutationObserver(() => {
|
const observer = new MutationObserver(() => {
|
||||||
if (!menu) {
|
if (!menu) {
|
||||||
menu = getSongMenu();
|
menu = getSongMenu();
|
||||||
@ -18,10 +20,13 @@ const observer = new MutationObserver(() => {
|
|||||||
}
|
}
|
||||||
if (menu.contains(downloadButton)) return;
|
if (menu.contains(downloadButton)) return;
|
||||||
const menuUrl = document.querySelector('tp-yt-paper-listbox [tabindex="0"] #navigation-endpoint')?.href;
|
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);
|
menu.prepend(downloadButton);
|
||||||
progress = document.querySelector("#ytmcustom-download");
|
progress = document.querySelector("#ytmcustom-download");
|
||||||
|
|
||||||
|
if (doneFirstLoad) return;
|
||||||
|
setTimeout(() => doneFirstLoad ||= true, 500);
|
||||||
});
|
});
|
||||||
|
|
||||||
const baseUrl = defaultConfig.url;
|
const baseUrl = defaultConfig.url;
|
||||||
|
|||||||
Reference in New Issue
Block a user