mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 10:31:47 +00:00
fix: picture-in-picture icon
This commit is contained in:
@ -42,11 +42,9 @@ const menuObserver = new MutationObserver(() => {
|
|||||||
menu.prepend(downloadButton);
|
menu.prepend(downloadButton);
|
||||||
progress = document.querySelector('#ytmcustom-download');
|
progress = document.querySelector('#ytmcustom-download');
|
||||||
|
|
||||||
if (doneFirstLoad) {
|
if (!doneFirstLoad) {
|
||||||
return;
|
setTimeout(() => (doneFirstLoad ||= true), 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(() => (doneFirstLoad ||= true), 500);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export const onRendererLoad = ({
|
export const onRendererLoad = ({
|
||||||
|
|||||||
@ -18,6 +18,8 @@ let useNativePiP = false;
|
|||||||
let menu: Element | null = null;
|
let menu: Element | null = null;
|
||||||
const pipButton = ElementFromHtml(pipHTML);
|
const pipButton = ElementFromHtml(pipHTML);
|
||||||
|
|
||||||
|
let doneFirstLoad = false;
|
||||||
|
|
||||||
// Will also clone
|
// Will also clone
|
||||||
function replaceButton(query: string, button: Element) {
|
function replaceButton(query: string, button: Element) {
|
||||||
const svg = button.querySelector('#icon svg')?.cloneNode(true);
|
const svg = button.querySelector('#icon svg')?.cloneNode(true);
|
||||||
@ -61,11 +63,15 @@ const observer = new MutationObserver(() => {
|
|||||||
const menuUrl = $<HTMLAnchorElement>(
|
const menuUrl = $<HTMLAnchorElement>(
|
||||||
'tp-yt-paper-listbox [tabindex="0"] #navigation-endpoint',
|
'tp-yt-paper-listbox [tabindex="0"] #navigation-endpoint',
|
||||||
)?.href;
|
)?.href;
|
||||||
if (!menuUrl?.includes('watch?')) {
|
if (!menuUrl?.includes('watch?') && doneFirstLoad) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
menu.prepend(pipButton);
|
menu.prepend(pipButton);
|
||||||
|
|
||||||
|
if (!doneFirstLoad) {
|
||||||
|
setTimeout(() => (doneFirstLoad ||= true), 500);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const togglePictureInPicture = async () => {
|
const togglePictureInPicture = async () => {
|
||||||
|
|||||||
@ -12,7 +12,7 @@
|
|||||||
tabindex="-1"
|
tabindex="-1"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="icon menu-icon style-scope ytmusic-menu-navigation-item-renderer"
|
class="icon ytmd-menu-item style-scope ytmusic-menu-navigation-item-renderer"
|
||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
id="Layer_1"
|
id="Layer_1"
|
||||||
|
|||||||
Reference in New Issue
Block a user