Google Chrome – How to Bring an Existing GMail Tab to the Front

Hi Chris, I was wondering if this can be modified to work in 'Brave Browser'.
I tried replacing "Google Chrome" in the script with "Brave Browser" but it doesn't seem to work.
Screenshot 2023-09-01 at 11.37.47

Sharing the script below:

----------------------------------------------------
# Auth: Christopher Stone <scriptmeister@thestoneforge.com>
# dCre: 2015/05/14 12:30
# dMod: 2015/08/15 20:26
# Appl: Google Chrome, System Events
# Task: Bring Chrome Tab with Google Calendar to front if it exists - otherwise open Calendar in new window.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @Google_Chrome, @System_Events
----------------------------------------------------

set googleServiceURL to "https://www.google.co.uk/"

set _win to false
tell application "Brave Browser"
	set {idList, urlList} to {id, URL} of every tab of every window
end tell

set AppleScript's text item delimiters to return

if (urlList as text) contains googleServiceURL = true then
	set theWin to 1
	repeat with i in urlList
		set theTab to 1
		repeat with n in i
			if n starts with googleServiceURL then
				set {_win, _tab} to {theWin, theTab}
			end if
			set theTab to theTab + 1
		end repeat
		set theWin to theWin + 1
	end repeat
end if

if _win ≠ false then
	tell application "System Events"
		if quit delay ≠ 0 then set quit delay to 0
		tell process "Brave Browser"
			perform action "AXRaise" of window _win
		end tell
	end tell
	tell application "Brave Browser"
		tell front window to set active tab index to _tab
	end tell
else
	tell application "Brave Browser"
		set newWin to make new window
		tell newWin to set URL of active tab to googleServiceURL
	end tell
end if

----------------------------------------------------

Also if it works in brave browser, I'd like it to open the URL in new tab rather a new window.

In case you're not aware, Brave Browser is chromium based browser with almost all features identical to Google Chrome. All Google Chrome extensions work with Brave Browser. And the reason I replaced Chrome with Brave is because Brave is known for the privacy features. Also we can have ad free experience on almost all websites including Google and YouTube. All this, for free.