Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function applyExternalAPI_Polyfill() {
- // @ts-expect-error API above
- window.externalAPI = {
- ___WEB_SCROBBLER_EVENTS: {},
- // on PLAY/OFF, on changing timer offset
- EVENT_STATE: YandexMusicEvents.EVENT_STATE,
- // on changing track
- EVENT_TRACK: YandexMusicEvents.EVENT_TRACK,
- on(event: YandexMusicEvents, listener: () => void) {
- },
- off(event: YandexMusicEvents, listener: () => void) {
- },
- isPlaying: () => document.querySelector('[*|href="#pause_filled"]') instanceof SVGUseElement,
- getCurrentTrack() {
- const duration = getTimecodeRoot()?.querySelector('input')?.value;
- const cover = (document.querySelector("img[class*='PlayerBarDesktop_cover']")! as HTMLImageElement).src;
- return {
- title: "",
- album: { title: "" },
- cover,
- artists: [{ title: "" }],
- duration: 26000,
- link: "",
- }
- },
- getProgress: () => ({ position: Number(getInputRoot()?.value) * 1000 })
- } satisfies Window["externalAPI"];
- isPolyfilled = true;
- console.log("yandex-music scrobbler: polyfilling successfull!")
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement