要以编程方式更改Safari设置,您可以使用macOS的AppleScript
tell application "Safari"
activate
tell front window
set current tab to (make new tab with properties {URL:"about:blank"})
set URL of current tab to "https://www.example.com"
end tell
-- 打开设置对话框
tell application "System Events"
tell process "Safari"
click menu item "偏好设置" of menu "Safari" of menu bar item "Safari" of menu bar 1
end tell
end tell
delay 1
-- 更改代理设置
tell application "System Events"
tell process "Safari"
tell window "偏好设置"
select tab "高级"
tell group 1
tell checkbox "在菜单栏中显示‘开发’菜单"
set checked to true
end tell
end tell
end tell
end tell
end tell
-- 关闭设置对话框
tell application "System Events"
tell process "Safari"
click button "好" of window "偏好设置"
end tell
end tell
end tell
这个脚本会打开一个新的Safari标签,导航到指定的URL,然后打开Safari的偏好设置。接下来,它会更改一些设置,例如启用“开发”菜单。最后,它会关闭偏好设置对话框。
领取专属 10元无门槛券
手把手带您无忧上云