Last active
November 6, 2024 23:18
-
-
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 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 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" |
怎么样从edge同步到Safari啊?现在edge用户群也挺大的。直接把脚本里面的Google Chrome改成Microsoft Edge并不行
I'm sure it's safe to assume you both (@gkb21 & @frantortosa) got this figured by now but, but if not or for anyone else who may be interested, here is an example of setting up automated tasks/jobs in macOS & Linux. I hope it helps!
Oh, I had actually given up on this, so I am grateful you provided that link. I will definitely try it out now.
Been looking for this for so long. I think the script can be executed by Automator instead of chron. Can you add the option to import specifically? Like, I want to import only Bookmarks and History.
Did someone get this error too?
execution error: System Events got an error: Can’t get menu item "Google Chrome.app…" of menu "Import From" of menu item "Import From" of menu "File" of menu bar item "File" of menu bar 1 of process "Safari". (-1728)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yeah same, Would someone be able to explain how to get this running ?