Skip to content

Instantly share code, notes, and snippets.

@siathalysedI
Forked from vorg/tabdump.scpt
Created May 2, 2025 05:44
Show Gist options
  • Save siathalysedI/70694dcda4087a08c4524fa6ba385927 to your computer and use it in GitHub Desktop.
Save siathalysedI/70694dcda4087a08c4524fa6ba385927 to your computer and use it in GitHub Desktop.

Revisions

  1. @vorg vorg revised this gist Jun 5, 2020. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions tabdump.scpt
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    (*Adapted from https://stackoverflow.com/a/39820517*)
    set r to "" -- an empty variable for appending a string
    tell application "Safari"
    repeat with w in windows -- loop for each window, w is a variable which contain the window object
  2. @vorg vorg created this gist Jun 5, 2020.
    18 changes: 18 additions & 0 deletions tabdump.scpt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    set r to "" -- an empty variable for appending a string
    tell application "Safari"
    repeat with w in windows -- loop for each window, w is a variable which contain the window object
    if exists current tab of w then -- is a valid browser window
    repeat with t in tabs of w -- loop for each tab of this window, , t is a variable which contain the tab object
    -- get the title (name) of this tab and get the url of this tab
    tell t to set r to r & "- [ ] [" & name & "](" & URL & ")" & linefeed -- append a line to the variable (r)
    (*
    'linefeed' mean a line break
    'tell t' mean a tab of w (window)
    '&' is for concatenate strings, same as the + operator in Swift
    *)
    end repeat
    end if
    end repeat
    end tell
    set the clipboard to r
    return r -- return the string (each line contains a title and an URL)