mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-16 12:42:06 +00:00
fix(in-app-menu): remove unused observer
This commit is contained in:
@ -7,9 +7,6 @@ import { createPanel } from './menu/panel';
|
|||||||
import { ElementFromFile } from '../utils';
|
import { ElementFromFile } from '../utils';
|
||||||
import { isEnabled } from '../../config/plugins';
|
import { isEnabled } from '../../config/plugins';
|
||||||
|
|
||||||
type ElectronCSSStyleDeclaration = CSSStyleDeclaration & { webkitAppRegion: 'drag' | 'no-drag' };
|
|
||||||
type ElectronHTMLElement = HTMLElement & { style: ElectronCSSStyleDeclaration };
|
|
||||||
|
|
||||||
function $<E extends Element = Element>(selector: string) {
|
function $<E extends Element = Element>(selector: string) {
|
||||||
return document.querySelector<E>(selector);
|
return document.querySelector<E>(selector);
|
||||||
}
|
}
|
||||||
@ -68,7 +65,6 @@ export default () => {
|
|||||||
|
|
||||||
// Increases the right margin of Navbar background when the scrollbar is visible to avoid blocking it (z-index doesn't affect it)
|
// Increases the right margin of Navbar background when the scrollbar is visible to avoid blocking it (z-index doesn't affect it)
|
||||||
document.addEventListener('apiLoaded', () => {
|
document.addEventListener('apiLoaded', () => {
|
||||||
setupSearchOpenObserver();
|
|
||||||
const htmlHeadStyle = $('head > div > style');
|
const htmlHeadStyle = $('head > div > style');
|
||||||
if (htmlHeadStyle) {
|
if (htmlHeadStyle) {
|
||||||
// HACK: This is a hack to remove the scrollbar width
|
// HACK: This is a hack to remove the scrollbar width
|
||||||
@ -76,16 +72,3 @@ export default () => {
|
|||||||
}
|
}
|
||||||
}, { once: true, passive: true });
|
}, { once: true, passive: true });
|
||||||
};
|
};
|
||||||
|
|
||||||
function setupSearchOpenObserver() {
|
|
||||||
const searchOpenObserver = new MutationObserver((mutations) => {
|
|
||||||
const navBarBackground = $<ElectronHTMLElement>('#nav-bar-background');
|
|
||||||
if (navBarBackground) {
|
|
||||||
navBarBackground.style.webkitAppRegion = (mutations[0].target as HTMLElement & { opened: boolean }).opened ? 'no-drag' : 'drag';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
const searchBox = $('ytmusic-search-box');
|
|
||||||
if (searchBox) {
|
|
||||||
searchOpenObserver.observe(searchBox, { attributeFilter: ['opened'] });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user