Tabskip macro

Tabskip V1.0

Hi all. I've hacked up something some of you may find useful. Essentially it's an applescript that searches all open browser tabs titles and urls for a string (in both Safari and Chrome), then jumps to that tab. Then, if you run it again with a certain number of seconds, it will jump to the next matching tab, across multiple browsers.

Core use case: map a key to run script with "gmail" as input, hit multiple times to run through all tabs with gmail in url or title.

You can also run it once with a search string, then again without but passing "forward" or "back" as a parameter. This will skip through the matching tabs. I use this with karbiner/goku: hold down "b", hit "g" for gmail, keep holding down "b", hit "n" for next and "p" for previous.

The script does not open a new tab when not found: I thought this was best left to Keyboard Maestro. It returns true or false, and you can handle this how you wish. See the example for handling opening gmail when not found.

Note that this applescript is stateful: you need to save it on disk (default in the Keyboard Maestro macro is ~/.config/applescripts/FastTabSkip.scpt). This is so it can remember the order of windows as you iterate. It also has some caching built in: if you call it within three seconds (configurable in the script) then next/prev will jump relative to the current tab, otherwise it will requery all browser windows and start at the first tab.

My focus for this script has been performance: I wanted the applescript to jump through windows as fast as possible. As such it caches what can be expensive operations: retrieving the windows and tab titles for both browser. If you rerun the script within 3 seconds it will skip the retrieval. However my testing on a quite slow ageing macbook air show that the slowest part of the script is the axraise of the window, especially when it is on another space. There's a "Voodoo" delay in the script I added to handle desktop switching. You may be able to drop this depending on your mac.

I hacked this together from a bunch of other peoples scripts- none of the core code is mine, apologies if I don't credit you. I've spent a couple of days debugging the (really nasty) edge cases, but it's probably still buggy as anything :man_shrugging:. I welcome any suggestions for revisions especially regarding performance. (17.0 KB)

TabSkipDemo Macros.kmmacros (12.6 KB)

1 Like