Last active
January 6, 2024 18:12
-
-
Save amanuel/81e70673b057687e904a248218c50ce2 to your computer and use it in GitHub Desktop.
Move Safari Tabs to Firefox (preserves windows)
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
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
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.