fix: picture-in-picture icon

This commit is contained in:
JellyBrick
2023-12-28 02:17:42 +09:00
parent e67699fed5
commit 48eeb6bca3
3 changed files with 10 additions and 6 deletions

View File

@ -42,11 +42,9 @@ const menuObserver = new MutationObserver(() => {
menu.prepend(downloadButton);
progress = document.querySelector('#ytmcustom-download');
if (doneFirstLoad) {
return;
if (!doneFirstLoad) {
setTimeout(() => (doneFirstLoad ||= true), 500);
}
setTimeout(() => (doneFirstLoad ||= true), 500);
});
export const onRendererLoad = ({

View File

@ -18,6 +18,8 @@ let useNativePiP = false;
let menu: Element | null = null;
const pipButton = ElementFromHtml(pipHTML);
let doneFirstLoad = false;
// Will also clone
function replaceButton(query: string, button: Element) {
const svg = button.querySelector('#icon svg')?.cloneNode(true);
@ -61,11 +63,15 @@ const observer = new MutationObserver(() => {
const menuUrl = $<HTMLAnchorElement>(
'tp-yt-paper-listbox [tabindex="0"] #navigation-endpoint',
)?.href;
if (!menuUrl?.includes('watch?')) {
if (!menuUrl?.includes('watch?') && doneFirstLoad) {
return;
}
menu.prepend(pipButton);
if (!doneFirstLoad) {
setTimeout(() => (doneFirstLoad ||= true), 500);
}
});
const togglePictureInPicture = async () => {

View File

@ -12,7 +12,7 @@
tabindex="-1"
>
<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
id="Layer_1"