Created
January 5, 2016 09:10
-
-
Save scriptingosx/47a76087812b306e78d8 to your computer and use it in GitHub Desktop.
Safari - Build Text Link List from Tabs
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
global linkText | |
on run | |
set linkText to "" | |
tell application "Safari" | |
activate | |
set w to window 1 | |
set n to 0 | |
try -- this will fail for the downloads window | |
set n to count tabs of w | |
end try | |
if n > 1 then | |
repeat with t in every tab of w | |
my appendLineWithDoc(t) | |
end repeat | |
else if n = 1 then | |
my appendLineWithDoc(document of w) | |
end if | |
end tell | |
set the clipboard to linkText | |
return linkText | |
end run | |
on appendLineWithDoc(theDoc) | |
tell application "Safari" | |
tell theDoc | |
try | |
set linkText to linkText & name | |
set linkText to linkText & return & "<" & URL & ">" & return & return | |
end try | |
end tell | |
end tell | |
end appendLineWithDoc | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A bit more compact:
Or, for markdown links: