Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Automatically open Safari Web Inspector
#!/usr/bin/osascript
# Automatically open Safari Web Inspector
set _browser to "Safari"
set _develop to "Développement"
set _inspector to "Inspecteur web"
set _phone to "iPhone"
set _ignore to "about:"
tell application _browser to activate
tell application "System Events"
repeat with _window in every window of process _browser
if title of _window contains _inspector then
return
end if
end repeat
set _winCount to count windows of process _browser
repeat with developMenuItem in menu items of menu _develop of menu bar item _develop of menu bar 1 of process _browser
if _phone is in name of developMenuItem then
set apps to entire contents of developMenuItem
repeat with _app in apps
if (_ignore is not in name of _app) and (count (name) of _app) is greater than 0 then
click _app
if (_winCount is less than (count windows of process _browser)) then
return
end if
end if
end repeat
exit repeat
end if
end repeat
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment