如何以编程方式创建Chrome个人资料? [英] How to create a Chrome profile programmatically?

查看:92
本文介绍了如何以编程方式创建Chrome个人资料?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的设置中,开发,测试,暂存环境是通过不同的代理服务器控制的.我想编写多个Chrome配置文件(有时称为用户"或人")的脚本,并为每个配置文件连接到不同的代理服务器.最后,我想与同事共享此脚本,以便他们可以访问完全相同的设置.

Development, testing, staging environments are controlled via different proxy servers in my setup. I want to script creation of multiple Chrome profiles (sometimes called "user" or "person") and connect to a different proxy server for each of them. Finally I want to share this script with colleagues so that they have access to the exactly same setup.

后者可以通过脚本安装扩展来完成,例如 Falcon代理代理助手到Chrome配置文件.我想知道如何编写不同配置文件的脚本.

The latter can be done via scripted installation of extensions such as Falcon Proxy or Proxy Helper to the Chrome profile. I would like to know how to script creation of the different profiles.

配置文件是~/.config/google-chrome(Linux,~/Library/Application Support/Google/Chrome(Mac OS X)和%USERPROFILE%\AppData\Local\Google\Chrome\User Data(Windows))中的文件夹.但是如何创建和初始化一个文件呢?在哪里注册新的配置文件?

A profile is a folder inside ~/.config/google-chrome (Linux, ~/Library/Application Support/Google/Chrome (Mac OS X) and %USERPROFILE%\AppData\Local\Google\Chrome\User Data (Windows). But how to create and initialize one? Where do I register the new profile?

推荐答案

创建用户

以下示例适用于Windows,但基本过程应相同.

Creating a user

The following example applies to Windows, but the basic procedure should be the same.

首先,在您的Chrome安装中更改为UserData文件夹:

First, change to the UserData folder in your Chrome installation:

cd "%APPDATA%\..\Local\Google\Chrome\User Data"

此方法会将当前用户复制为新用户的模板.如果新用户应该为空白,则需要删除(CTRL + SHIFT + DEL当前浏览器数据).

This method will copy the current user as a template for the new user. If the new user should be blank, you need to delete (CTRL + SHIFT + DEL the current browser data).

现在创建一个新用户:

mkdir NewUser && copy Default NewUser

将目录更改为chrome安装:

Change your directory to the chrome installation:

cd "C:\Program Files (x86)\Google\Chrome\Application"

工厂重置所有用户参数:

Factory-Reset all user parameters:

chrome.exe --user-data-dir="..\User Data\NewUser" -first-run

其中--user-data-dir是先前创建的NewUser目录的路径(完整或相对).

where --user-data-dir is the path (full or relative) to the previously created NewUser directory.

要使用此配置文件再次运行chrome,只需运行不带-first-run标志的chrome.

To run chrome again using this profile, simply run chrome without the -first-run flag.

这篇关于如何以编程方式创建Chrome个人资料?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆