Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save smgoller/cf58ae7570da512e295c to your computer and use it in GitHub Desktop.
Save smgoller/cf58ae7570da512e295c to your computer and use it in GitHub Desktop.
Post current song playing in Google Play Music in Chrome to Colloquy
using terms from application "Colloquy"
on process user command c with arguments for view
try
if c is in {"nowplaying", "np", "playing"} then
tell application "Google Chrome"
repeat with w in (every window)
repeat with t in (every tab whose URL contains "play.google.com/music") of w
if (execute t javascript "document.getElementsByClassName('playing').length") is equal to 1 then
set tTitle to execute t javascript "document.getElementById('playerSongTitle').innerText;"
set tArtist to execute t javascript "document.getElementById('player-artist').innerText;"
set tAlbum to execute t javascript "document.getElementsByClassName('player-album')[0].innerText;"
set tTime to execute t javascript "document.getElementById('time_container_duration').innerText;"
set msg to "is listening to <font color=\"orange\"><b>" & tTitle & "</b></font> by <font color=\"green\"><b>" & tArtist & "</b></font> from album <font color=\"teal\"><b>" & tAlbum & "</b></font> <font color=\"blue\">[" & tTime & "]</font>"
end if
end repeat
end repeat
end tell
tell view to send message msg with action tense
end if
end try
end process user command
end using terms from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment