Skip to content

Instantly share code, notes, and snippets.

@wwwjfy
Created July 23, 2014 16:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wwwjfy/a79e262c6187dc281863 to your computer and use it in GitHub Desktop.
Save wwwjfy/a79e262c6187dc281863 to your computer and use it in GitHub Desktop.
Save Safari and Google Chrome tabs in a single webpage
set docText to "<html><body>"
tell application "Safari"
--Variables
set windowCount to number of windows
--Repeat for Every Window
repeat with x from 1 to windowCount - 1
set tabcount to number of tabs in window x
set docText to docText & "<h2>Safari " & x & "</h2><ul>"
--Repeat for Every Tab in Current Window
repeat with y from 1 to tabcount
--Get Tab Name & URL
set tabName to name of tab y of window x
set tabURL to URL of tab y of window x
set docText to docText & "<li><a href=" & "\"" & tabURL & "\">" & tabName & "</a></li>" & linefeed as string
end repeat
set docText to docText & "</ul>"
end repeat
end tell
tell application "Google Chrome"
--Variables
set windowCount to number of windows
--Repeat for Every Window
repeat with x from 1 to windowCount
set tabcount to number of tabs in window x
set docText to docText & "<h2>Chrome " & x & "</h2><ul>"
--Repeat for Every Tab in Current Window
repeat with y from 1 to tabcount
--Get Tab Name & URL
set tabName to title of tab y of window x
set tabURL to URL of tab y of window x
set docText to docText & "<li><a href=" & "\"" & tabURL & "\">" & tabName & "</a></li>" & linefeed as string
end repeat
set docText to docText & "</ul>"
end repeat
end tell
set docText to docText & "</body></html>"
set the clipboard to docText
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment