跳到主要内容

Epic 每周免费游戏领取

收藏0

在 Epic Games 商城领取本周免费游戏,覆盖浏览器没装自动化扩展的环境(CDP 接管真实 profile / 扩展浏览器 / 内置兜底)

让 AI 安装

seell最新版本 0.1.0更新于 2026-11-20下载 0 次

scripts/cdp_launch.ps1

3.2 KB
1# Launch a real browser with remote debugging on an isolated profile, WITHOUT copying
2# the user's login cookies (copying Chrome cookies fails because they are DPAPI-bound
3# to the original profile path and the app-bound encryption key). Instead this script
4# starts the browser with its REAL default profile so the existing Epic login is kept.
5#
6# IMPORTANT PRECONDITION: all browser processes for the chosen browser must be closed,
7# otherwise a new --remote-debugging-port launch is ignored (the request is forwarded
8# to the running instance) and no debug endpoint opens. This script closes them for you.
9#
10# Usage:
11# powershell -NoProfile -ExecutionPolicy Bypass -File cdp_launch.ps1 -Browser edge
12# powershell -NoProfile -ExecutionPolicy Bypass -File cdp_launch.ps1 -Browser chrome -Port 9223
13#
14# After launch, verify: curl http://127.0.0.1:9222/json/version
15
16param(
17 [ValidateSet('edge','chrome')]
18 [string]$Browser = 'edge',
19 [int]$Port = 9222,
20 [string]$ExtraArgs = ''
21)
22
23$ErrorActionPreference = 'Stop'
24
25function Get-BrowserInfo {
26 param([string]$Kind)
27 if ($Kind -eq 'edge') {
28 return @{
29 Proc = 'msedge'
30 ExeCandidates = @(
31 'C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe',
32 'C:\Program Files\Microsoft\Edge\Application\msedge.exe'
33 )
34 UserData = Join-Path $env:LOCALAPPDATA 'Microsoft\Edge\User Data'
35 }
36 } else {
37 return @{
38 Proc = 'chrome'
39 ExeCandidates = @(
40 'C:\Program Files\Google\Chrome\Application\chrome.exe',
41 'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe',
42 (Join-Path $env:LOCALAPPDATA 'Google\Chrome\Application\chrome.exe')
43 )
44 UserData = Join-Path $env:LOCALAPPDATA 'Google\Chrome\User Data'
45 }
46 }
47}
48
49$info = Get-BrowserInfo -Kind $Browser
50$exe = $info.ExeCandidates | Where-Object { Test-Path $_ } | Select-Object -First 1
51if (-not $exe) { throw "Browser executable not found for $Browser" }
52if (-not (Test-Path $info.UserData)) { throw "User Data dir not found: $($info.UserData)" }
53
54Write-Host "Browser : $exe"
55Write-Host "Profile : $($info.UserData)"
56Write-Host "Port : $Port"
57
58# Close all running instances so the debug port actually binds.
59$running = Get-Process -Name $info.Proc -ErrorAction SilentlyContinue
60if ($running) {
61 Write-Host "Closing $($running.Count) running $($Browser) process(es) to free the profile lock..."
62 Stop-Process -Name $info.Proc -Force -ErrorAction SilentlyContinue
63 Start-Sleep -Seconds 3
64}
65
66$argList = @(
67 "--remote-debugging-port=$Port",
68 "--user-data-dir=`"$($info.UserData)`"",
69 '--no-first-run',
70 '--no-default-browser-check',
71 '--restore-last-session',
72 'about:blank'
73)
74if ($ExtraArgs) { $argList += $ExtraArgs }
75
76Start-Process -FilePath $exe -ArgumentList $argList
77Start-Sleep -Seconds 6
78
79try {
80 $v = Invoke-RestMethod -Uri "http://127.0.0.1:$Port/json/version" -TimeoutSec 5
81 Write-Host "CDP_READY Browser=$($v.Browser)"
82 Write-Host "CDP_WS=$($v.webSocketDebuggerUrl)"
83} catch {
84 Write-Host "CDP_FAIL: $($_.Exception.Message)"
85 Write-Host 'Check: profile lock still held, or enterprise policy disabled remote debugging.'
86 exit 1
87}

文件内容是平台检查时读出的文本,只供查看。平台不会运行包里的任何脚本或程序。