does it possible to open with script link on specific safari window with tab group?
In general yes, but how would you get the link or the specific window?
mostly i have link in telegram and want to open it in safari window that pinned to workspace
A couple of issues:
I don’t use telegram so I can’t help with that. The example below will use the clipboard.
Applescript doesn’t know what a pinned window is so you have to identify the window some other way. I’ll pick an arbitrary text string and select the window that has at least one tab whose URL contains that string. Alternatively, you could use Safari’s front window (or any index position).
-- target window contains a tab with a matching URL
set targetWindowSite to "pro-football-reference.com"
-- desired link to open in above window
set lk to "https://www.pro-football-reference.com/teams/mia/2024.htm"
set the clipboard to lk
tell application "Safari"
set winList to windows -- lists windows
set urls to {}
repeat with w in winList -- cycle through windows
set tabList to tabs of w -- lists tabs in window
repeat with t in tabList -- cycles through tabs
-- does tabs' url contain target site
set tr to URL of t contains targetWindowSite
if tr then
set tarWin to w -- get id of matching window
exit repeat
end if
end repeat
end repeat
-- make and activate new tab in matching window
make new tab at beginning of tarWin with properties {URL:(the clipboard)}
set current tab of tarWin to tab 1 of tarWin
end tell