feat(api-server): add endpoint to get shuffle state (#2792)

This commit is contained in:
Franz DC
2025-01-18 13:23:17 +08:00
committed by GitHub
parent 3339f997e3
commit 368b251e3f
6 changed files with 102 additions and 6 deletions

View File

@ -80,6 +80,20 @@ async function onApiLoaded() {
>('ytmusic-player-bar')
?.queue.shuffle();
});
const isShuffled = () => {
const isShuffled =
document
.querySelector<HTMLElement>('ytmusic-player-bar')
?.attributes.getNamedItem('shuffle-on') ?? null;
return isShuffled !== null;
};
window.ipcRenderer.on('ytmd:get-shuffle', () => {
window.ipcRenderer.send('ytmd:get-shuffle-response', isShuffled());
});
window.ipcRenderer.on(
'ytmd:update-like',
(_, status: 'LIKE' | 'DISLIKE' = 'LIKE') => {