Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip Disliked Songs #1505

Merged
merged 7 commits into from
Dec 9, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/i18n/resources/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,10 @@
"visualizer-type": "Visualizer Type"
},
"name": "Visualizer"
},
"skip-disliked-songs": {
"description": "Skips disliked songs",
"name": "Skip Disliked Songs"
}
}
}
34 changes: 34 additions & 0 deletions src/plugins/skip-disliked-songs/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { t } from '@/i18n';
import { createPlugin } from '@/utils';

export default createPlugin({
name: () => t('plugins.skip-disliked-songs.name'),
description: () => t('plugins.skip-disliked-songs.description'),
restartNeeded: false,
renderer: {
observer: null as MutationObserver | null,
async start() {
const likeBtn = await this.waitForElem('#like-button-renderer');
this.observer = new MutationObserver(() => {
if (likeBtn?.getAttribute("like-status") == "DISLIKE")
document.querySelector("tp-yt-paper-icon-button.next-button")?.click();
});
this.observer.observe(likeBtn,
{ attributes: true, childList: false, subtree: false });
},
stop() {
this.observer?.disconnect();
},
waitForElem(selector) {
return new Promise(resolve => {
const interval = setInterval(() => {
const elem = document.querySelector(selector);
if (!elem) return;

clearInterval(interval);
resolve(elem);
});
});
}
}
});
MiepHD marked this conversation as resolved.
Show resolved Hide resolved