Skip to content

Commit

Permalink
Merge pull request #960 from ystknsh/master
Browse files Browse the repository at this point in the history
add sh file, commands/browsing/open-multiple-websites-on-safari.template.sh
  • Loading branch information
grzegorzkrukowski authored Sep 3, 2024
2 parents b38d4a7 + f379cbf commit f3f1961
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions commands/browsing/open-multiple-websites-on-safari.template.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash

# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Open Multiple Websites on Safari
# @raycast.mode silent

# Optional parameters:
# @raycast.icon 📚
# @raycast.packageName Browsing

# Documentation:
# @raycast.description Open multiple websites on Safari using list of URLs
# @raycast.author Yasutaka Nishii
# @raycast.authorURL https://github.com/ystknsh

# Set list of URLs
urls=(
"https://example.com"
"https://example.org"
"https://example.net"
"https://example.jp"
"https://example.io"
"https://example.ai"
)

# Make AppleScript commands
applescript_command="tell application \"Safari\"
make new document with properties {URL:\"${urls[0]}\"}
tell window 1"

for ((i=1; i<${#urls[@]}; i++)); do
applescript_command+="
make new tab with properties {URL:\"${urls[$i]}\"}"
done

applescript_command+="
end tell
end tell"

# Execute AppleScript
osascript -e "$applescript_command"

# Set Safari window to front(Optional)
osascript <<EOD
tell application "System Events"
tell process "Safari"
set frontmost to true
tell window 1
set value of attribute "AXMain" to true
set value of attribute "AXFocused" to true
end tell
end tell
end tell
EOD

0 comments on commit f3f1961

Please sign in to comment.