The following AppleScript was originally written for Google Chrome users, but I significantly edited and added to the AppleScript, so it works for Brave Browser (MacOS) and does a bit more than the original script.
(I am NOT the original author; see notes at end of text, below.)
If a MacOS user wants to try the AppleScript, they need to copy the text contents (below) and paste that into a new Script Editor.app window on their Mac, and then save that new AppleScript, as:
Export_Brave_Tabs_to_Text_File.scpt
The AppleScript creates an HTML text file (“Export_Brave_Tabs_to_Text_File.html”), in which the Tabs are recorded, and places that text file on the MacOS Desktop.
Next, Brave Browser (MacOS) creates a new window (named “New Tab”) and opens that text file, displaying the contents of that text file in that new window, so the user promptly sees the Title and Link combinations listing of Tabs.
Thus, the user has a backup of their Tabs and can immediately see the results in the Brave Browser (MacOS) window (“New Tab”), in addition to finding and safely storing the “Export_Brave_Tabs_to_Text_File.html” file.
The AppleScript - in text form:
--
-- 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
set NoteTitle to "<p>" & NoteTitle & "</p>"
--
-- GET TABS FROM BRAVE
tell application "Brave Browser"
activate
set braveWindow to window 1
repeat with w in braveWindow
try
repeat with t in (tabs of w)
set TabTitle to (title of t)
set TabURL to (URL of t)
set TabTitle to ("<p><a href=\"" & TabURL & "\">" & TabTitle & "</a>") as string
set TabURL to ("<br><a href=\"" & TabURL & "\">" & TabURL & "</a></p>") as string
set TabBLANK to ("<p><br></p>")
set TabInfo to ("" & TabTitle & return & TabURL & return & return)
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 & return & url_list) as text
set AppleScript's text item delimiters to old_delim
--
set nuName0 to "Export_Brave_Tabs_to_Text_File0.txt"
set nuName to "Export_Brave_Tabs_to_Text_File.html"
--
set pth to (path to desktop folder)
--
set nuNamePth_POSIX0 to (POSIX path of ((pth as string) & nuName0))
set nuNamePth_POSIX to (POSIX path of ((pth as string) & nuName))
-- return nuNamePth_POSIX
--
-- gives a list of all encodings
-- do shell script "iconv -l "
--
-- how it works -> from encoding to encoding inputfile
-- changes encodings only
-- set NewEncodedText to do shell script "iconv -f UTF-8 -t CP1252 " & quoted form of POSIX path of MyTextFile
--
tell me to do shell script "echo " & (quoted form of url_list) & " >" & nuNamePth_POSIX0
delay 0.5
--
-- Fix the carriage return
-- https://www.macscripter.net/t/convert-mac-cr-to-windows-crlf/58552
--
tell me to do shell script "perl -pe 's/(:?\\r\\n?|\\n)/\\r\\n/g' <" & nuNamePth_POSIX0 & " >" & nuNamePth_POSIX & "" without altering line endings
delay 0.75
tell me to do shell script "rm -f " & nuNamePth_POSIX0
--
set nuNamePth_alias to ((pth as string) & nuName) as alias
delay 0.5
--
set urlDest to "file://" & nuNamePth_POSIX
set the clipboard to urlDest
--
tell application "Brave Browser"
activate tab "New Tab"
tell application "System Events"
tell menu item "New Private Window" of menu "File" of menu bar item "File" of menu bar 1 of application process "Brave Browser"
click
end tell
delay 0.5
tell window "New Tab"
keystroke "a" using {command down}
delay 0.85
keystroke "v" using {command down}
delay 0.85
keystroke return
end tell
end tell
delay 0.75
end tell
--
--
(*
Found an AppleScript at: "https://veritrope.com/code/export-all-brave-tabs-to-a-text-file/"
Veritrope.com
Export All Brave Tabs to a Text File
VERSION 1.0
September 8, 2012
// INSPIRED BY: Francesco Di Lorenzo (@frankdilo)
20241031 Thursday
Renamed "Chrome" to "Brave"
I made several **Significant Changes** to the original downloaded AppleScript file.
The original AppleScript was written for Google Chrome users.
Now, this AppleScript is written for Brave Browser (MacOS) users.
*)
--
--