# Foxhand — helper installer for Windows. In PowerShell: # irm https://foxhand.pages.dev/download/ps | iex # Downloads the right foxhand-host .exe and registers it with Firefox (per user, no admin). & { $ErrorActionPreference = 'Stop' $ProgressPreference = 'SilentlyContinue' # the progress bar makes Invoke-WebRequest very slow on PowerShell 5.1 [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 $base = if ($env:FOXHAND_BASE) { $env:FOXHAND_BASE } elseif ($env:WEBMCP_BASE) { $env:WEBMCP_BASE } else { 'https://foxhand.pages.dev/download/0.5.7' } $arch = if ($env:PROCESSOR_ARCHITECTURE -eq 'ARM64' -or $env:PROCESSOR_ARCHITEW6432 -eq 'ARM64') { 'arm64' } else { 'x64' } $name = "foxhand-host-windows-$arch.exe" $tmp = Join-Path ([IO.Path]::GetTempPath()) ("foxhand-" + [guid]::NewGuid().ToString('N')) New-Item -ItemType Directory -Path $tmp | Out-Null $exe = Join-Path $tmp $name try { Write-Host "Downloading $name ..." Invoke-WebRequest -UseBasicParsing -Uri "$base/$name" -OutFile $exe # Refuse to run anything we can't verify. try { $sums = (Invoke-WebRequest -UseBasicParsing -Uri "$base/SHA256SUMS").Content } catch { throw "Couldn't download SHA256SUMS to verify $name. Not installing." } if ($sums -is [byte[]]) { $sums = [Text.Encoding]::UTF8.GetString($sums) } $want = $null foreach ($l in ($sums -split "`r?`n")) { $f = $l.Trim() -split '\s+', 2 if ($f.Count -eq 2 -and ($f[1] -eq $name -or $f[1] -eq "*$name")) { $want = $f[0].ToLower(); break } } if (-not $want) { throw "SHA256SUMS has no entry for $name. Not installing." } $got = (Get-FileHash -Algorithm SHA256 $exe).Hash.ToLower() if ($want -ne $got) { throw "Checksum mismatch for $name - download corrupted or tampered with. Not installing." } & $exe install if ($LASTEXITCODE) { throw "Install failed (exit $LASTEXITCODE)." } } finally { Remove-Item -Recurse -Force $tmp -ErrorAction SilentlyContinue } }