Fix Settings sometimes not being injected to header

This commit is contained in:
redphx 2024-07-28 15:58:03 +07:00
parent eb42f4a3d3
commit 9fad2914ac
3 changed files with 7 additions and 7 deletions

View File

@ -5746,12 +5746,12 @@ class HeaderSection {
HeaderSection.#$remotePlayBtn.classList.remove("bx-gone");
}
static watchHeader() {
const $header = document.querySelector("#PageContent header");
if (!$header)
let $root = document.querySelector("#PageContent header") || document.querySelector("#root");
if (!$root)
return;
HeaderSection.#observer && HeaderSection.#observer.disconnect(), HeaderSection.#observer = new MutationObserver((mutationList) => {
HeaderSection.#timeout && clearTimeout(HeaderSection.#timeout), HeaderSection.#timeout = window.setTimeout(HeaderSection.checkHeader, 2000);
}), HeaderSection.#observer.observe($header, { subtree: !0, childList: !0 }), HeaderSection.checkHeader();
}), HeaderSection.#observer.observe($root, { subtree: !0, childList: !0 }), HeaderSection.checkHeader();
}
}

View File

@ -116,7 +116,7 @@ document.addEventListener('readystatechange', e => {
// Preload Remote Play
getPref(PrefKey.REMOTE_PLAY_ENABLED) && RemotePlay.preload();
} else {
// Show Settings button in the header when not signed
// Show Settings button in the header when not signed in
HeaderSection.watchHeader();
}

View File

@ -68,8 +68,8 @@ export class HeaderSection {
}
static watchHeader() {
const $header = document.querySelector('#PageContent header');
if (!$header) {
let $root = document.querySelector('#PageContent header') || document.querySelector('#root');
if (!$root) {
return;
}
@ -78,7 +78,7 @@ export class HeaderSection {
HeaderSection.#timeout && clearTimeout(HeaderSection.#timeout);
HeaderSection.#timeout = window.setTimeout(HeaderSection.checkHeader, 2000);
});
HeaderSection.#observer.observe($header, {subtree: true, childList: true});
HeaderSection.#observer.observe($root, {subtree: true, childList: true});
HeaderSection.checkHeader();
}