Answers:
这可以通过以下脚本编辑器来实现:
do shell script "open -a /Applications/Google\\ Chrome.app --args --incognito"
将其另存为应用程序,将别名放入扩展坞中。在10.6.8中对此进行了测试。
仅当您尚未打开Chrome时才有效。
另一个解决方法:
模式(文本):代表窗口的模式,可以是“正常”或“隐身”模式,在窗口创建期间只能设置一次。
tell application "Google Chrome"
close windows
make new window with properties {mode:"incognito"}
activate
end tell
Zdne编写了一种很好的方法来做到这一点,即使您已经打开了Chrome浏览器,该方法仍然有效:
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
使用Run Applescript块将其另存为Automator应用程序,然后可以使用为应用程序指定的名称在Spotlight中运行它。
如果不存在新的chrome隐身窗口,我将Lyken和user3936答案组合在一起,如果存在隐身窗口,脚本会将其带到前台。
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
我很快用鸭嘴兽创建了一个应用,以启动Chrome隐身模式。
您可以从http://ente.limmat.ch/ftp/pub/software/applications/GoogleChromeIncognito/ 下载它,包括源代码。
该应用程序的功能:
(需要OS X 10.6+)。
该应用程序内的脚本如下:
#!/ bin / bash
#(c)2012年,由Adrian Zaugg根据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 $ //“)”
#询问Spotlight Chrome所在的位置,选择顶部条目,因为这是最新打开的Chrome版本
CHROMEPATH =“ $(mdfind'kMDItemContentType ==” com.apple.application-bundle“ && kMDItemFSName =”'“” $ CHROMENAME.app“'”'|头-1)“
#如果系统不知道Chrome的位置,请期待我旁边的Chrome。
如果[-z“ $ CHROMEPATH”]; 然后
CHROMEPATH =“ $ MYPATH / $ CHROMENAME.app”
科幻
如果[-e“ $ CHROMEPATH”]; 然后
#是否已有实例在运行?
如果[[$(ps -u $(id -u)| grep -c“ $ CHROMEPATH / Contents / MacOS / Google Chrome”] -gt 1];然后
#使用Apple脚本打开新的隐身窗口
osascript -e'告诉应用程序“'”“ $ CHROMENAME”'“'\
-e'设置IncogWin以创建具有属性{mode:“ incognito”}}的新窗口
-e'将IncogWin的活动选项卡的URL设置为“ about:blank”'\
-e'结束告诉'
其他
#只需以隐身模式打开Chrome
打开-n“ $ CHROMEPATH” --args --incognito --new-window“ about:blank”
科幻
#将Chrome置于最前面
osascript -e'告诉应用程序“'”“ $ CHROMENAME”'“以激活'
其他
#找不到Chrome
osascript -e'tell app“'” $ MYAPPNAME“'”以显示对话框“请把我放在'” $ CHROMENAME“'旁边!” 按钮“确定”,默认按钮1,标题为“'“ $ MYAPPNAME”'“,图标停止'
科幻
出口0
这也可以。
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --incognito
如果您希望将其带到前台,
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --incognito; open -a /Applications/Google\ Chrome.app