mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-12 11:01:45 +00:00
fix(ambient-mode): fix ambient-mode not working for videos after restart (#2294)
* Fix Ambient Mode not working for videos after restart (#2255) This should fix https://github.com/th-ch/youtube-music/issues/1641 * fix: fix waitForElement --------- Co-authored-by: craftgeil <80261988+craftgeil@users.noreply.github.com>
This commit is contained in:
11
src/utils/wait-for-element.ts
Normal file
11
src/utils/wait-for-element.ts
Normal file
@ -0,0 +1,11 @@
|
||||
export const waitForElement = <T extends Element>(selector: string): Promise<T> => {
|
||||
return new Promise<T>((resolve) => {
|
||||
const interval = setInterval(() => {
|
||||
const elem = document.querySelector<T>(selector);
|
||||
if (!elem) return;
|
||||
|
||||
clearInterval(interval);
|
||||
resolve(elem);
|
||||
});
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user