Mnisbet
Mnisbet

Reputation: 63

Closing chrome incoginto window via terminal or applescript

Was hoping someone could help me with code that would detect whether an incognito window (or multiple incognito windows) was open, and if so close it/them.

I found the below code which will achieve this if the only window open was incognito, but unsure how to implement a loop to check all open windows and close only those that are incognito.

tell application "Google Chrome"
if exists window 1 then
    if mode of window 1 = "incognito" then
        -- insert your code here
    end if
end if
end tell

Upvotes: 0

Views: 423

Answers (1)

jweaks
jweaks

Reputation: 3792

You don't need a repeat loop to close all the incognito windows. You can do it with an "every window whose mode is" qualifier. Like so:

tell application "Google Chrome" to close (every window whose mode is "incognito")

Upvotes: 2

Related Questions