banner
codeacg

codeacg

额. 每天的事情 看番 + 写代码(学
github
telegram

Raycast implements bookmark synchronization between Safari and Chrome.

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#

  1. Open 'Create Script Command'
    1684558696.png

  2. Create a script
    1684558816.png

  3. Copy the above code into the script

  4. Use the script
    1684558993.png

  5. Friendly reminder

Raycast scripts can be placed in a separate folder. Remember to add the path in the plugin settings.

1684558999.png

You can get the Apple icon from the official Apple website.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.