Skip to content

Instantly share code, notes, and snippets.

@mikesmullin
Created May 7, 2025 23:12
Show Gist options
  • Save mikesmullin/a186a7857b46b8521bd90a7acb797b3a to your computer and use it in GitHub Desktop.
Save mikesmullin/a186a7857b46b8521bd90a7acb797b3a to your computer and use it in GitHub Desktop.
Spotify Javascript Automation

Spotify Javascript Automation

I'm doing this because Spotify has an annoying bug, where it cannot set the volume properly when I click (it instead picks a random low-numbered value like 0.23, than the one I chose 0.9.)

  1. open devtools (F12) > debugger > search
  2. search for:
    this._harmony.setVolume
    
  3. click the "format source" button
  4. set breakpoint on it (cdn/build/web-player/web-player.*.js:21600)
  5. adjust volume normally, to catch breakpoint
  6. input in console:
    window.HARMONY = this._harmony
    
  7. remove breakpoint and continue
  8. now you can control from console:
    await HARMONY.setVolume(0.9)
    (some PlayerAPIClientError errors are normal, if music has not begun playing)

Harmony is the vendored web player module a.k.a. window.webpackChunkclient_web[0][1]['4310']

P.S. also interesting 1 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment