banner
codeacg

codeacg

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

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 官方网站弄。

加载中...
此文章数据所有权由区块链加密技术和智能合约保障仅归创作者所有。