Files
ObsidianHome/小鱼/闲鱼消息通知/launch-edge.ps1
T

48 lines
1.6 KiB
PowerShell
Raw Normal View History

2026-11-09 09:18:58 +08:00
param(
[int]$Port = 9222,
[string]$StartUrl = "https://seller.goofish.com/"
)
$ErrorActionPreference = "Stop"
$candidates = @(
"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe",
"C:\Program Files\Microsoft\Edge\Application\msedge.exe"
)
$edge = $candidates | Where-Object { Test-Path $_ } | Select-Object -First 1
if (-not $edge) { Write-Host "Edge not found. Edit the path in launch-edge.ps1."; exit 1 }
$profileDir = Join-Path $PSScriptRoot "edge-profile"
New-Item -ItemType Directory -Force -Path $profileDir | Out-Null
# A dedicated --user-data-dir is required: Edge 136+ ignores the debug port on the default profile.
$args = @(
"--remote-debugging-port=$Port",
"--user-data-dir=$profileDir",
"--no-first-run",
"--no-default-browser-check",
"--disable-features=Translate",
$StartUrl
)
$running = Get-CimInstance Win32_Process -Filter "Name = 'msedge.exe'" -ErrorAction SilentlyContinue |
Where-Object { $_.CommandLine -like "*--remote-debugging-port=$Port*" }
if ($running) {
Write-Host "Watcher Edge already running on port $Port."
} else {
Start-Process -FilePath $edge -ArgumentList $args
Write-Host "Edge launched on debug port $Port (profile: $profileDir)"
}
Start-Sleep -Seconds 3
try {
$v = Invoke-WebRequest -Uri "http://127.0.0.1:$Port/json/version" -UseBasicParsing -TimeoutSec 5
Write-Host "Debug endpoint OK:"
Write-Host $v.Content
} catch {
Write-Host "Debug endpoint not reachable yet: $($_.Exception.Message)"
}
Write-Host ""
Write-Host "NEXT: log in to Goofish in this window, open the MESSAGES page, keep the tab open."