Last active
June 17, 2018 02:56
-
-
Save ChristoferK/c56a8b03c755b1fd97151105e48034b7 to your computer and use it in GitHub Desktop.
[YouTube Video State] Returns `playing`, `paused`, or `ended` to signify the state of a YouTube video open in Safari browser #AppleScript #YouTube #video #playing #Safari #JavaScript
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 "Safari" to tell front window to tell ¬ | |
(first tab whose URL contains "youtube.com/watch?v=") to ¬ | |
if it exists then do JavaScript [¬ | |
"document", ¬ | |
".querySelector('div[class*=\"-mode\"]')", ¬ | |
".className", ¬ | |
".match(/(playing|paused|ended)-mode/)[1]"] as text |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment