aiskillstore/marketplace / skills/7sageer/mac-automation
mac-automation
VerifiedThis skill should be used when the user requests Mac automation via AppleScript, including: Mail operations, Reminders/Calendar management, Safari control, Finder operations, system controls (volume, brightness, notifications, app launching), third-party apps (development tools, task management, media players), or mentions "AppleScript" or "automate Mac".
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 7.5 KB |
| examples/daily-briefing.applescript | other | 1.8 KB |
| examples/quick-note.applescript | other | 940 B |
| references/calendar-applescript.md | markdown | 7.8 KB |
| references/finder-applescript.md | markdown | 8.0 KB |
| references/mail-applescript.md | markdown | 5.4 KB |
| references/reminders-applescript.md | markdown | 6.9 KB |
| references/safari-applescript.md | markdown | 6.5 KB |
| references/system-applescript.md | markdown | 8.2 KB |
references/safari-applescript.md
View on GitHub# Safari AppleScript Reference
## Open URLs
### Open URL in New Tab
```bash
osascript <<'EOF'
tell application "Safari"
activate
tell window 1
set current tab to (make new tab with properties {URL:"https://www.google.com"})
end tell
end tell
EOF
```
### Open URL in New Window
```bash
osascript <<'EOF'
tell application "Safari"
activate
make new document with properties {URL:"https://www.apple.com"}
end tell
EOF
```
### Open URL in Current Tab
```bash
osascript <<'EOF'
tell application "Safari"
activate
set URL of current tab of window 1 to "https://www.github.com"
end tell
EOF
```
### Open Multiple URLs
```bash
osascript <<'EOF'
tell application "Safari"
activate
set urlList to {"https://google.com", "https://github.com", "https://apple.com"}
repeat with theURL in urlList
tell window 1
make new tab with properties {URL:theURL}
end tell
end repeat
end tell
EOF
```
## Get Page Information
### Get Current URL
```bash
osascript -e 'tell application "Safari" to return URL of current tab of window 1'
```
### Get Page Title
```bash
osascript -e 'tell application "Safari" to return name of current tab of window 1'
```
### Get Page Source (HTML)
```bash
osascript -e 'tell application "Safari" to return source of current tab of window 1'
```
### Get Selected Text
```bash
osascript <<'EOF'
tell application "Safari"
do JavaScript "window.getSelection().toString()" in current tab of window 1
end tell
EOF
```
### Get All Tab URLs
```bash
osascript <<'EOF'
tell application "Safari"
set output to ""
repeat with t in tabs of window 1
set output to output & (URL of t) & linefeed
end repeat
return output
end tell
EOF
```
### Get All Tab Titles
```bash
osascript <<'EOF'
tell application "Safari"
set output to ""
repeat with t in tabs of window 1
set output to output & (name of t) & linefeed
end repeat
return output
end tell
EOF
```
## Tab Management
### Close Current Tab
```bash
osascript -e 'tell application "Safari" to close current tab of window 1'
```
### Close All Tabs Except Current
```bash
osascript <<'EOF'
tell application "Safari"
tell window 1
set currentIndex to index of current tab
repeat with i from (count of tabs) to 1 by -1
if i ≠ currentIndex then
close tab i
end if
end repeat
end tell
end tell
EOF
```
### Switch to Tab by Index
```bash
osascript -e 'tell application "Safari" to set current tab of window 1 to tab 2 of window 1'
```
### Get Tab Count
```bash
osascript -e 'tell application "Safari" to return count of tabs of window 1'
```
### Create New Tab
```bash
osascript <<'EOF'
tell application "Safari"
activate
tell window 1
make new tab
end tell
end tell
EOF
```
## JavaScript Execution
### Execute JavaScript
```bash
osascript <<'EOF'
tell application "Safari"
do JavaScript "document.title" in current tab of window 1
end tell
EOF
```
### Click Element by ID
```bash
osascript <<'EOF'
tell application "Safari"
do JavaScript "document.getElementById('submit-button').click()" in current tab of window 1
end tell
EOF
```
### Fill Form Field
```bash
osascript <<'EOF'
tell application "Safari"
do JavaScript "document.getElementById('username').value = 'myuser'" in current tab of window 1
end tell
EOF
```
### Scroll Page
```bash
osascript <<'EOF'
tell application "Safari"
do JavaScript "window.scrollTo(0, document.body.scrollHeight)" in current tab of window 1
end tell
EOF
```
### Get Element Text
```bash
osascript <<'EOF'
tell application "Safari"
do JavaScript "document.querySelector('h1').innerText" in current tab of window 1
end tell
EOF
```
### Get All Links
```bash
osascript <<'EOF'
tell application "Safari"
do JavaScript "Array.from(document.querySelectorAll('a')).map(a => a.href).join('\\n')" in current tab of window 1
end tell
EOF
```
## Window Management
### Get Window Count
```bash
osascript -e 'tell application "Safari" to return count of windows'
```
### Minimize Window
```bash
osascript -e 'tell application "Safari" to set miniaturized of window 1 to true'
```
### Maximize Window
```bash
osascript <<'EOF'
tell application "Safari"
activate
set bounds of window 1 to {0, 0, 1920, 1080}
end tell
EOF
```
### Close Window
```bash
osascript -e 'tell application "Safari" to close window 1'
```
### Create New Window
```bash
osascript <<'EOF'
tell application "Safari"
activate
make new document
end tell
EOF
```
## Navigation
### Go Back
```bash
osascript -e 'tell application "Safari" to do JavaScript "history.back()" in current tab of window 1'
```
### Go Forward
```bash
osascript -e 'tell application "Safari" to do JavaScript "history.forward()" in current tab of window 1'
```
### Reload Page
```bash
osascript -e 'tell application "Safari" to do JavaScript "location.reload()" in current tab of window 1'
```
### Stop Loading
```bash
osascript -e 'tell application "Safari" to do JavaScript "window.stop()" in current tab of window 1'
```
## Reading List
### Add Current Page to Reading List
```bash
osascript <<'EOF'
tell application "Safari"
add reading list item (URL of current tab of window 1)
end tell
EOF
```
### Add URL to Reading List
```bash
osascript -e 'tell application "Safari" to add reading list item "https://example.com"'
```
## Bookmarks
### Get Bookmark Folders
```bash
osascript <<'EOF'
tell application "Safari"
set output to ""
repeat with f in bookmark folders
set output to output & (name of f) & linefeed
end repeat
return output
end tell
EOF
```
## Search
### Google Search
```bash
osascript <<'EOF'
tell application "Safari"
activate
set searchQuery to "AppleScript tutorial"
set searchURL to "https://www.google.com/search?q=" & (do shell script "python3 -c \"import urllib.parse; print(urllib.parse.quote('" & searchQuery & "'))\"")
tell window 1
set current tab to (make new tab with properties {URL:searchURL})
end tell
end tell
EOF
```
## Tips
1. **Activation**: Use `activate` to bring Safari to front
2. **Window 1**: `window 1` refers to the frontmost window
3. **JavaScript Permissions**: May require "Allow JavaScript from Apple Events" in Safari Developer menu
4. **Tab Indexing**: Tabs are 1-indexed
5. **URL Encoding**: Encode special characters for URLs
6. **Private Windows**: Private windows have limited AppleScript access
7. **Synchronous Loading**: Scripts don't wait for pages to load; add delays if needed
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |