Skip to content

Instantly share code, notes, and snippets.

@amanuel
Last active January 6, 2024 18:12
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amanuel/81e70673b057687e904a248218c50ce2 to your computer and use it in GitHub Desktop.
Save amanuel/81e70673b057687e904a248218c50ce2 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
@amanuel
Copy link
Author

amanuel commented Jan 26, 2020

Props to the folks here https://superuser.com/questions/818724/how-to-move-all-open-tabs-from-safari-to-firefox/1210777#1210777

My changes allow new windows to be created to match what's in safari. It isn't perfect...but worked for me. (eg. an empty tab is left in every window)

I will not have time to update this further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment