code

Find Safari Tabs by Substring

More on Safari Tabs: Here’s a lovely little AppleScript to find tabs by substring search. It works like a charm. Here’s a Keyboard Maestro Macro that works with a slightly modified version of the script: Here’s the modified AppleScript. I simply replaced the GUI elements with the Keyboard Maestro input action and a KM variable. :::AppleScript tell application "Keyboard Maestro Engine" set searchpat to (process tokens "%Variable%Find%") end tell tell application "Safari" set winlist to every window set winmatchlist to {} set tabmatchlist to {} set tabnamematchlist to {} repeat with win in winlist set ok to true try set tablist to every tab of win on error errmsg --display dialog name of win as string set ok to false end try if ok then repeat with t in tablist if searchpat is in (name of t as string) then set end of winmatchlist to win set end of tabmatchlist to t set end of tabnamematchlist to (id of win as string) & ".