Skip to content

Instantly share code, notes, and snippets.

@willhoney7
Created September 6, 2018 17:45
Show Gist options
  • Save willhoney7/59a41622b709aff4fdd11d10fb49cfff to your computer and use it in GitHub Desktop.
Save willhoney7/59a41622b709aff4fdd11d10fb49cfff to your computer and use it in GitHub Desktop.
play/pause youtube via applescript
tell application "Google Chrome"
set found_video to false
set window_list to every window
repeat with the_window in window_list
if found_video is equal to true then
exit repeat
end if
set tab_list to every tab in the_window
repeat with the_tab in tab_list
if the title of the_tab contains "- YouTube" then
tell the_tab
execute javascript "document.querySelector(\"video\").click();"
end tell
set found_video to true
exit repeat
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