Use AppleScript to control Beats Music

Similar to my post Use AppleScript to control Google Play Music All Access, here are instructions to use AppleScript to control Beats Music. It’s so much nicer to have global hotkeys to control music players. See the Use AppleScript to control Google Play Music All Access for some credit for how I figured this all out. Applying the same technique to Beats Music was a lot easier because the DOM element IDs aren’t obfuscated.

tell application "Google Chrome"
  repeat with w in (every window)
    repeat with t in (every tab whose URL contains "listen.beatsmusic.com") of w
      # Options for ids are:
      # t-prev = previous
      # t-play = play/pause
      # t-next = next
      set elemId to "t-play"
      tell t to execute javascript "document.getElementById('" & elemId & "').click();"
      return
    end repeat
  end repeat
end tell

If you want to get this as an Alfred App Workflow, download it here.

comments powered by Disqus