Skip to content

Instantly share code, notes, and snippets.

@ChristoferK
ChristoferK / Menubar Applications.applescript
Last active June 7, 2019 07:49
[Menubar Applications] UI scripting commands in AppleScript that provide access to the menubar applications and their menubar icons #AppleScript #applications #menubar #SystemEvents #UI
use application "System Events"
set _P to a reference to (processes whose class of menu bar 2 = menu bar)
name of _P --> A list of apps sitting in the menu bar
menu bar item 1 of menu bar 2 of _P --> Their icons
@ChristoferK
ChristoferK / YouTube Video Playing Status.applescript
Last active June 17, 2018 02:56
[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
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