1. Let the user choose the firefox flavor (regular or ESR) without editing the script 2. Apply the librewolf patch directly after installing (No 7za) 3. Remove the telemetry that points to firefox.settings.services.mozilla.com (issue #10)
89 lines
3.1 KiB
PowerShell
89 lines
3.1 KiB
PowerShell
Import-Module BitsTransfer
|
|
|
|
$ProgramName = "*Mozilla*Firefox*"
|
|
$installPath = Get-ChildItem "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*" | Where-Object { $_.getValue('DisplayName') -like $ProgramName } | ForEach-Object { $_.getValue('InstallLocation')}
|
|
|
|
if (!$installPath) {
|
|
|
|
# Choose firefox flavor
|
|
write-host ""
|
|
write-host "1 - Download Firefox"
|
|
write-host "2 - Download Firefox Extended Support Release"
|
|
write-host ""
|
|
write-host "E - Exit"
|
|
write-host ""
|
|
write-host -nonewline "Type your choice and press Enter: "
|
|
|
|
$choice = read-host
|
|
switch -Regex ( $choice ) {
|
|
1 { Write-Host "Firefox" -ForegroundColor Green; $url = "https://download.mozilla.org/?product=firefox-latest-ssl&os=win"}
|
|
2 {Write-Host "Firefox ESR" -ForegroundColor Green; $url = "https://download.mozilla.org/?product=firefox-esr-latest-ssl&os=win"}
|
|
default { exit }
|
|
}
|
|
if ([IntPtr]::size -eq 8) { # Check if the system is 64bit and download the correct version
|
|
$url += "64"
|
|
}
|
|
|
|
$downloadfile = "\FirefoxInstaller.exe"
|
|
Write-Output "Downloading firefox..."
|
|
Start-BitsTransfer -Source $url -Destination $downloadfile
|
|
|
|
Write-Output ""
|
|
Write-Output "Installing Firefox. Please, follow the wizard"
|
|
Start-Process $downloadfile -NoNewWindow -Wait
|
|
|
|
# Check if firefox is running and close/kill
|
|
while ($firefox = Get-Process firefox -ErrorAction SilentlyContinue) {
|
|
$firefox.CloseMainWindow()
|
|
# kill after five seconds
|
|
Sleep 10
|
|
if (!$firefox.HasExited) {
|
|
$firefox | Stop-Process -Force
|
|
}
|
|
Sleep 3
|
|
}
|
|
|
|
# Check if firefox is installed
|
|
Remove-Item $downloadfile
|
|
$installPath = Get-ChildItem "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*" | Where-Object { $_.getValue('DisplayName') -like $ProgramName } | ForEach-Object { $_.getValue('InstallLocation')}
|
|
if (!$installPath) {
|
|
Write-Output "Firefox can't be located. Process can't continue"
|
|
exit
|
|
}
|
|
|
|
} else {Write-Host "Firefox is installed" }
|
|
|
|
while ($firefox = Get-Process firefox -ErrorAction SilentlyContinue) {
|
|
$firefox.CloseMainWindow()
|
|
# kill after five seconds
|
|
Sleep 5
|
|
if (!$firefox.HasExited) {
|
|
$firefox | Stop-Process -Force
|
|
}
|
|
Sleep 3
|
|
}
|
|
|
|
Write-Output "Delete files with privacy....."
|
|
Remove-Item -Path $installPath\crashreporter.exe -Force
|
|
Remove-Item -Path $installPath\updater.exe -Force
|
|
Remove-Item -Path $installPath\pingsender.exe -Force
|
|
|
|
Write-Output "Extra privacy..."
|
|
$bytes = [System.IO.File]::ReadAllBytes("$installPath\omni.ja")
|
|
$hexString = [System.BitConverter]::ToString($bytes)
|
|
$offset = $hexString.IndexOf("3F-20-22-68-74-74-70-73-3A-2F-2F-66-69-72-65-66-6F-78-2E-73-65-74-74-69-6E-67-73-2E-73-65-72-76-69-63-65-73-2E-6D-6F-7A-69-6C-6C-61-2E-63-6F")
|
|
if ($offset -gt -1) {
|
|
$offset = $offset/3
|
|
For ($i=3; $i -le 50; $i++) {
|
|
$bytes[$offset+$i] = 32
|
|
}
|
|
[System.IO.File]::WriteAllBytes("$installPath\omni2.ja", $bytes)
|
|
Remove-Item -Path $installPath\omni.ja -Force
|
|
Rename-Item -Path $installPath\omni2.ja omni.ja
|
|
}
|
|
|
|
Write-Output "Copy librewolf settings"
|
|
$scriptPath = Split-Path -Path $MyInvocation.MyCommand.Path
|
|
Copy-Item "$scriptPath\settings\*" -Destination "$installPath" -Recurse -Force
|
|
|
|
Write-Output "Enjoy"
|