Here's an example that works with Chrome, Brave, and Edge (the latter two with slight modifications). They all include the Chromium Suite. Safari includes the Safari Suite and a very similar AppleScript works for it.
This script is passed three variables from Keyboard Maestro: local_Url, local_UrlPattern, and local_ReloadTab. The script function is simple...
If the browser includes a window with a tab URL that matches local_UrlPattern (RegEx), then that tab is activated. If local_ReloadTab is "1", then the activated tab is reloaded.
If a match is not found, the browser opens local_Url in a new tab.
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
use framework "Foundation"
### Requires Keyboard Maestro 8.0.3+ ###
set kmInst to system attribute "KMINSTANCE"
tell application "Keyboard Maestro Engine"
set kmUrl to getvariable "local_Url" instance kmInst
set kmUrlPattern to getvariable "local_UrlPattern" instance kmInst
set kmReloadTab to getvariable "local_ReloadTab" instance kmInst
end tell
property NSRegularExpressionSearch : a reference to 1024
if kmUrlPattern ends with "/" then set kmUrlPattern to text 1 thru -2 of kmUrlPattern
set windowIndex to 1
tell application "Google Chrome"
repeat with theWindow in windows
set tabIndex to 1
repeat with theTab in tabs of theWindow
set theTabURL to URL of theTab
if theTabURL ends with "/" then set theTabURL to text 1 thru -2 of theTabURL
if (my regexMatch:theTabURL withPattern:kmUrlPattern) then
activate
tell window windowIndex
set active tab index to tabIndex
set index to 1
end tell
tell application "System Events" to tell process "Google Chrome"
perform action "AXRaise" of window 1
end tell
if kmReloadTab is "1" then
tell the active tab of its first window to reload
end if
return
end if
set tabIndex to tabIndex + 1
end repeat
set windowIndex to windowIndex + 1
end repeat
open location kmUrl
end tell
on regexMatch:theText withPattern:thePattern
set thePattern to "^" & thePattern & "$"
set theText to current application's NSString's stringWithString:theText
set theRange to theText's rangeOfString:thePattern options:NSRegularExpressionSearch
return (|length| of result) > 0
end regexMatch:withPattern: