Advertisement
Guest User

Untitled

a guest
Dec 29th, 2024
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. function applyExternalAPI_Polyfill() {
  4.         // @ts-expect-error API above
  5.         window.externalAPI = {
  6.             ___WEB_SCROBBLER_EVENTS: {},
  7.  
  8.             // on PLAY/OFF, on changing timer offset
  9.             EVENT_STATE: YandexMusicEvents.EVENT_STATE,
  10.  
  11.             // on changing track
  12.             EVENT_TRACK: YandexMusicEvents.EVENT_TRACK,
  13.  
  14.             on(event: YandexMusicEvents, listener: () => void) {
  15.  
  16.             },
  17.             off(event: YandexMusicEvents, listener: () => void) {
  18.  
  19.             },
  20.             isPlaying: () => document.querySelector('[*|href="#pause_filled"]') instanceof SVGUseElement,
  21.             getCurrentTrack() {
  22.                 const duration = getTimecodeRoot()?.querySelector('input')?.value;
  23.  
  24.                 const cover = (document.querySelector("img[class*='PlayerBarDesktop_cover']")! as HTMLImageElement).src;
  25.  
  26.                 return {
  27.                     title: "",
  28.                     album: { title: "" },
  29.                     cover,
  30.                     artists: [{ title: "" }],
  31.                     duration: 26000,
  32.                     link: "",
  33.                 }
  34.             },
  35.             getProgress: () => ({ position: Number(getInputRoot()?.value) * 1000 })
  36.         } satisfies Window["externalAPI"];
  37.  
  38.         isPolyfilled = true;
  39.         console.log("yandex-music scrobbler: polyfilling successfull!")
  40.     }
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement