Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lalitaalaalitah/7f97b77bbc74d4317fcbd4de231e43e2 to your computer and use it in GitHub Desktop.
Save lalitaalaalitah/7f97b77bbc74d4317fcbd4de231e43e2 to your computer and use it in GitHub Desktop.
Move Safari Tabs to Firefox (preserves windows)
tell application "Firefox"
activate
set safariWindows to getSafariWindows() of me
repeat with w in safariWindows
set newTabURLs to takeSafariTabURLs(w) of me
repeat with tabURL in newTabURLs
open location tabURL
delay 0.5
end repeat
tell application "System Events" to keystroke "n" using command down
delay 1
end repeat
end tell
on getSafariWindows()
set safariWindows to {}
tell application "Safari"
repeat with w in windows
if name of w is not "" then --in case of zombie windows
set the end of safariWindows to w
end if
end repeat
return safariWindows
end tell
end getSafariWindows
on takeSafariTabURLs(w)
set tabURLs to {}
tell application "Safari"
repeat with t in tabs of w
set tabURL to URL of t
set the end of tabURLs to tabURL
end repeat
return tabURLs
end tell
end takeSafariTabURLs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment