@liang-hz/agent-in-chrome 0.55.2 → 0.55.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +3 -3
- package/README.md +3 -3
- package/extension/manifest.json +1 -1
- package/extension/sw.js +91 -25
- package/mcp/agent-identity.mjs +293 -61
- package/mcp/cdp/browser-launch.mjs +160 -48
- package/mcp/server.mjs +4 -22
- package/native-host/host.mjs +28 -0
- package/package.json +1 -1
- package/scripts/borrow-login.mjs +6 -2
- package/scripts/e2e-sweep.mjs +3 -4
- package/scripts/e2e.mjs +77 -36
- package/scripts/install.mjs +70 -4
- package/scripts/launcher-spawn.mjs +22 -0
- package/scripts/pack-crx.mjs +2 -1
- package/scripts/test-agents.mjs +55 -22
- package/scripts/test-e2e-sweep.mjs +7 -2
- package/scripts/test-identity.mjs +307 -84
- package/scripts/test-install-skill.mjs +37 -2
- package/scripts/test-protocol.mjs +102 -1
- package/scripts/test-security.mjs +38 -17
- package/scripts/test-sw.mjs +103 -18
package/README.en.md
CHANGED
|
@@ -42,7 +42,7 @@ Agent in Chrome connects an AI agent (Claude Code, Claude Desktop, Trae, Codex,
|
|
|
42
42
|
| Modal overlay detection (including login walls with no ARIA role) | ✅ | ❌ | ❌ | ❌¹¹ | ❌¹¹ |
|
|
43
43
|
| Element pixel coordinates + top-level coordinates across frames | ✅ | ❌ | ❌ | ❌¹¹ | ❌¹¹ |
|
|
44
44
|
|
|
45
|
-
<sup>1</sup> `--extension` mode only (Chrome/Edge, requires installing their extension); the default mode is an isolated profile. <sup>2</sup> `--autoConnect` only (Chrome 144+, requires manually opening the gate in `chrome://inspect`, which exposes every window in that profile). <sup>3</sup> Either connect over CDP to a Chrome already started with a debug port, or use its bundled browser (isolated profile, no user login state). <sup>4</sup> A separate Chromium fork; login state comes from import rather than live borrowing — `ego-browser import` re-imports from Chrome/Edge/Brave (extensions included). <sup>5</sup> Windows supports extension mode
|
|
45
|
+
<sup>1</sup> `--extension` mode only (Chrome/Edge, requires installing their extension); the default mode is an isolated profile. <sup>2</sup> `--autoConnect` only (Chrome 144+, requires manually opening the gate in `chrome://inspect`, which exposes every window in that profile). <sup>3</sup> Either connect over CDP to a Chrome already started with a debug port, or use its bundled browser (isolated profile, no user login state). <sup>4</sup> A separate Chromium fork; login state comes from import rather than live borrowing — `ego-browser import` re-imports from Chrome/Edge/Brave (extensions included). <sup>5</sup> Windows supports both extension mode and CLI/headless mode; the Linux path is written but unverified. <sup>6</sup> Playwright's `--secrets` and DevTools MCP's `--redactNetworkHeaders` are both opt-in and off by default, and the latter doesn't cover bodies. Measured: Playwright's `browser_network_request` filters Cookie and Set-Cookie out of request headers by default (full raw headers require run_code). <sup>7</sup> Solid placeholder mechanism on the input side; no redaction on network responses. <sup>8</sup> `browser_run_code_unsafe` describes itself as RCE-equivalent and is on by default. <sup>9</sup> ego has no native network helpers, but its `page.cdp()` escape hatch reaches everything (measured on 0.5.0.28): raw headers live in CDP ExtraInfo events and need manual pairing by requestId, WS frames are capturable, mocking/throttling/tracing all doable; cookies stay plaintext throughout, no redaction. <sup>10</sup> ego and browser-use both make code their primary interface (heredoc / Python) — arbitrary code execution is by design. <sup>11</sup> Measured: overlays without ARIA roles don't surface in ego's semantic snapshot (flattened into the same tree, no modality marker; only a click error names the intercepting element); its snapshot carries no element pixel coordinates, and top-level coordinates across frames must be computed by hand. browser-use filters buttons under an overlay out of its element list entirely and its coordinate clicks can falsely report success; its observation output likewise carries no pixel coordinates. <sup>12</sup> Measured: Playwright MCP 0.0.80 ships no mocking/throttling/tracing tools at all (the `browser_route`/tracing tools in its README were not released with this version), and it has no native WS frames, initiator stacks, or curl export either; all of these are reachable through the `browser_run_code_unsafe` escape hatch.
|
|
46
46
|
|
|
47
47
|
**Speed** (same test page containing a cross-origin iframe, equivalent fresh profiles, medians; browser-use is omitted because it requires manual per-run authorization in `chrome://inspect` and can't complete the same flow unattended):
|
|
48
48
|
|
|
@@ -72,7 +72,7 @@ Agent in Chrome connects an AI agent (Claude Code, Claude Desktop, Trae, Codex,
|
|
|
72
72
|
|
|
73
73
|
## Quick start
|
|
74
74
|
|
|
75
|
-
> Requires Node.js 18+ and Chrome 125+ (or Edge / Brave / Vivaldi / any Chromium-based browser). macOS is fully tested; Windows extension mode
|
|
75
|
+
> Requires Node.js 18+ and Chrome 125+ (or Edge / Brave / Vivaldi / any Chromium-based browser). macOS is fully tested; Windows extension mode and CLI/headless mode are both supported (named pipes + registry + `.bat` launcher; CLI-mode process management goes through the PowerShell process table); the Linux path is written but unverified — see [Known limitations](#known-limitations).
|
|
76
76
|
>
|
|
77
77
|
> 18 really is enough, and that's measured: on Node 18.20.8 `check` passes end to end, the MCP server
|
|
78
78
|
> boots and lists all 37 tools. The one exception is CLI mode's `AGENT_IN_CHROME_KEEP=1`, which needs
|
|
@@ -340,7 +340,7 @@ follow the npm package.
|
|
|
340
340
|
- **Cross-origin iframes under a CSS transform** (rotate/scale/skew) can't have their coordinates computed, so elements inside them can't be clicked; `read_page` marks them `coords: "未知"` ("unknown" — the field is emitted in Chinese). Work around it by opening that URL directly with `browser_new_tab`.
|
|
341
341
|
- **No performance / a11y / SEO audit scores** — `npx lighthouse <url> --view` is one command away and carries Chrome's own scoring; in extension mode we drive your everyday Chrome, which has no debugging port, so building our own would only produce a worse Lighthouse. **Division of labour**: scores come from `npx lighthouse`; we cover what it can't reach — pages behind a login, the screen that only appears after you open some panel, and the headers and bodies of one specific request.
|
|
342
342
|
- **There is no dedicated drag tool** — drag sliders, drag-and-drop reordering, and canvas gestures are done with `browser_batch` chaining a series of `browser_cdp` `Input.dispatchMouseEvent` calls (recipe in [skills/agent-in-chrome/references/actions-and-waits.md](skills/agent-in-chrome/references/actions-and-waits.md#拖拽--滑块没有-drag-工具), under "拖拽 / 滑块"). Synthesizing events via `eval` dispatches `isTrusted: false`, which real captchas reject.
|
|
343
|
-
- **Platforms**: macOS is fully tested. **Windows extension mode is supported** (registry + named pipes + a `.bat` launcher; the bridge's first line of defense becomes the token rather than directory permissions — see the `bridgeEndpoint` comment in `mcp/token.mjs`). Windows CLI/headless mode (`AGENT_IN_CHROME_LAUNCH=1`) is
|
|
343
|
+
- **Platforms**: macOS is fully tested. **Windows extension mode is supported** (registry + named pipes + a `.bat` launcher; the bridge's first line of defense becomes the token rather than directory permissions — see the `bridgeEndpoint` comment in `mcp/token.mjs`). Windows CLI/headless mode (`AGENT_IN_CHROME_LAUNCH=1`) is supported — the three process-management data sources were ported (see `mcp/cdp/browser-launch.mjs`); initial real-machine testing passed, long-run feedback welcome. The Linux path is written but unverified. PRs welcome.
|
|
344
344
|
|
|
345
345
|
---
|
|
346
346
|
|
package/README.md
CHANGED
|
@@ -42,7 +42,7 @@ Agent in Chrome 把 AI agent(Claude Code、Claude Desktop、Trae、Codex……
|
|
|
42
42
|
| 模态浮层检出(含无 ARIA 角色的登录墙) | ✅ | ❌ | ❌ | ❌¹¹ | ❌¹¹ |
|
|
43
43
|
| 元素像素坐标 + 跨源帧顶层坐标 | ✅ | ❌ | ❌ | ❌¹¹ | ❌¹¹ |
|
|
44
44
|
|
|
45
|
-
<sup>1</sup> 仅 `--extension` 模式(Chrome/Edge,需装其扩展);默认模式是独立 profile。 <sup>2</sup> 仅 `--autoConnect`(Chrome 144+,需在 `chrome://inspect` 手动开闸,该 profile 全部窗口暴露)。 <sup>3</sup> 二选一:CDP 直连已开调试端口的 Chrome,或用自带浏览器(独立 profile,不带用户登录态)。 <sup>4</sup> 独立 Chromium 分叉浏览器;登录态靠导入而非实时借用——`ego-browser import` 可从 Chrome/Edge/Brave 重复导入(扩展一并迁入)。 <sup>5</sup> Windows
|
|
45
|
+
<sup>1</sup> 仅 `--extension` 模式(Chrome/Edge,需装其扩展);默认模式是独立 profile。 <sup>2</sup> 仅 `--autoConnect`(Chrome 144+,需在 `chrome://inspect` 手动开闸,该 profile 全部窗口暴露)。 <sup>3</sup> 二选一:CDP 直连已开调试端口的 Chrome,或用自带浏览器(独立 profile,不带用户登录态)。 <sup>4</sup> 独立 Chromium 分叉浏览器;登录态靠导入而非实时借用——`ego-browser import` 可从 Chrome/Edge/Brave 重复导入(扩展一并迁入)。 <sup>5</sup> Windows 插件模式与 CLI/headless 模式均已支持;Linux 路径已写未验证。 <sup>6</sup> Playwright 的 `--secrets` 与 DevTools 的 `--redactNetworkHeaders` 均为可选开关且默认关闭,后者不覆盖 body。实测 Playwright 的 `browser_network_request` 默认过滤请求头中的 Cookie 与 Set-Cookie(要完整原始头得走 run_code)。 <sup>7</sup> 输入侧占位符机制完备;网络返回值无打码。 <sup>8</sup> `browser_run_code_unsafe` 自述 RCE-equivalent,默认开启。 <sup>9</sup> ego 无网络类原生 helper,但 `page.cdp()` 逃生舱实测可达:原始头在 CDP ExtraInfo 事件里、需按 requestId 自行配对,WS 帧可抓,mock/限速/trace 均可做;全程 Cookie 明文无打码。 <sup>10</sup> ego 与 browser-use 的主接口都是代码(heredoc / Python),任意代码执行是设计使然。 <sup>11</sup> 实测无 ARIA 浮层不进 ego 的语义快照(与正文平铺同树、无模态标记,仅点击报错会点名遮挡元素),快照不含元素像素坐标,跨源帧顶层坐标需自行计算;browser-use 的元素表则会把遮罩下按钮整个过滤掉、坐标点击会误报成功,观察输出同样不含像素坐标。 <sup>12</sup> 实测 Playwright MCP 0.0.80 包内并无 mock/限速/trace 类工具(其 README 文档所载 `browser_route`/tracing 未随该版本发布),WS 帧、发起调用栈、curl 导出也无原生工具;均可用 `browser_run_code_unsafe` 逃生舱补做。
|
|
46
46
|
|
|
47
47
|
**速度**(同一含跨源 iframe 的测试页、对等全新 profile、中位数;browser-use 因需人工在 `chrome://inspect` 逐次授权,无法无人值守完成同一流程,未列入):
|
|
48
48
|
|
|
@@ -72,7 +72,7 @@ Agent in Chrome 把 AI agent(Claude Code、Claude Desktop、Trae、Codex……
|
|
|
72
72
|
|
|
73
73
|
## 快速开始
|
|
74
74
|
|
|
75
|
-
> 需要 Node.js 18+ 和 Chrome 125+(或 Edge / Brave / Vivaldi 等 Chromium 系)。目前 macOS 实测完整;Windows
|
|
75
|
+
> 需要 Node.js 18+ 和 Chrome 125+(或 Edge / Brave / Vivaldi 等 Chromium 系)。目前 macOS 实测完整;Windows 插件模式与 CLI/headless 模式均已支持(命名管道 + 注册表 + .bat 启动器;CLI 模式的进程管理走 PowerShell 进程表);Linux 路径已写待验证(见[已知限制](#已知限制))。
|
|
76
76
|
>
|
|
77
77
|
> 18 够用是实测过的:Node 18.20.8 上 `check` 全过、MCP server 起得来、37 个工具都在。唯一的例外在
|
|
78
78
|
> CLI 模式的 `AGENT_IN_CHROME_KEEP=1` 那条路上——它要 Node 的全局 `WebSocket`,**Node 22 才有**;
|
|
@@ -333,7 +333,7 @@ npx @liang-hz/agent-in-chrome@latest update
|
|
|
333
333
|
- **跨源 iframe 被 CSS 变换(旋转/缩放/斜切)过时坐标算不出来**,里面的元素点不了,`read_page` 会标 `coords:"未知"`——改用 `browser_new_tab` 直接打开那个地址。
|
|
334
334
|
- **不做性能 / a11y / SEO 审计打分**——那类需求 `npx lighthouse <url> --view` 一条命令就跑完,还带 Chrome 官方的评分口径;插件模式下我们挂的是你自己那个没有调试端口的 Chrome,硬做只会做出一个更差的 Lighthouse。**分工**:跑分交给 `npx lighthouse`,我们负责它进不去的地方——需要登录态的页面、点开某个面板之后才出现的那一屏、以及看具体某个请求的头和响应体。
|
|
335
335
|
- **没有专门的拖拽工具**——拖滑块、拖放排序、画布手势用 `browser_batch` 串一列 `browser_cdp` 的 `Input.dispatchMouseEvent`(配方在 [skills/agent-in-chrome/references/actions-and-waits.md](skills/agent-in-chrome/references/actions-and-waits.md#拖拽--滑块没有-drag-工具));用 `eval` 合成事件派的是 `isTrusted: false`,真验证码不认。
|
|
336
|
-
- **平台**:macOS 完整实测。**Windows
|
|
336
|
+
- **平台**:macOS 完整实测。**Windows 插件模式与 CLI/headless 模式均已支持**(插件模式:注册表 + 命名管道 + `.bat` 启动器,桥接第一道防线由目录权限换成令牌,详见 `mcp/token.mjs` 的 bridgeEndpoint 注释;CLI 模式:进程表/占用者/收场三处数据源走 Windows 对应物,见 `mcp/cdp/browser-launch.mjs`)。CLI 模式在 Windows 上初测通过,长跑反馈欢迎开 issue。Linux 路径已写未验证。欢迎 PR。
|
|
337
337
|
|
|
338
338
|
---
|
|
339
339
|
|
package/extension/manifest.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"manifest_version": 3,
|
|
3
3
|
"name": "Agent in Chrome",
|
|
4
|
-
"version": "0.55.
|
|
4
|
+
"version": "0.55.5",
|
|
5
5
|
"description": "让 AI agent 操作你已经登录的那个 Chrome 标签页,复用你现有的登录态。 · by Liang (liangai.org)",
|
|
6
6
|
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA6Jtdbvmd/bUVxIn9YXdLBw9idVVJwXfCHCGYkPZ0Wp8YcIRBPj10a6L4tTF6h78cLjvgowiZmCAdiUZekjBdPrKJT9nhkGIX9yER3DfRpk0NOkTxum95Eb/K6Y4U/3q1TbhFkebBFZAcPG6O5/Nh8qnTiEuN/EFB3PqlODh4UInLxYbGsHV5vp4WXxfGOt1fF3VkekS7T1gPndijbBBeriv61eb7KguMNrEbid+p07kBPDZ6D3mp4JT6eqsfoPgK01QISBMrJgou0ra9Z4t+bhPvsoe2xAkr8X5iojSAVKUs1UKyKueV2WJ1JPqdAFIRckWwZ4sqEpk/LenKFljTiQIDAQAB",
|
|
7
7
|
"minimum_chrome_version": "125",
|
package/extension/sw.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
// 所有 browser_* 工具的实现都在这个文件里(工具表见 TOOLS)。
|
|
10
10
|
|
|
11
11
|
const HOST_NAME = "org.liangai.agent_in_chrome";
|
|
12
|
-
const VERSION = "0.55.
|
|
12
|
+
const VERSION = "0.55.5";
|
|
13
13
|
/* 这个 service worker 实例是什么时候起来的(= 磁盘上的代码是什么时候读进来的),见 hello */
|
|
14
14
|
const SW_BOOTED_AT = Date.now();
|
|
15
15
|
/* agent 开的标签页统一收进这一组,跟用户自己的标签页视觉隔离 */
|
|
@@ -2978,26 +2978,44 @@ async function wakeTab(tabId) {
|
|
|
2978
2978
|
* 探针(inPage)走的都是单帧默认注入——不一起防住,卡点只是往后挪了一步。
|
|
2979
2979
|
*/
|
|
2980
2980
|
async function injectStaged(opts) {
|
|
2981
|
-
const
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
2981
|
+
const tabId = opts.target?.tabId;
|
|
2982
|
+
let wakePending = null;
|
|
2983
|
+
const pulseWake = () => {
|
|
2984
|
+
if (tabId == null) return Promise.resolve();
|
|
2985
|
+
if (!wakePending) {
|
|
2986
|
+
wakePending = wakeTab(tabId)
|
|
2987
|
+
.catch(() => {})
|
|
2988
|
+
.finally(() => {
|
|
2989
|
+
wakePending = null;
|
|
2990
|
+
});
|
|
2991
|
+
}
|
|
2992
|
+
return wakePending;
|
|
2993
|
+
};
|
|
2994
|
+
const heartbeat = tabId == null ? null : setInterval(() => void pulseWake(), EVAL_WAKE_MS);
|
|
2995
|
+
try {
|
|
2996
|
+
const idle = chrome.scripting.executeScript(opts);
|
|
2997
|
+
const PENDING = {};
|
|
2998
|
+
let timer;
|
|
2999
|
+
const first = await Promise.race([
|
|
3000
|
+
idle,
|
|
3001
|
+
new Promise((r) => {
|
|
3002
|
+
timer = setTimeout(() => r(PENDING), IDLE_INJECT_MS);
|
|
3003
|
+
}),
|
|
3004
|
+
]).finally(() => clearTimeout(timer));
|
|
3005
|
+
if (first !== PENDING) return { res: first, degraded: false };
|
|
3006
|
+
Promise.resolve(idle).catch(() => {});
|
|
3007
|
+
await pulseWake();
|
|
3008
|
+
const res = await deadline(
|
|
3009
|
+
chrome.scripting.executeScript({ ...opts, injectImmediately: true }),
|
|
3010
|
+
IMMEDIATE_INJECT_MS,
|
|
3011
|
+
`页面注入 ${IDLE_INJECT_MS + IMMEDIATE_INJECT_MS}ms 没有回执(等帧就绪、立即注入两条路都试过了):` +
|
|
3012
|
+
`这张标签页的注入路卡死了,重试大概率还是它。用 browser_new_tab 开一张新的、地址照旧,在新页上重来;` +
|
|
3013
|
+
`这张页也没全废——browser_eval 走 CDP,仍然读得到东西。`
|
|
3014
|
+
);
|
|
3015
|
+
return { res, degraded: true };
|
|
3016
|
+
} finally {
|
|
3017
|
+
if (heartbeat !== null) clearInterval(heartbeat);
|
|
3018
|
+
}
|
|
3001
3019
|
}
|
|
3002
3020
|
|
|
3003
3021
|
/*
|
|
@@ -3162,7 +3180,7 @@ function cursorAgent(op, A) {
|
|
|
3162
3180
|
A = {
|
|
3163
3181
|
x: Math.round((window.innerWidth || 0) / 2),
|
|
3164
3182
|
y: Math.round((window.innerHeight || 0) * 0.4),
|
|
3165
|
-
travelMs:
|
|
3183
|
+
travelMs: 0,
|
|
3166
3184
|
kind: "move",
|
|
3167
3185
|
idle: true,
|
|
3168
3186
|
};
|
|
@@ -3288,7 +3306,8 @@ function cursorAgent(op, A) {
|
|
|
3288
3306
|
|
|
3289
3307
|
const kind = String((A && A.kind) || "move");
|
|
3290
3308
|
const label = A && A.label ? String(A.label).slice(0, 40) : "";
|
|
3291
|
-
const travel =
|
|
3309
|
+
const travel =
|
|
3310
|
+
A && A.travelMs != null ? Math.max(0, Math.min(600, Number(A.travelMs) || 0)) : 0;
|
|
3292
3311
|
|
|
3293
3312
|
w.className = "w";
|
|
3294
3313
|
void w.offsetWidth;
|
|
@@ -3947,10 +3966,21 @@ function pageAgent(op, arg) {
|
|
|
3947
3966
|
let b = box(el);
|
|
3948
3967
|
let scrolled = false;
|
|
3949
3968
|
const offscreen = (r) => r.x + r.w <= 0 || r.y + r.h <= 0 || r.x >= vw || r.y >= vh;
|
|
3969
|
+
const SLIVER_MIN_PX = 6;
|
|
3970
|
+
const sliver = (r) => {
|
|
3971
|
+
if (r.x < 0 && r.x + r.w > 0 && r.x + r.w < SLIVER_MIN_PX) return true;
|
|
3972
|
+
if (r.x < vw && r.x + r.w > vw && vw - r.x < SLIVER_MIN_PX) return true;
|
|
3973
|
+
if (r.y < 0 && r.y + r.h > 0 && r.y + r.h < SLIVER_MIN_PX) return true;
|
|
3974
|
+
if (r.y < vh && r.y + r.h > vh && vh - r.y < SLIVER_MIN_PX) return true;
|
|
3975
|
+
return false;
|
|
3976
|
+
};
|
|
3950
3977
|
if (el.scrollIntoView) {
|
|
3951
3978
|
if (offscreen(b)) {
|
|
3952
3979
|
scrolled = scrollIn(el, "center");
|
|
3953
3980
|
b = box(el);
|
|
3981
|
+
} else if (sliver(b)) {
|
|
3982
|
+
scrolled = scrollIn(el, "center") || scrolled;
|
|
3983
|
+
b = box(el);
|
|
3954
3984
|
} else {
|
|
3955
3985
|
const c0 = clipperOf(el);
|
|
3956
3986
|
if (c0 && c0.canScroll) {
|
|
@@ -6986,6 +7016,13 @@ function markFileInputInPage(ref, selector, token) {
|
|
|
6986
7016
|
fired[token] = { change: false, input: false };
|
|
6987
7017
|
const onChange = () => {
|
|
6988
7018
|
fired[token].change = true;
|
|
7019
|
+
try {
|
|
7020
|
+
fired[token].filesAtChange = [...el.files].map((f) => ({
|
|
7021
|
+
name: f.name,
|
|
7022
|
+
size: f.size,
|
|
7023
|
+
type: f.type || "",
|
|
7024
|
+
}));
|
|
7025
|
+
} catch {}
|
|
6989
7026
|
};
|
|
6990
7027
|
const onInput = () => {
|
|
6991
7028
|
fired[token].input = true;
|
|
@@ -7034,11 +7071,28 @@ function readFileInputInPage(token) {
|
|
|
7034
7071
|
};
|
|
7035
7072
|
el = walk(document);
|
|
7036
7073
|
}
|
|
7037
|
-
if (!el)
|
|
7074
|
+
if (!el) {
|
|
7075
|
+
const caught = fired.filesAtChange;
|
|
7076
|
+
if (caught) {
|
|
7077
|
+
try {
|
|
7078
|
+
delete regs[token];
|
|
7079
|
+
} catch {}
|
|
7080
|
+
try {
|
|
7081
|
+
delete firedAll[token];
|
|
7082
|
+
} catch {}
|
|
7083
|
+
return {
|
|
7084
|
+
files: caught,
|
|
7085
|
+
count: caught.length,
|
|
7086
|
+
changeFired: nativeChange,
|
|
7087
|
+
inputFired: nativeInput,
|
|
7088
|
+
elementReplaced: true,
|
|
7089
|
+
};
|
|
7090
|
+
}
|
|
7038
7091
|
return {
|
|
7039
7092
|
error:
|
|
7040
7093
|
"上传目标在设置过程中从页面上消失了(页面可能重新渲染或导航过)。重新 browser_read_page 后再试一次。",
|
|
7041
7094
|
};
|
|
7095
|
+
}
|
|
7042
7096
|
|
|
7043
7097
|
const files = [];
|
|
7044
7098
|
try {
|
|
@@ -9145,6 +9199,17 @@ const TOOLS = {
|
|
|
9145
9199
|
sid
|
|
9146
9200
|
) {
|
|
9147
9201
|
const tabId = await withTarget(sid, wantTab);
|
|
9202
|
+
try {
|
|
9203
|
+
const tab = await chrome.tabs.get(tabId);
|
|
9204
|
+
const win = await chrome.windows.get(tab.windowId);
|
|
9205
|
+
if (win.state === "minimized") {
|
|
9206
|
+
throw new Error(
|
|
9207
|
+
"Chrome 窗口是最小化的:最小化的窗口不产帧,截图会一直挂到超时。先把窗口恢复(点任务栏图标即可,不必切过去)再试。"
|
|
9208
|
+
);
|
|
9209
|
+
}
|
|
9210
|
+
} catch (e) {
|
|
9211
|
+
if (/最小化的窗口/.test(String(e?.message || e))) throw e;
|
|
9212
|
+
}
|
|
9148
9213
|
const given = [region ? "region" : null, ref ? "ref" : null, selector ? "selector" : null, fullPage ? "fullPage" : null].filter(Boolean);
|
|
9149
9214
|
if (given.length > 1) {
|
|
9150
9215
|
throw new Error(`region / ref / selector / fullPage 只能给一个,收到了 ${given.join(" 和 ")},什么都没截。`);
|
|
@@ -10776,6 +10841,7 @@ const TOOLS = {
|
|
|
10776
10841
|
},
|
|
10777
10842
|
changeFired: back.changeFired,
|
|
10778
10843
|
changeDispatchedManually: back.changeDispatchedManually || undefined,
|
|
10844
|
+
elementReplaced: back.elementReplaced || undefined,
|
|
10779
10845
|
hint: back.changeFired
|
|
10780
10846
|
? undefined
|
|
10781
10847
|
: "页面没有收到 change 事件,说明它可能并不监听这个输入框。检查上传是否真的开始了。",
|
|
@@ -10950,7 +11016,7 @@ async function applyViewport(tabId, vp, warnings) {
|
|
|
10950
11016
|
: `按 ${got.innerWidth} 这个宽度去算坐标和断点,别按你给的那个。`)
|
|
10951
11017
|
);
|
|
10952
11018
|
}
|
|
10953
|
-
if (got.dpr
|
|
11019
|
+
if (Math.abs(Number(got.dpr) - Number(dsf)) > 0.001) warnings.push(`devicePixelRatio 实际是 ${got.dpr},不是你给的 ${dsf}。`);
|
|
10954
11020
|
return out;
|
|
10955
11021
|
}
|
|
10956
11022
|
|