Skip to content

Instantly share code, notes, and snippets.

@qkdreyer
Last active December 15, 2016 12:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save qkdreyer/14ea36ce3bc9cc5632b78252fe35ec76 to your computer and use it in GitHub Desktop.
Save qkdreyer/14ea36ce3bc9cc5632b78252fe35ec76 to your computer and use it in GitHub Desktop.
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