mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-10 10:11:46 +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) => {
|
||||
if (!(e.target instanceof HTMLElement)) return;
|
||||
|
||||
if (
|
||||
e.target.closest('ytmusic-play-button-renderer') &&
|
||||
!e.target.closest('ytmusic-player-page')
|
||||
) {
|
||||
document.body.classList.add('unobtrusive-player--did-play');
|
||||
}
|
||||
|
||||
// Player bar handler
|
||||
if (
|
||||
e.target.closest('ytmusic-player-bar') &&
|
||||
!document.body.classList.contains('unobtrusive-player--auto-closing')
|
||||
) {
|
||||
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