Test if URL exists and the Open URL action leads to multiple tabs

I have written a simple macro using "open URL". with say param www.A...
If you run it again with param www.B...
it opens a second tab for this new URL

However, if you are running it again with www.A for whatever reason you may not want a second tab,

So it seems to me it would be useful to be able to specify in Open URL the following

a: open a new tab (always)
b: reuse last tab used
c: reuse/bring to front old tab with same URL and refresh

This could all be in default browser or a specific browser?

Similarly a test to see if the URL already exists

if exists then
bring to front ?
return true/false ?

and maybe a REFRESH URL action eg. REFRESH this specific URL (not currently displayed) or the current frontmost URL?

and maybe
CLOSE tab with this URL if it exists

At the moment I can live with a new tab every time, but maybe I am missing something.....?

How would KM know which tab was the "last tab used"? Are you aware of any AppleScript properties that keep that information available to use? How would KM determine which tab was the last one used? For that matter, how would you, as a human, determine which tab was the last one used? If you can't think of a way that a human could determine "last tab used" then I'm not sure if KM could solve it.

What if there was more than one tab with the same URL? Pick a random one?

And when you say "same URL" do you mean EXACTLY the same, or do you mean the same domain name only, or something else? A lot of websites changes their URL every time you access them, so I'm not sure how you would want to determine "sameness." You need to define what "sameness" is.

Are you aware that there are some AppleScript solutions for all your problems? Are you just asking for KM to provide the same functionality, or did you not know that AppleScript can already do these things? Did you check this site for AppleScript solutions to these problems?

If I'm sounding negative, it's probably because I have a really bad cold today. Sorry.

I do not know, that is why I am asking.

I did a search on the site, but did not find anything recent, so I thought I would ask.

PS Hope you get better soon.

Just did a different search using “Browser Tabs” rather than “URL” and found

which looks very promising.

There's a slight problem in that the "Open a URL" action is nothing to do with web browsers!

At least, not directly... The action passes the URL to the OS, the OS passes it on to the registered application for the URL protocol, the application does its thing.

We might most often use it for http and https, but what about mailto, kmtrigger, keyboardmaestro, gopher (for us old-timers ;-), and so on. Even file:

The "Open a URL" action is so versatile that, as you've found, you need to search the Forum for things more specific to browsers/tabs. @_jims's macro is, IMO, the gold standard, but if you're only worried about a single browser it's not hard to write something that meets your own requirements.

I used gopher when it came out, albeit briefly.

Hmm, interesting that when I quoted your text, this site converted your text characters to an emoji, above.

I do not know which of my comments you were responding to when you said, "I don't know." If you were responding to my question, "How do you define sameness?" then there's no way for me to write a macro. I need to know the requirements.

I think this is because you didn't include the comma.