Created
November 15, 2019 21:20
-
-
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
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
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