Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save revolunet/c16f121957b73781ace8 to your computer and use it in GitHub Desktop.
Save revolunet/c16f121957b73781ace8 to your computer and use it in GitHub Desktop.
Ouvrir automatiquement Safari web inspector avec cordova run (french version)
#!/usr/bin/osascript
#
# ajouter ce script dans .cordova/hooks/after_run/safari-webinspector.applescript
# le rendre executable avec un chmod +x
#
# lancer l'app avec par exemple : cordova run ios --target="ipad"
#
# Name of the device as visible in Safari->Develop menu
set deviceName to "iOS Simulator"
# Number of seconds to wait for the simulator window to show up
set maxWait to 30
# ---------------------------------------
# You shouldn't modify anything below here
set hasClicked to false
set x to 0
tell application "Safari"
activate
repeat until hasClicked or x > (maxWait * 10)
try
tell application "System Events"
click menu item "index.html" of menu deviceName of menu item deviceName of menu "Développement" of menu bar item "Développement" of menu bar 1 of application process "Safari"
end tell
set hasClicked to true
on error foo
delay 0.1
set x to x + 1
end try
end repeat
if hasClicked = false then
display dialog "Unable to connect to iOS simulator - make sure that it's working" buttons {"OK"} default button 1
else
try
tell application "System Events"
click button 1 of window "Top Sites" of application process "Safari"
end tell
end try
return
end if
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment