Skip to content

Instantly share code, notes, and snippets.

@HR
Created December 31, 2016 18:47
Show Gist options
  • Save HR/9d92eb2cdfa36c4af833a4586f5bd986 to your computer and use it in GitHub Desktop.
Save HR/9d92eb2cdfa36c4af833a4586f5bd986 to your computer and use it in GitHub Desktop.
Close tabs containing a URL in Safari Applescript
on run argv
set passedInURL to (item 1 of argv)
tell application "Safari"
set windowCount to number of windows
repeat with x from 1 to windowCount
set tabCount to number of tabs in window x
repeat with y from 1 to tabCount
set thistab to tab y of window x
set thisURL to URL of thistab
if passedInURL is in thisURL then close thistab
end repeat
end repeat
end tell
end run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment