我们用Apple script把Chrome的书签全部导入至Safari(为什么不把Safari的书签导入Chrome?因为Safari可以对导入的书签自动降重~)
把以下Apple script保存进sync-from-chrome-to-safari.scpt文件,然后在终端中运行这段指令即可。(运行前需要先在Safari上打开起始页,否则可能会报错)
osascript /到这个文件的路径/sync-from-chrome-to-safari.scpt
-- close google chrome to perform importing
do shell script "killall \"Google Chrome\" || echo \"Google Chrome is not running.\""
tell application "Safari" to activate
tell application "System Events" to set visible of application process "Safari" to false
log "Syncing"
tell application "System Events"
tell application process "Safari"
tell menu "导入自" of menu item "导入自" of menu "文件" of menu bar item "文件" of menu bar 1
click menu item "Google Chrome.app…"
end tell
tell sheet 1 of window "起始页"
click button "导入"
end tell
delay 2
tell sheet 1 of window "起始页"
click button "好"
end tell
end tell
end tell
log "All done"
-- 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"
如果你安装有Alfred就更好办了:安装Vision设计的这个扩展:
链接: https://pan.baidu.com/s/1XPPIiUQotpmZlonlVx7Dpg 密码: 3g9l
在Safari中新建起始页,打开Alfred中输入sync即可使用。
参考
- 参考自本文的代码(原代码无法在中文系统下使用) https://www.v2ex.com/amp/t/675929