Skip to content

Instantly share code, notes, and snippets.

@amanuel
Last active October 19, 2024 19:57
Show Gist options
  • Save amanuel/81e70673b057687e904a248218c50ce2 to your computer and use it in GitHub Desktop.
Save amanuel/81e70673b057687e904a248218c50ce2 to your computer and use it in GitHub Desktop.

Revisions

  1. amanuel revised this gist Jan 26, 2020. No changes.
  2. amanuel created this gist Jan 26, 2020.
    36 changes: 36 additions & 0 deletions tabssafari2firefox.scpt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    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