Shortcut using new Safari Tab Groups?

I write stories for a podcast where I need to cite my sources at the bottom. I was hoping with the new Safari tab groups on Mac, I might be able to automate this process by pulling the data I need (Title, website slug, date, full url of article) from each tab and dumping it into my current Draft, but it doesn’t look like Monterey Shortcuts offers a tab group option. Does anyone know of a workaround?

This is the current shortcut I was using on iOS/iPadOS:

1 Like

I don’t think you can do this with pure Shortcuts, but you can run an AppleScript:

tell application "Safari"
	set docText to ""
	set tabcount to number of tabs in the front window
	--Repeat for Every Tab in Current Window
	repeat with y from 1 to tabcount
		--Get Tab Name & URL
		set tabName to name of tab y of the front window
		set tabURL to URL of tab y of the front window
		set docText to docText & "- [" & tabName & "](" & tabURL & ")" & linefeed as string
	end repeat
	set the clipboard to docText
end tell

This gets the links from the front window in Markdown in a list, I suspect you could modify it further!


Pssst… You should probably change "Safari Technology Preview" to just "Safari".


Maybe :eyes:
Though fortunately, the script works in both!

1 Like

I thought the same.

If you have both installed - Tech Preview and Regular - how does tell disambiguate?

(Or can’t you have both installed? I have Firefox Regular and Nightly installed at the same time.)

You can have both! You just replace the tell application "Safari" with tell application "Safari Technology Preview" :slight_smile:

1 Like

I would never have guessed that! I can see how it makes sense, but it’s still surprising. Is that the only case you know of where one app name can be used for two apps?


This is wonderful - thank you, @RosemaryOrchard!! I’ve already started modifying it to fit the bibliography format I use. I did have one question though: I was looking online for a while for a library/glossary of Safari tab data points that AppleScript recognizes (like tabName) and couldn’t find anything. Can you (or anyone on this thread) please recommend any helpful online resources for learning AppleScript or finding out if those data points exist? I’d like to be able to extract the publication date of an article and the “” piece of the URL, but I don’t know if that’s possible in AppleScript and the websites I was looking at don’t seem to make that information easy to find. Thank you again!

1 Like

In Script Editor or Script Debugger you can open the Dictionary for Safari which will give you all the various parts you can grab. What might be easiest is to return a list of the URLs only to Shortcuts, and then use Shortcuts to get the article data from the URL.

1 Like