Note

Raycast 实现 Safari 和 Chrome 同步书签

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'
1684558696.png
2.创建脚本
1684558816.png
3.把上述代码copy到脚本中即可
4.使用脚本
1684558993.png

5.友情提示

Raycast脚本可以单独放到一个文件夹下,插件设置地方记得添加路径

1684558999.png

apple的图标可以去apple官方网站弄。

0
0
...
...
...
Avatar