mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-16 20:52:06 +00:00
feat: migration to TypeScript part 2
Co-authored-by: Su-Yong <simssy2205@gmail.com>
This commit is contained in:
14
plugins/disable-autoplay/front.ts
Normal file
14
plugins/disable-autoplay/front.ts
Normal file
@ -0,0 +1,14 @@
|
||||
export default () => {
|
||||
document.addEventListener('apiLoaded', (apiEvent) => {
|
||||
apiEvent.detail.addEventListener('videodatachange', (name: string) => {
|
||||
if (name === 'dataloaded') {
|
||||
apiEvent.detail.pauseVideo();
|
||||
(document.querySelector('video') as HTMLVideoElement)?.addEventListener('timeupdate', (e) => {
|
||||
(e.target as HTMLVideoElement)?.pause();
|
||||
});
|
||||
} else {
|
||||
(document.querySelector('video') as HTMLVideoElement).ontimeupdate = null;
|
||||
}
|
||||
});
|
||||
}, { once: true, passive: true });
|
||||
};
|
||||
Reference in New Issue
Block a user