Created
December 18, 2019 13:00
-
-
Save rsnemmen/e4967a8af8553005dc51a7874dc1bfdc to your computer and use it in GitHub Desktop.
Apple script to save urls of all currently open safari tabs to markdown file
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
-- Set up the initial document | |
set output to (("List of open tabs in Safari" & linefeed as string) & "=======================" & linefeed as string) & linefeed as string | |
tell application "Safari" | |
-- Count the number of Windows | |
set numWindows to number of windows | |
repeat with w from 1 to numWindows | |
--Count the number of Tabs | |
set numTabs to number of tabs in window w | |
repeat with t from 1 to numTabs | |
-- Set the Tab Name and URL values | |
set tabName to name of tab t of window w | |
set tabURL to URL of tab t of window w | |
-- Create the Tab link and write the code | |
set output to (output & "[" & tabName & "](" & tabURL & ")" & linefeed as string) & linefeed as string | |
end repeat | |
end repeat | |
end tell | |
-- Write the entire document to TextEdit | |
tell application "TextEdit" | |
activate | |
make new document | |
set the text of the front document to output | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As an alternative for saving groups of tabs for future use, I highly recommend the safari add-on Tab Space.