# my-extension installer / updater (Windows). # # Easiest: paste this one line into PowerShell — # irm https://pats-toolbox.web.app/update.ps1 | iex # # First run downloads the latest build to %USERPROFILE%\my-extension and tells you how to load # it; later runs pull a newer build if there is one. Either way you finish by clicking Reload in # chrome://extensions (Chrome can't auto-reload an unpacked extension). $ErrorActionPreference = "Stop" $Base = "https://pats-toolbox.web.app" $Dir = Join-Path $HOME "my-extension" Write-Host "Checking for updates..." try { $info = Invoke-RestMethod -Uri "$Base/version.json" -ErrorAction Stop } catch { Write-Host "Couldn't reach the update server: $($_.Exception.Message)" -ForegroundColor Red return } if (-not $info.url) { Write-Host "No build has been published yet. Ask Pat." -ForegroundColor Yellow return } $verFile = Join-Path $Dir ".version" $local = if (Test-Path $verFile) { (Get-Content $verFile -Raw).Trim() } else { "" } $firstInstall = [string]::IsNullOrEmpty($local) if ($local -eq $info.version) { Write-Host "Already up to date (v$($info.version))." -ForegroundColor Green return } Write-Host "Downloading v$($info.version)..." New-Item -ItemType Directory -Force -Path $Dir | Out-Null $tmp = Join-Path $env:TEMP "my-extension-$($info.version).zip" Invoke-WebRequest -Uri $info.url -OutFile $tmp Expand-Archive -Path $tmp -DestinationPath $Dir -Force Remove-Item $tmp -Force Set-Content -Path $verFile -Value $info.version Write-Host "" Write-Host "Installed v$($info.version) to $Dir" -ForegroundColor Green if ($firstInstall) { Write-Host "First time setup:" -ForegroundColor Cyan Write-Host " 1. Open chrome://extensions" Write-Host " 2. Turn on 'Developer mode' (top right)" Write-Host " 3. Click 'Load unpacked' and select: $Dir" Write-Host " 4. Click the extension icon and sign in (ask Pat for an invite)" } else { Write-Host "Now open chrome://extensions and click Reload on my-extension." -ForegroundColor Cyan }