Last active
March 20, 2023 00:42
-
-
Save imWildCat/4887c0c9964ee77384b52e90b1bb820b to your computer and use it in GitHub Desktop.
Open Safari and Debug Simulator (generated by GPT-4, refined by @imWildCat)
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
#!/usr/bin/osascript | |
# Required parameters: | |
# @raycast.schemaVersion 1 | |
# @raycast.title Safari Dev or Simulator Debug (web) | |
# @raycast.mode compact | |
# Optional parameters: | |
# @raycast.icon 🤖 | |
log "Hello World!" | |
tell application "Safari" | |
activate | |
end tell | |
tell application "System Events" | |
tell process "Safari" | |
click menu bar item "Develop" of menu bar 1 | |
delay 0.1 | |
set developMenu to menu "Develop" of menu bar item "Develop" of menu bar 1 | |
set simulatorMenuItems to (menu items of developMenu whose name starts with "Simulator") | |
log developMenu | |
log simulatorMenuItems | |
if (count simulatorMenuItems) > 0 then | |
set simulatorMenu to item 1 of simulatorMenuItems | |
click simulatorMenu | |
delay 0.1 | |
set localhostMenuItems to (menu items of menu 1 of simulatorMenu whose name starts with "localhost" or name starts with "index") | |
if (count localhostMenuItems) > 0 then | |
click item 1 of localhostMenuItems | |
else | |
display alert "localhost or index menu item not found" | |
end if | |
else | |
display alert "Simulator menu item not found" | |
end if | |
end tell | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you used
Script Editor
for this AppleScript, please re-open it and save it as UTF-8 encoding with a different code editor.Otherwise, Raycast is not able to run it. Reference: raycast/script-commands#55 (comment)