每个窗口单独的会话(Separate session for each window)

2019-08-02 12:29发布

我想创建一个扩展,其中铬的每个窗口都有自己的会话。 我们隐姓埋名较早使用,但问题是,在主窗口和隐身窗口有单独的会话,会话的各种隐身窗口之间共享。

有没有配置Chrome浏览器在每次打开隐身窗口时间使用一个单独的会话的方法吗?

Answer 1:

你的目标将有一个新的用户数据目录是启动一个浏览器实例。 Cookie会在每个实例中分离出来。 在扩展实施的方式达到相同的目标在CMD命令:

chrome.exe --user-data-dir="C:\temp\user1"


Answer 2:

我有一个类似的问题,我想使用谷歌浏览器进行浏览和调试工作和铬是相当原始的,当谈到会议。 我写这个批处理脚本复制默认的配置文件,清晰的会话信息,然后使用新的配置文件。 在创建新的之前老重复配置文件也被清除。 其结果是所有的旧的个人资料的东西一个新的会话。

@echo off

rem folder prefix for the new profile folder
set folderNameStart=profile_

rem generate and format the date creating the new folder name
For /f "tokens=1-6 delims=/ " %%a in ('date /t') do (set mydate=%%c%%b%%a)
For /f "tokens=1-2 delims=/:" %%a in ('time /t') do (set mytime=%%a%%b)
set folderName=%folderNameStart%%mydate%%mytime%%random%

rem set the profile path and the folder destination as well as the directory to 
delete
set profilePath="C:\Documents and 
Settings\%USERNAME%\AppData\Local\Google\Chrome\User Data\Default"
set profileDestination="C:\Documents and 
Settings\%USERNAME%\AppData\Local\Google\Chrome\User Data\"%folderName%
set profileLocation="C:\Documents and 
Settings\%USERNAME%\AppData\Local\Google\Chrome\User Data\"

rem iterate through directory and delete all the existing profile folders
CD %profileLocation%
echo %profileLocation%
for /D /r %%G in ("%folderNameStart%*") do rmdir /q /s "%%G"

rem this will copy the old profile directory 
echo D | xcopy %profilePath% %profileDestination%

rem delete the session storage and its contents if its exist
rmdir /q /s "C:\Documents and Settings\%USERNAME%\AppData\Local\Google\Chrome\User 
Data\%folderName%\Session Storage"


rem start google chrome with the new profile folder
start "Chrome" "C:\Program Files\Google\Chrome\Application\chrome.exe" --profile-directory="%folderName%"


文章来源: Separate session for each window