Skip to content

Commit

Permalink
Merge pull request #978 from mandiant/chrome-fix
Browse files Browse the repository at this point in the history
Bypass annoying chrome pop-ups
  • Loading branch information
Ana06 authored Apr 11, 2024
2 parents 538a538 + 14a8189 commit b37e2a2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/googlechrome.vm/googlechrome.vm.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<id>googlechrome.vm</id>
<version>0.0.0.20240111</version>
<version>0.0.0.20240405</version>
<authors>Google LLC.</authors>
<description>Chrome is a popular web browser.</description>
<dependencies>
Expand Down
30 changes: 29 additions & 1 deletion packages/googlechrome.vm/tools/chocolateyinstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,35 @@ try {
fileType = 'MSI'
silentArgs = "/quiet /norestart /l*v `"$($env:TEMP)\$($env:chocolateyPackageName).$($env:chocolateyPackageVersion).MsiInstall.log`""
}
Install-ChocolateyInstallPackage @packageArgs
Install-ChocolateyInstallPackage @packageArgs -ErrorAction SilentlyContinue

VM-Assert-Path "${env:ProgramFiles}\Google\Chrome\Application\chrome.exe"
} catch {
VM-Write-Log-Exception $_
}

# Try to set configuration, but do not fail the package if it fails
$ErrorActionPreference = 'Continue'

# Expand the path to the Chrome User Data folder and create the "User Data" folder if it doesn't exist.
$userDataPath = ${Env:LOCALAPPDATA} + "\Google\Chrome\User Data"
New-Item -ItemType Directory -Path $userDataPath -Force -ea 0 | Out-Null

# Create the empty file "First Run" to bypass the "Sign in to Chrome" initial pop-up.
New-Item -Path $userDataPath -Name "First Run" -ItemType File -Force -ea 0 | Out-Null

# Create the "Local State" file with data required to bypass the "What's New" pop-up tab.
# Number must be higher than the current Chrome Version number and using 999 gives us some time before it fails.
$contentOptions = @{
Path = Join-Path $userDataPath "Local State"
Value = '{"browser":{"last_whats_new_version":999}}'
}
Set-Content @contentOptions

# Create the "Default" folder with a "Preferences" file with data required to bypass "Enhanced ad privacy" pop-up.
New-Item -Path $userDataPath -Name "Default" -ItemType Directory -Force -ea 0 | Out-Null
$contentOptions = @{
Path = Join-Path $userDataPath "Default\Preferences"
Value = "`{`"privacy_sandbox`":{`"m1`":{`"row_notice_acknowledged`":true}}`}"
}
Set-Content @contentOptions

0 comments on commit b37e2a2

Please sign in to comment.