Skip to content

Instantly share code, notes, and snippets.

@ChristoferK
Created November 15, 2019 21:20
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 ChristoferK/2faa7a299527c9e48c09307cf3c0b892 to your computer and use it in GitHub Desktop.
Save ChristoferK/2faa7a299527c9e48c09307cf3c0b892 to your computer and use it in GitHub Desktop.
[(Re)Store Chrome Tabs] Stores a list of open Chrome URLs, writing out to file and preserving arrangement; restores from file. #AppleScript #Chrome #Chromium #tabs #URLs #save #restore
property home : system attribute "HOME"
property file : home & "/.chrometabs"
on storeURLs()
close access (open for access my file)
tell application id "com.google.chrome" to ¬
set URLs to every window's tabs's URL
write the URLs to my file
return the URLs
end storeURLs
to restoreURLs()
close access (open for access my file)
if (get eof of my file) = 0 then return false
set URLs to read my file as list
tell application id "com.google.chrome"
repeat with URLgroup in the reverse of the URLs
tell (make new window)
set [active tab's URL] to the URLgroup
repeat with |URL| in the rest of the URLgroup
make new tab with properties {URL:|URL|}
end repeat
end tell
end repeat
activate
end tell
return the URLs
end restoreURLs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment