Copy Safari Front Window URLs

Hey Folks,

Since Peter’s macro has to drive the UI to make each tab in turn the active tab, it will be a bit slow on windows with many tabs.

This task can be accomplished in a millisecond using AppleScript.

I’m putting the result on the clipboard, but you can just as easily drop it into a Keyboard Maestro variable, etc.

-Chris

------------------------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2017/11/15 00:00
# dMod: 2017/11/15 00:03
# Appl: Safari
# Task: Put URLs of all tabs of the front window on the clipboard.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @Safari, @Put, @URLs, @All, @Tabs, @Front, @Window, @Clipboard
------------------------------------------------------------------------------

tell application "Safari"
   tell front window
      if its document exists then
         set AppleScript's text item delimiters to linefeed
         set urlList to URL of its tabs
         
         set the clipboard to (urlList as text)
         
      end if
   end tell
end tell

------------------------------------------------------------------------------
8 Likes