Created
July 23, 2014 16:27
-
-
Save wwwjfy/a79e262c6187dc281863 to your computer and use it in GitHub Desktop.
Save Safari and Google Chrome tabs in a single webpage
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 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