exit edge flag disable section when user is using a different lang #94 #95

This commit is contained in:
zoicware
2025-12-20 00:16:37 -05:00
committed by GitHub
parent 36c0292aa0
commit a960cee263

View File

@@ -273,9 +273,17 @@ function Disable-Registry-Keys {
$config = "$env:LOCALAPPDATA\Microsoft\Edge\User Data\Local State"
if (Test-Path $config) {
#powershell core bug where json that has empty strings will error
#$jsonContent = (Get-Content $config).Replace('""', '"_empty"') | ConvertFrom-Json
$jsonContent = (Get-Content $config -Raw) -replace '(?<!\\)""', '"_empty"' -replace '{\s*}', '{"_empty":"_empty"}' | ConvertFrom-Json
try {
$jsonContent = (Get-Content $config).Replace('""', '"_empty"') | ConvertFrom-Json -ErrorAction Stop
$fail = $false
}
catch {
Write-Status -msg 'Unable to set Edge flags to disable Copilot due to a different langauge being used' -errorOutput $true
Write-Status -msg 'You can manually disable the Copilot flags at [edge://flags] in the browser' -errorOutput $true
$fail = $true
}
if (!$fail) {
try {
if (($jsonContent.browser | Get-Member -MemberType NoteProperty enabled_labs_experiments -ErrorAction Stop) -eq $null) {
$jsonContent.browser | Add-Member -MemberType NoteProperty -Name enabled_labs_experiments -Value @()
@@ -305,6 +313,7 @@ function Disable-Registry-Keys {
Write-Status -msg 'Edge Browser has never been opened on this machine unable to set flags...' -errorOutput $true
Write-Status -msg 'Open Edge once and run this tweak again' -errorOutput $true
}
}
}