mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 18:41:47 +00:00
fix(unobtrusive-player): handle shuffle play (#3247)
This commit is contained in:
@ -6,18 +6,39 @@ import { t } from '@/i18n';
|
|||||||
const handlePlay = (e: MouseEvent) => {
|
const handlePlay = (e: MouseEvent) => {
|
||||||
if (!(e.target instanceof HTMLElement)) return;
|
if (!(e.target instanceof HTMLElement)) return;
|
||||||
|
|
||||||
if (
|
// Player bar handler
|
||||||
e.target.closest('ytmusic-play-button-renderer') &&
|
|
||||||
!e.target.closest('ytmusic-player-page')
|
|
||||||
) {
|
|
||||||
document.body.classList.add('unobtrusive-player--did-play');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
e.target.closest('ytmusic-player-bar') &&
|
e.target.closest('ytmusic-player-bar') &&
|
||||||
!document.body.classList.contains('unobtrusive-player--auto-closing')
|
!document.body.classList.contains('unobtrusive-player--auto-closing')
|
||||||
) {
|
) {
|
||||||
document.body.classList.remove('unobtrusive-player--did-play');
|
document.body.classList.remove('unobtrusive-player--did-play');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Song play button handler
|
||||||
|
if (
|
||||||
|
e.target.closest('ytmusic-play-button-renderer') &&
|
||||||
|
!e.target.closest('ytmusic-player-page')
|
||||||
|
) {
|
||||||
|
document.body.classList.add('unobtrusive-player--did-play');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Shuffle play menu item handler
|
||||||
|
const shuffleIconPathData = (
|
||||||
|
document.querySelector('iron-iconset-svg[name="yt-sys-icons"] #shuffle')
|
||||||
|
?.firstChild as SVGElement | null
|
||||||
|
)
|
||||||
|
?.getAttribute('d')
|
||||||
|
?.substring(0, 15);
|
||||||
|
|
||||||
|
if (
|
||||||
|
e.target.closest(
|
||||||
|
`ytmusic-menu-navigation-item-renderer:has(yt-icon path[d^="${shuffleIconPathData}"])`,
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
document.body.classList.add('unobtrusive-player--did-play');
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user