使用AppleScript可以在新标签页中打开具有特定名称的URLs。以下是一个示例代码:
tell application "Safari"
-- 创建新的标签页
tell front window
set newTab to make new tab with properties {URL:"about:blank"}
end tell
-- 设置要打开的URL名称
set targetURLName to "Google"
-- 获取所有已保存的书签
set bookmarksList to bookmarks of front window
-- 遍历书签列表并找到匹配的URL
repeat with bookmark in bookmarksList
if name of bookmark is targetURLName then
-- 在新标签页中打开URL
tell newTab
set current tab to newTab
set URL of newTab to URL of bookmark
end tell
-- 退出循环
exit repeat
end if
end repeat
end tell
这个代码的作用是在Safari浏览器中创建一个新的标签页,并在其中打开具有特定名称的URL。在示例代码中,我们以"Google"为例进行演示。您可以根据自己的需要修改targetURLName
变量来匹配您想要打开的URL名称。