File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed
Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change 1-
21import Foundation
32import AppKit
43
@@ -30,11 +29,14 @@ class ChromeApplicationLauncher: ContextApplicationLauncher {
3029 repeat with theUrl in tabUrls
3130 tell window id winId to make new tab with properties {URL:theUrl}
3231 end repeat
33- -- Remove the default blank tab
34- if (count of tabs of window id winId) > (count of tabUrls) then
35- try
32+ -- Close all tabs except the last N (our tabs)
33+ set totalTabs to count of tabs of window id winId
34+ set tabsToKeep to \( urls. count)
35+ set tabsToClose to totalTabs - tabsToKeep
36+ if tabsToClose > 0 then
37+ repeat with i from 1 to tabsToClose
3638 close tab 1 of window id winId
37- end try
39+ end repeat
3840 end if
3941 return winId
4042 end tell
@@ -54,6 +56,11 @@ class ChromeApplicationLauncher: ContextApplicationLauncher {
5456 let script = """
5557 tell application \" Google Chrome \"
5658 if (exists window id \( winId) ) then
59+ -- Close all tabs in the window
60+ set tabCount to count of tabs of window id \( winId)
61+ repeat with i from tabCount to 0 by -1
62+ close tab i of window id \( winId)
63+ end repeat
5764 try
5865 close window id \( winId)
5966 end try
You can’t perform that action at this time.
0 commit comments