List of links/tabs from safari

I am a chronic when it comes to new tabs. All of a sudden I have 93 open tabs and it’s complicated to get an overview.

I have a shortcut that appends title and url to a text file in dropbox and that “works”

But I have to go to the safari tab, run the shortcut, go back to safari, close the tab and run the shortcut on the next tab.

Is there an way to record all of the titles and urls from all of the open tabs?
I can close all of the tabs in one command from safari but if the automation can do that as well it would be great. I keep a few constant tabs at the top but they are easy to open again.

There’s a couple ways to do this. You can use AppleScript

AppleScript
(*
babylondreams.de
Export All Safari Tabs to the clipboard
VERSION 1.0
15. April 2016

======================================
// USER SWITCHES (YOU CAN CHANGE THESE!)
======================================
*)

-- NAME OF REPORT TITLE
property report_Title : "URL List from Safari Tabs"

(* 
======================================
// MAIN PROGRAM 
======================================
*)

-- PREPARE THE LIST
set url_list to {}
set the date_stamp to ((the current date) as string)
set NoteTitle to "# " & report_Title & " | " & the date_stamp & "

"

-- GET TABS FROM SAFARI
tell application "Safari"
	activate
	set safariWindow to window 1
	repeat with w in safariWindow
		try
			repeat with t in (tabs of w)
				set TabTitle to (name of t)
				set TabURL to (URL of t)
				set TabInfo to ("* [" & TabTitle & "](" & TabURL & ")

")
				copy TabInfo to the end of url_list
			end repeat
		end try
	end repeat
end tell

-- CONVERT URL_LIST TO TEXT
set old_delim to AppleScript's text item delimiters
set AppleScript's text item delimiters to return
set url_list to (NoteTitle & return & return & url_list) as text
set AppleScript's text item delimiters to old_delim

--WRITE THE FILE TO CLIPBOARD
-- tell application "Finder" to set the clipboard to the url_list as text
return url_list

or you could use an extension like Tab Spaces

You can’t use AppleScript. It is only supported on macOS, not iOS.

You can bookmark all open tabs on iOS Safari. You can share content for the current tab in iOS e.g. to Shortcuts as noted in the first post. But, there’s currently no way to automatically iterate over the tabs to grab content like the title and URL on iOS.

1 Like

Ok.
It’s not possible to access it via JavaScript either?

I did put my post in the iOS category but I didn’t mention it in the text. Sorry this problem is for iPhone/iPad only. I’m all set on my computer

It is sandboxed. You could access the current tab with a JavaScript bookmark let, but not all tabs. That’s generally true with any browser unless you switched yo say JXA, which again is not available on iOS.

1 Like

Just thinking out loud here, but would it be possible to have the Mac bookmark all the tabs via the shared “iCloud Tabs” feature of Safari?

Have AppleScript pull from the tabs open on Safari on the iOS device via iCloud Tabs, then perhaps manually close all tabs on the iOS device? You said there was a command to close all iOS Safari tabs, correct?