Raycast Implementation of Syncing Bookmarks between Safari and Chrome#
Background#
As we all know, syncing between Safari and Chrome browsers is very difficult and lacks suitable tools. If we can automatically import Chrome bookmarks into Safari, it can partially solve this problem. The following code, guided by Google and ChatGPT, is now available for use.
After being guided by Google and ChatGPT, this code is now available for use.
#!/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 Sync Chrome bookmarks to Safari browser
# @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 "File" of menu bar 1
click menu item "Import From" of menu "File" of menu bar item "File" of menu bar 1
click 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
delay 1
key code 76
tell application "System Events" to tell process "Safari"
repeat until static text "Finished importing from Google Chrome" of sheet 1 of window "Start Page" exists
end repeat
key code 76
delay 3
end tell
end tell
tell application "Safari"
quit
end tell
log "Completed! 🥳"
Usage#
-
Open 'Create Script Command'
-
Create a script
-
Copy the above code into the script
-
Use the script
-
Friendly reminder
Raycast scripts can be placed in a separate folder. Remember to add the path in the plugin settings.
You can get the Apple icon from the official Apple website.