Skip to content

Instantly share code, notes, and snippets.

@ChristoferK
Created October 13, 2020 15:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChristoferK/f055fa0f1514c3b686a6c3f0673d2f95 to your computer and use it in GitHub Desktop.
Save ChristoferK/f055fa0f1514c3b686a6c3f0673d2f95 to your computer and use it in GitHub Desktop.
[Match Safari Tabs Against URL Substring] A fast, efficient tab filter that operates over all tabs in all Safari windows to return a reference to those where the URL contains a given phrase. #AppleScript #Safari #browser #windows #tabs #URL #filter #search
on SafariTabsWhoseURLsContain:(phrase as text)
set text item delimiters to linefeed
tell application id "com.apple.Safari" to if it ¬
is running then tell every window to if ¬
it exists then tell (it where (index of ¬
tab 1 where phrase is in the URL) is in ¬
index of tabs) to tell (every tab whose ¬
URL contains the phrase) to if (exists) ¬
then return a reference to it
end SafariTabsWhoseURLsContain:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment