mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-13 11:21:46 +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:
@ -1,12 +1,12 @@
|
||||
import { t } from '@/i18n';
|
||||
import { createPlugin } from '@/utils';
|
||||
import { waitForElement } from '@/utils/wait-for-element';
|
||||
|
||||
export default createPlugin<
|
||||
unknown,
|
||||
unknown,
|
||||
{
|
||||
observer?: MutationObserver;
|
||||
waitForElem(selector: string): Promise<HTMLElement>;
|
||||
start(): void;
|
||||
stop(): void;
|
||||
}
|
||||
@ -15,19 +15,8 @@ export default createPlugin<
|
||||
description: () => t('plugins.skip-disliked-songs.description'),
|
||||
restartNeeded: false,
|
||||
renderer: {
|
||||
waitForElem(selector: string) {
|
||||
return new Promise<HTMLElement>((resolve) => {
|
||||
const interval = setInterval(() => {
|
||||
const elem = document.querySelector<HTMLElement>(selector);
|
||||
if (!elem) return;
|
||||
|
||||
clearInterval(interval);
|
||||
resolve(elem);
|
||||
});
|
||||
});
|
||||
},
|
||||
start() {
|
||||
this.waitForElem('#dislike-button-renderer').then((dislikeBtn) => {
|
||||
waitForElement<HTMLElement>('#dislike-button-renderer').then((dislikeBtn) => {
|
||||
this.observer = new MutationObserver(() => {
|
||||
if (dislikeBtn?.getAttribute('like-status') == 'DISLIKE') {
|
||||
document
|
||||
|
||||
Reference in New Issue
Block a user