Last active
January 25, 2025 03:24
-
-
Save Aneureka/41e4ee6ecb797bc97d20a44927d3dcbe to your computer and use it in GitHub Desktop.
An apple script to sync history, bookmarks & passwords from google chrome to safari.
This file contains hidden or 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
# Add a scheduled sync task at 4:00 am | |
# Some privileges should be granted to `cron` *manually*, so you may test `* * * * *` (run every second) first to grant the needed privileges in advance | |
0 4 * * * osascript /path/to/your/sync-from-chrome-to-safari.scpt |
This file contains hidden or 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
-- close google chrome to perform importing | |
do shell script "killall \"Google Chrome\" || echo \"Google Chrome is not running.\"" | |
do shell script "killall Safari || echo \"Safari is not running.\"" | |
tell application "Safari" to activate | |
tell application "System Events" to set visible of application process "Safari" to false | |
-- import history, bookmarks, passwords from google chrome to safari | |
tell application "System Events" to tell process "Safari" | |
delay 0.5 | |
log "Syncing..." | |
tell menu item "Import From" of menu "File" of menu bar item "File" of menu bar 1 | |
tell menu "Import From" | |
click menu item "Google Chrome.app…" | |
end tell | |
end tell | |
keystroke return | |
log "Complete sync" | |
end tell | |
-- close safari | |
do shell script "killall Safari || echo \"Safari is not running.\"" | |
-- restore chrome closed tabs and minimize window in background | |
delay 0.5 | |
log "Opening chrome in background" | |
do shell script "open -a \"Google Chrome\" --args --restore-last-session --no-startup-window" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Did someone get this error too?