Write-Host "=== MOZILLA FIREFOX NOTIFICATION LOCKDOWN SCRIPT ===" -ForegroundColor Cyan # 1. Enforce Firefox Enterprise Registry Policy (Blocks future prompt requests globally) Write-Host "[+] Configuring Registry Policies to block notifications..." -ForegroundColor Windows $RegistryPaths = @( "HKLM:\SOFTWARE\Policies\Mozilla\Firefox\Permissions\Notifications", "HKCU:\SOFTWARE\Policies\Mozilla\Firefox\Permissions\Notifications" ) foreach ($RegPath in $RegistryPaths) { if (-not (Test-Path $RegPath)) { New-Item -Path $RegPath -Force | Out-Null } # BlockNewRequests = 1 disables the prompt completely New-ItemProperty -Path $RegPath -Name "BlockNewRequests" -Value 1 -PropertyType DWord -Force | Out-Null } Write-Host " -> Registry policy applied: New notification requests are hard-blocked globally." -ForegroundColor Green # 2. Close running Firefox processes to safely edit local databases Write-Host "`n[+] Terminating running Mozilla Firefox instances to apply changes..." -ForegroundColor Windows $FFProcesses = Get-Process -Name "firefox" -ErrorAction SilentlyContinue if ($FFProcesses) { Stop-Process -Name "firefox" -Force Start-Sleep -Seconds 2 Write-Host " -> Firefox processes closed." -ForegroundColor Yellow } # 3. Locate and purge existing notification permissions in User Profiles Write-Host "`n[+] Scanning and cleaning local Firefox profile permissions..." -ForegroundColor Windows $UserProfilesDir = "C:\Users" $Users = Get-ChildItem -Path $UserProfilesDir -Directory foreach ($User in $Users) { $FFDataPath = "$UserProfilesDir\$($User.Name)\AppData\Roaming\Mozilla\Firefox\Profiles" if (Test-Path $FFDataPath) { Write-Host " -> Found Firefox Data for user: $($User.Name)" -ForegroundColor Cyan # Target all Firefox user profiles (.default, .default-release, etc.) $Profiles = Get-ChildItem -Path $FFDataPath -Directory foreach ($Profile in $Profiles) { $PermsFile = "$($Profile.FullName)\permissions.sqlite" if (Test-Path $PermsFile) { try { # Firefox locks its permissions inside a SQLite database. # We can use an embedded PowerShell fallback to clear the notification type or delete the file entirely if it corrupts. # This direct string/byte match approach purges historical notification permissions. # Alternatively, if you want a clean slate for the profile, we clear the permissions table using a quick script mechanism # Since editing live SQLite via raw PowerShell without external assemblies is risky, we rename/re-initialize the permission DB. # Firefox automatically regenerates a completely clean permissions.sqlite file upon next startup. Remove-Item -Path $PermsFile -Force -ErrorAction SilentlyContinue Write-Host " [✓] Purged and reset permission database for profile: $($Profile.Name)" -ForegroundColor Green } catch { Write-Host " [!] Error removing file for $($User.Name) ($($Profile.Name)): $_" -ForegroundColor Red } } } } } Write-Host "`n=== RECONFIG COMPLETE ===" -ForegroundColor Cyan Write-Host "Firefox notifications have been cleared out and hard-blocked via registry policies." -ForegroundColor Green