Raycast 實現 Safari 和 Chrome 同步書籤#
背景#
眾所周知,Safari 與 Chrome 瀏覽器之間的同步非常困難,缺乏適合的工具。如果能自動將 Chrome 書籤匯入到 Safari 中,可以在一定程度上解決這個問題。下面的程式碼經過 Google 和 ChatGPT 的引導,現在已經可以使用。
經過 Google 和 ChatGPT 的引導,現在這段程式碼已經可以使用。
#!/usr/bin/osascript
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title auto_bookmarks
# @raycast.mode silent
# Optional parameters:
# @raycast.icon ./images/apple.ico
# Documentation:
# @raycast.description 同步chrome書籤到Safari瀏覽器
# @raycast.author codeacg
tell application "Safari"
quit
tell application "Google Chrome"
quit
end tell
end tell
delay 2
tell application "Safari" to activate
tell application "System Events" to tell process "Safari"
click menu bar item "文件" of menu bar 1
click menu item "導入自" of menu "文件" of menu bar item "文件" of menu bar 1
click menu item "Google Chrome.app…" of menu "導入自" of menu item "導入自" of menu "文件" of menu bar item "文件" of menu bar 1
delay 1
key code 76
tell application "System Events" to tell process "Safari"
repeat until static text "完成從Google Chrome導入" of sheet 1 of window "起始頁" exists
end repeat
key code 76
delay 3
end tell
end tell
tell application "Safari"
quit
end tell
log "Completed! 🥳"
使用#
1. 打開 'Create Script Command'
2. 創建腳本
3. 把上述程式碼 copy 到腳本中即可
4. 使用腳本
5. 友情提示
Raycast 腳本可以單獨放到一個文件夾下,插件設置地方記得添加路徑
apple 的圖標可以去 apple 官方網站弄。