Created
July 7, 2017 15:39
-
-
Save rsayers/68d110b7c8652da05802a323a83716d0 to your computer and use it in GitHub Desktop.
Applescript to return current track playing in digitally imported
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tell application "Google Chrome" | |
set window_list to every window # get the windows | |
repeat with the_window in window_list # for every window | |
set tab_list to every tab in the_window # get the tabs | |
repeat with the_tab in tab_list # for every tab | |
set the_url to the URL of the_tab # grab the URL | |
if "di.fm" is in the_url then | |
tell the_tab | |
set song_title to execute javascript "document.getElementsByClassName('now-playing')[0].getElementsByClassName(\"title\")[0].text" | |
set artist_name to execute javascript "document.getElementsByClassName('now-playing')[0].getElementsByClassName(\"artist\")[0].innerText" | |
set song_url to execute javascript "document.getElementsByClassName('now-playing')[0].getElementsByClassName(\"title\")[0].href" | |
set output to (song_title & " " & artist_name & " " & song_url) | |
return output | |
end tell | |
end if | |
end repeat | |
end repeat | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment