Activate Safari/Chrome and Select an Existing Tab vs Creating a New Tab

Is there a way to open an existing tab in Safari or Chrome vs opening a duplicate version of an existing tab? I can see how easy it is to open new tabs in these browsers, but once I open such a tab, I would like a way to quickly return to it vs opening up additional duplicate tabs.

Yes, but you have to do it via AppleScript, since you need to write the code to decide which tab you want.

Basically, you need to scan through the windows and their tabs looking for the desired tab, and if found, select that window/tab, and if not, create a new window/tab.

I don’t have the AppleScript handy, but you should be able to find it on the net, or one of the AppleScript gurus on the list might chime in with the code for how to do this.

1 Like

Hey bdurham,

Try out this macro.

Type-select works.

Selecting a tab will take you to it.

Safari » Switch Tabs-Windows Using Pick-List.kmmacros (5.8 KB)

See this post for an example of switching to a specific tab (Google Chrome not Safari – the coding is not the same but the concepts are.)

Go to Gmail Tab in Chrome

-Chris

1 Like

Hey Folks,

Here's a version that works with Google Chrome.

-Chris


Google Chrome ⇢ Go-To-Tab ⇢ AppleScript Version v1.00.kmmacros (8.5 KB)

1 Like

hi @ccstone , you wouldn't by chance have an updated version of the Safari Switch tabs macro, (that you shared 10 years ago :rofl: ) that works today?

I found another version that works well out of the box for Safari: Find Safari Tabs with AppleScript

Sadly/unfortunatly @ccstone hasn't been on here in quite a while and if he did get back on he would have a backlog a few miles long.

Glad you found something else that works.

1 Like

Other threads have covered this more recently, so a search on the Forum might get you something.

FWIW, this is the subroutine I use. It lets you search either tab names or URLs, matches the start, end, or "contains", and lets you pick Safari or Chrome. It then either activates the first matching tab and returns 0, or returns 1 to indicate no match.

SUB - Activate First Matching Tab.kmmacros (5.4 KB)

Image

Example use -- a macro that brings the KM Forum to the front, or opens the Forum in a new window if it isn't already open:

KMForum.kmmacros (4.0 KB)

Image

2 Likes

thanks! this turned out to be more reliable that the other applescript I found.