Skip to content

Commit 6ecc097

Browse files
committed
better handling of the "continue where I left off" mode in Chrome
1 parent 6a64437 commit 6ecc097

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

Flitro/ContextManager/ChromeApplicationLauncher.swift

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import Foundation
32
import 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

0 commit comments

Comments
 (0)