How do I open Google Chrome in Incognito mode by default
This can be achieved with the following in script editor:
do shell script "open -a /Applications/Google\\ Chrome.app --args --incognito"
Save it as an application, throw the alias in the dock. Tested this in 10.6.8.
Only works if you don't have chrome open already.
Another workaround:
mode (text) : Represents the mode of the window which can be 'normal' or 'incognito', can be set only once during creation of the window.
tell application "Google Chrome"
close windows
make new window with properties {mode:"incognito"}
activate
end tell
Zdne has written a nice way to do this that works even if you've already got Chrome open:
if application "Google Chrome" is running then
tell application "Google Chrome" to make new window with properties {mode:"incognito"}
else
do shell script "open -a /Applications/Google\\ Chrome.app --args --incognito"
end if
tell application "Google Chrome" to activate
Save that as an Automator application using a Run Applescript
block and you can run it from Spotlight using the name you gave the application.
I combined Lyken and user3936 answer to open a new chrome incognito window if it does not exist, and if a incognito window exists the script will bring it to the foreground.
on is_running(appName)
tell application "System Events" to (name of processes) contains appName
end is_running
set chrome_running to is_running("Google Chrome")
if chrome_running then
tell application "Google Chrome"
repeat with w in (windows)
if mode of w is "incognito" then
set index of w to 1
tell application "System Events" to tell process "Google Chrome"
perform action "AXRaise" of window 1
end tell
activate
return
end if
end repeat
end tell
tell application "Google Chrome"
make new window with properties {mode:"incognito"}
activate
end tell
else
do shell script "open -a /Applications/Google\\ Chrome.app --args --incognito"
end if
I quickly created an app with platypus to launch Chrome incognito.
You can download it including the source from: http://ente.limmat.ch/ftp/pub/software/applications/GoogleChromeIncognito/
The app features:
- opens a new incognito window whether Chrome is open or not
- does not stay in the dock when Chrome has been started
- shows the new window with a blank page
- finds Chrome from every where in any location
- Chrome update resistent
- open source
(OS X 10.6+ required).
The script inside the app is the following:
#!/bin/bash # (c) 2012 by Adrian Zaugg under GNU GPL v.2 CHROMENAME="Google Chrome" MYPATH="$(dirname "$(dirname "$0" | sed -e "s%/Contents/Resources$%%")")" MYAPPNAME="$(basename "$(dirname "$0" | sed -e "s%/Contents/Resources$%%")" | sed -e "s/\.app$//")" # Ask Spotlight where Chrome is located, chose top entry since this was the latest opened Chrome version CHROMEPATH="$(mdfind 'kMDItemContentType == "com.apple.application-bundle" && kMDItemFSName = "'"$CHROMENAME.app"'"' | head -1)" # Expect Chrome next to me, if the system doesn't know where it is. if [ -z "$CHROMEPATH" ]; then CHROMEPATH="$MYPATH/$CHROMENAME.app" fi if [ -e "$CHROMEPATH" ]; then # Is there an instance already running? if [ $(ps -u $(id -u) | grep -c "$CHROMEPATH/Contents/MacOS/Google Chrome") -gt 1 ]; then # use apple script to open a new incognito window osascript -e 'tell application "'"$CHROMENAME"'"' \ -e ' set IncogWin to make new window with properties {mode:"incognito"}' \ -e ' set URL of active tab of IncogWin to "about:blank"' \ -e 'end tell' else # just open Chrome in incognito mode open -n "$CHROMEPATH" --args --incognito --new-window "about:blank" fi # bring Chrome to front osascript -e 'tell application "'"$CHROMENAME"'" to activate' else # Chrome not found osascript -e 'tell app "'"$MYAPPNAME"'" to display dialog "Place me next to '"$CHROMENAME"', please!" buttons "OK" default button 1 with title "'"$MYAPPNAME"'" with icon stop' fi exit 0