mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-13 19:31:46 +00:00
43 lines
1.1 KiB
TypeScript
43 lines
1.1 KiB
TypeScript
import { t } from '@/i18n';
|
|
import { createPlugin } from '@/utils';
|
|
import { waitForElement } from '@/utils/wait-for-element';
|
|
|
|
export default createPlugin<
|
|
unknown,
|
|
unknown,
|
|
{
|
|
observer?: MutationObserver;
|
|
start(): void;
|
|
stop(): void;
|
|
}
|
|
>({
|
|
name: () => t('plugins.skip-disliked-songs.name'),
|
|
description: () => t('plugins.skip-disliked-songs.description'),
|
|
restartNeeded: false,
|
|
renderer: {
|
|
start() {
|
|
waitForElement<HTMLElement>('#dislike-button-renderer').then(
|
|
(dislikeBtn) => {
|
|
this.observer = new MutationObserver(() => {
|
|
if (dislikeBtn?.getAttribute('like-status') == 'DISLIKE') {
|
|
document
|
|
.querySelector<HTMLButtonElement>(
|
|
'tp-yt-paper-icon-button.next-button',
|
|
)
|
|
?.click();
|
|
}
|
|
});
|
|
this.observer.observe(dislikeBtn, {
|
|
attributes: true,
|
|
childList: false,
|
|
subtree: false,
|
|
});
|
|
},
|
|
);
|
|
},
|
|
stop() {
|
|
this.observer?.disconnect();
|
|
},
|
|
},
|
|
});
|