How to change preferences in Chrome by modifying files?

如何修改 chrome 的預設參數,資料來源:
https://superuser.com/questions/554233/how-to-change-preferences-in-chrome-by-modifying-files

解法:

There is a file called “Preferences” within the “User Data/<Profile>” folder that appears to contain these settings. The location of this file varies according to OS. For the “Default” profile this is located at:

WinXP:

C:\Documents and Settings\<User Name>\Local Settings\Application Data\Google\Chrome\User Data\Default\Preferences

WinVista:

C:\Users\<User Name>\AppData\Local\Google\Chrome\User Data\Default\Preferences

You then need to search for the appropriate setting in that file. I would close Chrome (and backup) first as this file appears to be updated automatically as you navigate tabs.

Enable Auto-fill to fill in web forms in a single click.” appears to be stored here:

   "autofill": {
      "enabled": true,

Offer to save passwords I enter on the web.

      "password_manager_enabled": true,

Deploy initial preferences:
https://support.google.com/chrome/a/answer/187948?hl=en#zippy=%2Cstep-create-the-initial-preferences-file


寫入 Preferences 的程式碼:

def nodriver_overwrite_prefs(conf, prefs_dict={}):
    prefs_filepath = os.path.join(conf.user_data_dir,"Default")
    if not os.path.exists(prefs_filepath):
        os.mkdir(prefs_filepath)
    prefs_filepath = os.path.join(prefs_filepath,"Preferences")
    prefs_dict["profile"]={}
    prefs_dict["profile"]["name"]=CONST_APP_VERSION
    prefs_dict["profile"]["password_manager_enabled"]=False
    json_str = json.dumps(prefs_dict)
    with open(prefs_filepath, 'w') as outfile:
        outfile.write(json_str)

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *