Edge Settings 在哪里存储关闭浏览器时不得清除 cookie 的网站列表?

问题描述 投票:0回答:2

Edge 在哪里存储在 edge://settings/clearBrowsingDataOnClose 添加的网站列表?

我在注册表中找不到这些,我想通过脚本或命令添加到此列表 - 而不是通过 Edge 设置 UI 手动/交互地添加。

microsoft-edge
2个回答
1
投票

您是说该页面上不清除下的站点列表吗?如果是这样,它存储在一个名为 Preferences.

的文件中
  1. 找到首选项文件的位置。您可以转到 edge://version/ 并找到 Profile path。首选项文件位于该路径下。

  1. 用记事本打开首选项文件并搜索
    clear_browsing_data_cookies_exceptions
    。这是控制设置的值。例如,我设置不清除列表如下:

文件中的值是这样的:

 "clear_browsing_data_cookies_exceptions":{"*,www.google.com":{"last_modified":"13321607962560793","setting":1},"www.bing.com,*":{"last_modified":"13321607952873922","setting":1}}

注:

last_modified
的值为WebKit/Chrome Timestamp。


更新:

用于编辑文件的示例 PowerShell 代码:

$file = 'C:\Users\username\AppData\Local\Microsoft\Edge\User Data\your profile\Preferences'
$content = Get-Content -Path $file
$newContent = $content -replace 'clear_browsing_data_cookies_exceptions":{', 'clear_browsing_data_cookies_exceptions":{"www.stackoverflow.com,*":{"last_modified":"13321607962560794","setting":1},'
$newContent | Set-Content -Path $file

请注意,在编辑文件之前,您需要使用

taskkill /f /im msedge.exe
杀死所有Edge进程。

注册表解决方案:

此策略 Microsoft Edge 关闭时保存 cookie 可以编辑此设置。 对应的注册表设置如下:

注意:此政策仅在以下情况下有效:


0
投票

这也有效,但有两个问题:

  1. 必须通过UI手动添加第一个条目,以处理第一个条目末尾的逗号。
  2. 批处理文件只有在首先更改为配置文件路径文件夹时才有效。
    @echo off
    rem Add websites to Edge list of sites not to clear cookies for when closing.
    rem Manually add one site first before running the script to add the other sites - this deals with the comma at the end.
    
    cd "C:\Users\username\AppData\Local\Microsoft\Edge\User Data\Default"
    set EdgeSettingsFile=Preferences
    
    rem call :AddSite 192.168.1.4 //Add this manually before running the script to add the other sites - this deals with the comma at the end.
    call :AddSite [*.]live.com
    call :AddSite [*.]microsoft.com
    call :AddSite [*.]microsoftonline.com
    call :AddSite [*.]office.com
    call :AddSite [*.]onenote.com
    call :AddSite [*.]youtube.com
    goto :end
    
    :AddSite
    set foo=\"clear_browsing_data_cookies_exceptions\":{
    set bar=\"clear_browsing_data_cookies_exceptions\":{\"%1,*\":{\"last_modified\":\"13316715107817621\",\"setting\":1},
    powershell -Command "(gc %EdgeSettingsFile%) -replace '%foo%', '%bar%' | Out-File -encoding ASCII %EdgeSettingsFile%"
    pause
    exit /B
    
    :end
    start "C:\Program Files\Notepad++\notepad++.exe" %EdgeSettingsFile%
© www.soinside.com 2019 - 2024. All rights reserved.