dsh-web-fetch-playwright 0.1.1 → 0.2.2
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.md +27 -5
- package/README.zh-CN.md +27 -5
- package/dsh.plugin.json +1 -1
- package/lib/client.js +185 -105
- package/lib/index.js +362 -43
- package/lib/types/cdp-pool.d.ts +100 -0
- package/lib/types/client/card.d.ts +4 -3
- package/lib/types/client/controller.d.ts +12 -0
- package/lib/types/client/fields.d.ts +7 -1
- package/lib/types/client/form.d.ts +10 -0
- package/lib/types/client/locales.d.ts +1 -1
- package/lib/types/config.d.ts +62 -2
- package/lib/types/index.d.ts +4 -2
- package/lib/types/provider.d.ts +40 -10
- package/lib/types/types.d.ts +22 -1
- package/package.json +4 -3
- package/src/cdp-pool.ts +211 -0
- package/src/client/card.tsx +46 -17
- package/src/client/controller.ts +17 -1
- package/src/client/fields.module.css +12 -0
- package/src/client/fields.tsx +9 -3
- package/src/client/form.ts +23 -0
- package/src/client/locales.ts +12 -0
- package/src/config.ts +76 -2
- package/src/index.ts +9 -3
- package/src/provider.ts +220 -47
- package/src/types.ts +22 -1
package/README.md
CHANGED
|
@@ -12,9 +12,9 @@ A [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) (DSH) plug
|
|
|
12
12
|
- **Denoise pipeline** — Mozilla Readability extracts the article, DOMPurify removes layout/noise tags (nav, sidebar, footer, ads, forms), and Turndown with the GFM plugin converts to Markdown with the same style options as the shipped `tool-web` renderer.
|
|
13
13
|
- **Two backends** — launch a local Playwright browser, or drive an already-running browser over its DevTools Protocol (CDP) endpoint.
|
|
14
14
|
- **Browser resolution** — a configured path, a `playwright` CLI on `$PATH`, or the bundled `playwright-core`; CDP needs no local browser at all.
|
|
15
|
-
- **Isolated sessions** — every fetch
|
|
16
|
-
- **Live configuration** — a settings card (设置 → 插件 → 插件配置) edits the backend
|
|
17
|
-
- **Budget-aware** — per-fetch deadline (45s)
|
|
15
|
+
- **Isolated or profile sessions (CDP)** — every fetch is scoped to exactly one tab. Local launches close their browser per fetch; the CDP backend keeps **one shared connection** to the remote browser and each fetch opens a tab inside it, closed when done. By default that tab lives in the remote browser's **real profile** (its cookies, localStorage, and persistent logins apply — like `playwright-cli open`); unchecking *Share the browser context* switches to a throwaway isolated context per fetch.
|
|
16
|
+
- **Live configuration** — a settings card (设置 → 插件 → 插件配置) edits the backend, context mode, denoise toggle, and concurrency; changes apply to the next fetch without a restart.
|
|
17
|
+
- **Budget-aware** — per-fetch deadline (45s); concurrency is backend-priced (`maxConcurrency`, default 4 local browsers / **50 CDP tabs**; queued fetches fail fast with a retry hint after 20s instead of hanging); image/font/media subrequests aborted; body capped at 100k chars.
|
|
18
18
|
|
|
19
19
|
## How it works
|
|
20
20
|
|
|
@@ -61,12 +61,16 @@ After a bundle plugin is added to the profile layer stack, **restart `dsh web`**
|
|
|
61
61
|
|
|
62
62
|
The settings card (设置 → 插件 → 插件配置 → *Playwright 网页爬取*) edits the `web-fetch-playwright` settings section live:
|
|
63
63
|
|
|
64
|
+

|
|
65
|
+
|
|
64
66
|
| Field | Default | Description |
|
|
65
67
|
| --- | --- | --- |
|
|
66
68
|
| `backend` | `local` | Radio: *Local Playwright* or *Remote CDP endpoint*, each with its own nested input. |
|
|
67
69
|
| `playwrightPath` | (blank) | Local backend: path to a `playwright` executable or a Chromium-family browser binary. Blank = discover on `$PATH`, then fall back to the bundled `playwright-core`. |
|
|
68
70
|
| `cdpEndpoint` | `127.0.0.1:9222` | Remote backend: `host:port`, `http(s)://…` or `ws(s)://…`. |
|
|
71
|
+
| `shareBrowserContext` | `true` | CDP backend only. **Checked (profile mode)**: each fetch is a tab in the remote browser's default context — its real profile — so cookies/localStorage are shared and its persistent logins apply; only the tab closes when the fetch ends. **Unchecked (isolated mode)**: a fresh incognito-like context per fetch, nothing shared. Local backend ignores this field. |
|
|
69
72
|
| `denoise` | `true` | Run the denoise pipeline; off returns the full rendered HTML for the tool layer to convert. |
|
|
73
|
+
| `maxConcurrency` | *(auto)* | How many fetches may render at once (1–200). Blank = backend default: **4** for local (each slot launches a browser) / **50** for CDP (each slot is just a tab in the already-running remote browser). Beyond the limit, fetches wait briefly; if no slot frees within 20s they fail with `WEB_FETCH_TIMEOUT` and a hint to retry or raise this setting, rather than hanging until the tool budget aborts. |
|
|
70
74
|
|
|
71
75
|
Local backend resolution order:
|
|
72
76
|
|
|
@@ -74,7 +78,25 @@ Local backend resolution order:
|
|
|
74
78
|
2. A `playwright` executable on `$PATH` (its package knows that installation's browser registry).
|
|
75
79
|
3. The bundled `playwright-core` — requires `PLAYWRIGHT_BROWSERS_PATH` or browsers in the default cache; otherwise the error suggests `playwright install chromium`.
|
|
76
80
|
|
|
77
|
-
CDP mode needs no local browser: it
|
|
81
|
+
CDP mode needs no local browser: the provider holds **one shared connection** for its lifetime (reconnecting automatically if it drops, and reconnecting to the new endpoint when the setting changes), and every fetch leases a tab in the remote browser that closes when the fetch completes. Concurrency therefore counts tabs, which is why the CDP default is high (50). Unloading the plugin drops the shared connection (the remote browser itself is never closed).
|
|
82
|
+
|
|
83
|
+
### The CDP context modes (share the browser's profile or not)
|
|
84
|
+
|
|
85
|
+
With *Share the browser context* **checked** (default, profile mode), each fetch is a tab in the remote browser's default context — the real profile. Cookies and localStorage come from and are written back to that profile, so sites the browser is logged into are fetched logged-in, exactly like a tab you open by hand. The shared context is never closed; resource filtering and popup guards attach to the fetch's tab only, so your other tabs are untouched. With it **unchecked** (isolated mode), every fetch gets a fresh incognito-like context — anonymous reads, nothing persists.
|
|
86
|
+
|
|
87
|
+
**Profile-mode risk notes** — it upgrades `web_fetch` from "anonymous read" to "acts as the browser's logged-in user":
|
|
88
|
+
|
|
89
|
+
- A fetched page that talks the agent into a GET-style state-changing URL (logout, settings change, API call) will send it with your session cookies.
|
|
90
|
+
- Concurrent fetches to the same site share one cookie jar; one fetch's logout or `Set-Cookie` affects the others.
|
|
91
|
+
- Output starts depending on the browser's history (A/B buckets, language preferences). The remote profile also keeps accumulating site data; the plugin never cleans it.
|
|
92
|
+
|
|
93
|
+
Persistent logins require a persistent user-data-dir. Headful (recommended — log in by hand once):
|
|
94
|
+
|
|
95
|
+
```sh
|
|
96
|
+
google-chrome --remote-debugging-port=9222 --user-data-dir="$HOME/.config/chrome-dsh-profile"
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Headless server (pre-seed logins in a headful environment first): `chromium --headless=new --remote-debugging-port=9222 --user-data-dir=/data/chrome-dsh-profile`. Do **not** add `--incognito` or a throwaway user-data-dir — either defeats profile mode. Design notes and verified playwright-core facts live in [`docs/context-mode-profile.md`](./docs/context-mode-profile.md).
|
|
78
100
|
|
|
79
101
|
## Development
|
|
80
102
|
|
|
@@ -103,7 +125,7 @@ See [CONTRIBUTING.md](./CONTRIBUTING.md) for the development and release workflo
|
|
|
103
125
|
|
|
104
126
|
## Security
|
|
105
127
|
|
|
106
|
-
Same stance as the built-in HTTP provider: **no SSRF / private-network protection is implemented** — anything the browser can reach, this provider can fetch. The CDP endpoint is configured from the settings page with no loopback restriction, so only expose the settings page to trusted environments. Fetched pages are rendered locally; no data is sent anywhere beyond the target page itself.
|
|
128
|
+
Same stance as the built-in HTTP provider: **no SSRF / private-network protection is implemented** — anything the browser can reach, this provider can fetch. The CDP endpoint is configured from the settings page with no loopback restriction, so only expose the settings page to trusted environments. Fetched pages are rendered locally; no data is sent anywhere beyond the target page itself — but note that in profile mode the requests (and any state changes a malicious page tricks the agent into) carry the remote browser's logged-in sessions (see the risk notes above).
|
|
107
129
|
|
|
108
130
|
## License
|
|
109
131
|
|
package/README.zh-CN.md
CHANGED
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
- **降噪管线** —— Mozilla Readability 提取正文,DOMPurify 移除布局/噪音标签(导航、侧边栏、页脚、广告、表单),Turndown + GFM 插件按与内置 `tool-web` 渲染器一致的风格转成 Markdown。
|
|
13
13
|
- **两种后端** —— 本地启动 Playwright 浏览器,或通过 DevTools 协议(CDP)驱动一个已在运行的浏览器。
|
|
14
14
|
- **浏览器解析** —— 配置路径 → `$PATH` 上的 `playwright` CLI → 插件自带的 `playwright-core`;CDP 模式完全不需要本地浏览器。
|
|
15
|
-
-
|
|
16
|
-
- **热配置** —— 「设置 → 插件 →
|
|
17
|
-
- **预算控制** —— 单次抓取 45s
|
|
15
|
+
- **共享或隔离会话(CDP)** —— 每次抓取严格限定为一个标签页。本地后端每次抓取启动并关闭自己的浏览器;CDP 后端对远端浏览器保持**一条共享连接**,每次抓取只在其里开一个标签页、用完即关。默认该标签页位于远端浏览器的**真实 profile**(沿用其 cookie、localStorage 与已登录会话,效果类似 `playwright-cli open`);取消勾选「共享浏览器上下文」则切换为每次抓取全新隔离 context。
|
|
16
|
+
- **热配置** —— 「设置 → 插件 → 插件配置」卡片可随时切换后端、上下文模式、降噪开关与并发数,改动对下一次抓取即时生效,无需重启。
|
|
17
|
+
- **预算控制** —— 单次抓取 45s 超时;并发按后端定价(`maxConcurrency`,默认本地 4 个浏览器 / **CDP 50 个标签页**;排队的抓取等不到空位会在 20s 内尽快报错并提示重试,而不是一直挂到被工具层中止);拦截图片/字体/媒体子请求;返回体 10 万字符封顶。
|
|
18
18
|
|
|
19
19
|
## 工作原理
|
|
20
20
|
|
|
@@ -61,12 +61,16 @@ bundle 插件加入 profile 层栈后需**重启 `dsh web`** 生效;卸载用
|
|
|
61
61
|
|
|
62
62
|
设置卡片(设置 → 插件 → 插件配置 → *Playwright 网页爬取*)实时编辑 `web-fetch-playwright` 设置段:
|
|
63
63
|
|
|
64
|
+

|
|
65
|
+
|
|
64
66
|
| 字段 | 默认 | 说明 |
|
|
65
67
|
| --- | --- | --- |
|
|
66
68
|
| `backend` | `local` | radio:本地 Playwright / 远端 CDP 地址,每个选项内嵌各自的填空。 |
|
|
67
69
|
| `playwrightPath` | 空 | 本地后端:`playwright` 可执行文件或 Chromium 系浏览器二进制路径;留空按 `$PATH` 查找,再回退到内置 `playwright-core`。 |
|
|
68
70
|
| `cdpEndpoint` | `127.0.0.1:9222` | 远端后端:`host:port`、`http(s)://…` 或 `ws(s)://…`。 |
|
|
71
|
+
| `shareBrowserContext` | `true` | 仅 CDP 后端。**勾选(profile 模式)**:每次抓取是远端浏览器默认 context(真实 profile)里的一个标签页,cookie/localStorage 与之互通、已登录会话直接生效,抓取结束只关标签页;**取消勾选(隔离模式)**:每次抓取使用全新隐身式 context,互不共享。本地后端忽略此字段。 |
|
|
69
72
|
| `denoise` | `true` | 是否启用降噪;关闭时返回整页渲染 HTML,交由工具层转换。 |
|
|
73
|
+
| `maxConcurrency` | *(自动)* | 同时渲染的页面上限(1–200)。留空按后端取默认:本地 **4**(每个槽位启动一个浏览器)/ CDP **50**(远端浏览器已就位,每个槽位只是一个标签页)。超出的请求短暂排队;20s 内等不到空位则以 `WEB_FETCH_TIMEOUT` 尽快失败并提示重试或调大该值,而不是一直挂起直到工具层预算中止。 |
|
|
70
74
|
|
|
71
75
|
本地后端解析顺序:
|
|
72
76
|
|
|
@@ -74,7 +78,25 @@ bundle 插件加入 profile 层栈后需**重启 `dsh web`** 生效;卸载用
|
|
|
74
78
|
2. `$PATH` 上的 `playwright`(其包自带该安装的浏览器注册表);
|
|
75
79
|
3. 插件内置的 `playwright-core`——需要 `PLAYWRIGHT_BROWSERS_PATH` 或默认缓存里有浏览器,否则报错会提示 `playwright install chromium`。
|
|
76
80
|
|
|
77
|
-
CDP
|
|
81
|
+
CDP 模式不需要本地浏览器:插件在生命周期内对远端浏览器保持**一条共享连接**(连接断开自动重连,地址改动后自动换连),每次抓取只租用远端浏览器里的一个标签页,抓取结束即关闭。因此并发数按"标签页"计,默认也更高(50)。插件卸载时断开共享连接(绝不会关闭远端浏览器本身)。
|
|
82
|
+
|
|
83
|
+
### CDP 上下文模式(是否共享浏览器 profile)
|
|
84
|
+
|
|
85
|
+
「共享浏览器上下文」**勾选**(默认,profile 模式)时,每次抓取是远端浏览器默认 context——真实 profile——里的一个标签页:cookie 与 localStorage 双向互通,浏览器里已登录的站点会以登录态被抓取,和你手动开标签页一样。共享 context 永不关闭;资源过滤与弹窗守卫只挂在本次抓取自己的标签页上,不会干扰你人工打开的其他标签页。**取消勾选**(隔离模式)时,每次抓取使用全新隐身式 context——匿名读取,什么都不保留。
|
|
86
|
+
|
|
87
|
+
**profile 模式风险须知** —— 它把 `web_fetch` 从"匿名读网页"升级为"以浏览器登录身份行动":
|
|
88
|
+
|
|
89
|
+
- 被抓取的恶意页面若诱导 agent 请求 GET 型状态变更 URL(登出、改设置、API 操作),请求会自动携带会话 cookie。
|
|
90
|
+
- 同一站点的并发抓取共享一个 cookie jar,一方的登出 / `Set-Cookie` 会影响另一方。
|
|
91
|
+
- 输出开始依赖浏览器历史(A/B 分桶、语言偏好);远端 profile 的站点数据只增不减,插件不做清理。
|
|
92
|
+
|
|
93
|
+
登录态持久的前提是 user-data-dir 持久化。有头(推荐,手动登录一次):
|
|
94
|
+
|
|
95
|
+
```sh
|
|
96
|
+
google-chrome --remote-debugging-port=9222 --user-data-dir="$HOME/.config/chrome-dsh-profile"
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
无头服务器(先在有头环境预置登录态):`chromium --headless=new --remote-debugging-port=9222 --user-data-dir=/data/chrome-dsh-profile`。**不要**叠加 `--incognito` 或一次性 user-data-dir——都会让 profile 模式失效。设计依据与已核实的 playwright-core 源码事实见 [`docs/context-mode-profile.md`](./docs/context-mode-profile.md)。
|
|
78
100
|
|
|
79
101
|
## 开发
|
|
80
102
|
|
|
@@ -103,7 +125,7 @@ tests/ # 单元 + provider + 浏览器集成(可自跳过
|
|
|
103
125
|
|
|
104
126
|
## 安全边界
|
|
105
127
|
|
|
106
|
-
与内置 HTTP provider 同立场:**未实现 SSRF/私网防护**——浏览器能访问的目标,本 provider 就能抓。CDP
|
|
128
|
+
与内置 HTTP provider 同立场:**未实现 SSRF/私网防护**——浏览器能访问的目标,本 provider 就能抓。CDP 地址由设置页配置,不做回环限制,请在可信环境暴露设置页。抓取仅在本地渲染,除目标页面自身外不会向任何地方发送数据——但 profile 模式下请求(以及恶意页面诱导 agent 触发的状态变更)会携带远端浏览器的登录会话,见上文风险须知。
|
|
107
129
|
|
|
108
130
|
## 许可证
|
|
109
131
|
|
package/dsh.plugin.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-web-fetch-playwright",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Playwright/CDP web-fetch provider for DeepSeek Harness: renders pages in a real browser, denoises them (Readability + DOMPurify), and returns markdown.",
|
|
5
5
|
"entry": {
|
|
6
6
|
"name": "dsh-web-fetch-playwright",
|
package/lib/client.js
CHANGED
|
@@ -101,6 +101,31 @@ window.__ModuleLoader__.load({
|
|
|
101
101
|
};
|
|
102
102
|
}
|
|
103
103
|
/**
|
|
104
|
+
* An integer field over an inclusive range. The draft is the decimal string;
|
|
105
|
+
* an empty draft clears the field (re-inherit the schema default), and
|
|
106
|
+
* anything but an integer in range blocks the save as invalid.
|
|
107
|
+
* @param field - field name inside the namespace section.
|
|
108
|
+
* @param min - smallest accepted integer (inclusive).
|
|
109
|
+
* @param max - largest accepted integer (inclusive).
|
|
110
|
+
* @returns the field's conversion spec.
|
|
111
|
+
*/
|
|
112
|
+
function numberField(field, min, max) {
|
|
113
|
+
return {
|
|
114
|
+
field,
|
|
115
|
+
format: (value) => typeof value === "number" && Number.isInteger(value) ? String(value) : "",
|
|
116
|
+
parse: (text) => {
|
|
117
|
+
const trimmed = text.trim();
|
|
118
|
+
if (trimmed === "") return { kind: "clear" };
|
|
119
|
+
if (!/^\d+$/.test(trimmed)) return void 0;
|
|
120
|
+
const value = Number(trimmed);
|
|
121
|
+
return value >= min && value <= max ? {
|
|
122
|
+
kind: "set",
|
|
123
|
+
value
|
|
124
|
+
} : void 0;
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
104
129
|
* Stages the Playwright card's edits over one settings namespace and writes
|
|
105
130
|
* them on save. Publishes through a snapshot store because slot components
|
|
106
131
|
* read through a selector while both the scope and the drafts change below.
|
|
@@ -323,7 +348,9 @@ window.__ModuleLoader__.load({
|
|
|
323
348
|
radioField("backend", ["local", "cdp"]),
|
|
324
349
|
textField("playwrightPath"),
|
|
325
350
|
textField("cdpEndpoint"),
|
|
326
|
-
checkboxField("
|
|
351
|
+
checkboxField("shareBrowserContext"),
|
|
352
|
+
checkboxField("denoise"),
|
|
353
|
+
numberField("maxConcurrency", 1, 200)
|
|
327
354
|
]);
|
|
328
355
|
this.store = this.form.bind(() => this.projection());
|
|
329
356
|
}
|
|
@@ -333,7 +360,9 @@ window.__ModuleLoader__.load({
|
|
|
333
360
|
backend: this.form.field("backend"),
|
|
334
361
|
playwrightPath: this.form.field("playwrightPath"),
|
|
335
362
|
cdpEndpoint: this.form.field("cdpEndpoint"),
|
|
336
|
-
|
|
363
|
+
shareBrowserContext: this.form.field("shareBrowserContext"),
|
|
364
|
+
denoise: this.form.field("denoise"),
|
|
365
|
+
maxConcurrency: this.form.field("maxConcurrency")
|
|
337
366
|
};
|
|
338
367
|
}
|
|
339
368
|
/**
|
|
@@ -359,21 +388,21 @@ window.__ModuleLoader__.load({
|
|
|
359
388
|
document.head.appendChild(tag);
|
|
360
389
|
}
|
|
361
390
|
var PluginCard_module_css_default = {
|
|
362
|
-
"description": "UM8-Rq_description",
|
|
363
|
-
"footer": "UM8-Rq_footer",
|
|
364
391
|
"chevron": "UM8-Rq_chevron",
|
|
365
|
-
"name": "UM8-Rq_name",
|
|
366
|
-
"save": "UM8-Rq_save",
|
|
367
|
-
"readOnly": "UM8-Rq_readOnly",
|
|
368
|
-
"card": "UM8-Rq_card",
|
|
369
|
-
"pending": "UM8-Rq_pending",
|
|
370
|
-
"body": "UM8-Rq_body",
|
|
371
|
-
"headText": "UM8-Rq_headText",
|
|
372
392
|
"chevronOpen": "UM8-Rq_chevronOpen",
|
|
393
|
+
"save": "UM8-Rq_save",
|
|
394
|
+
"name": "UM8-Rq_name",
|
|
395
|
+
"discard": "UM8-Rq_discard",
|
|
373
396
|
"failed": "UM8-Rq_failed",
|
|
397
|
+
"header": "UM8-Rq_header",
|
|
374
398
|
"cardOpen": "UM8-Rq_cardOpen",
|
|
375
|
-
"
|
|
376
|
-
"
|
|
399
|
+
"description": "UM8-Rq_description",
|
|
400
|
+
"body": "UM8-Rq_body",
|
|
401
|
+
"card": "UM8-Rq_card",
|
|
402
|
+
"footer": "UM8-Rq_footer",
|
|
403
|
+
"readOnly": "UM8-Rq_readOnly",
|
|
404
|
+
"headText": "UM8-Rq_headText",
|
|
405
|
+
"pending": "UM8-Rq_pending"
|
|
377
406
|
};
|
|
378
407
|
//#endregion
|
|
379
408
|
//#region src/client/PluginCard.tsx
|
|
@@ -480,7 +509,7 @@ window.__ModuleLoader__.load({
|
|
|
480
509
|
}
|
|
481
510
|
//#endregion
|
|
482
511
|
//#region \0dsh-web-fetch-playwright-css:/opt/dsh/plugins/dsh-web-fetch-playwright/src/client/fields.module.css.mjs
|
|
483
|
-
const css = ".CFSaVG_field{border:0;border-top:1px solid var(--dsw-alias-border-l2);flex-direction:column;gap:6px;margin:0;padding:12px 0;display:flex}.CFSaVG_field:first-child{border-top:0}.CFSaVG_fieldEmbedded{border:0;flex-direction:column;gap:6px;margin:0;padding:0;display:flex}.CFSaVG_head{align-items:center;gap:8px;display:flex}.CFSaVG_label{min-width:0;color:var(--dsw-alias-label-primary);flex:1;font-size:13px;font-weight:500;line-height:1.5}.CFSaVG_badges{align-items:center;gap:8px;display:inline-flex}.CFSaVG_badge{white-space:nowrap;background:var(--dsw-alias-bg-module-platform);color:var(--dsw-alias-label-secondary);border-radius:999px;padding:1px 8px;font-size:11px;font-weight:500;line-height:17px}.CFSaVG_reset{font:inherit;color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border:none;padding:0;font-size:12px;line-height:1.5}.CFSaVG_reset:hover:not(:disabled){color:var(--dsw-alias-label-primary)}.CFSaVG_reset:disabled{cursor:default}.CFSaVG_input{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);height:34px;font:inherit;color:var(--dsw-alias-label-primary);border-radius:8px;padding:0 12px;font-size:13px;line-height:1.5}.CFSaVG_input:focus-visible{border-color:var(--dsw-alias-brand-primary);outline:none}.CFSaVG_input:disabled{color:var(--dsw-alias-label-tertiary);cursor:default}.CFSaVG_inputInvalid{border:1px solid var(--dsw-alias-label-error);background:var(--dsw-alias-bg-layer-3);height:34px;font:inherit;color:var(--dsw-alias-label-primary);border-radius:8px;padding:0 12px;font-size:13px;line-height:1.5}.CFSaVG_invalid{color:var(--dsw-alias-label-error);margin:0;font-size:12px;line-height:1.5}.CFSaVG_hint{color:var(--dsw-alias-label-tertiary);margin:0;font-size:12px;line-height:1.5}.CFSaVG_radioGroup{flex-direction:column;gap:8px;display:flex}.CFSaVG_radioOption{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);border-radius:8px;flex-direction:column;gap:8px;padding:10px 12px;display:flex}.CFSaVG_radioOption:has(input[type=radio]:checked){border-color:var(--dsw-alias-brand-primary)}.CFSaVG_radioPick{cursor:pointer;align-items:flex-start;gap:10px;display:flex}.CFSaVG_radioPick input[type=radio]{width:14px;height:14px;accent-color:var(--dsw-alias-brand-primary);flex:none;margin-top:2px}.CFSaVG_radioPick input[type=radio]:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}.CFSaVG_radioText{flex-direction:column;gap:2px;min-width:0;display:flex}.CFSaVG_radioLabel{color:var(--dsw-alias-label-primary);font-size:13px;font-weight:500;line-height:1.5}.CFSaVG_radioHint{color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:1.5}.CFSaVG_radioContent{margin-left:24px}.CFSaVG_radioContent input[type=text]:enabled{cursor:text}.CFSaVG_checkboxRow{align-items:center;gap:10px;display:flex}.CFSaVG_checkboxRow input[type=checkbox]{width:16px;height:16px;accent-color:var(--dsw-alias-brand-primary);flex:none;margin:0}.CFSaVG_checkboxRow input[type=checkbox]:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}";
|
|
512
|
+
const css = ".CFSaVG_field{border:0;border-top:1px solid var(--dsw-alias-border-l2);flex-direction:column;gap:6px;margin:0;padding:12px 0;display:flex}.CFSaVG_field:first-child{border-top:0}.CFSaVG_fieldEmbedded{border:0;flex-direction:column;gap:6px;margin:0;padding:0;display:flex}.CFSaVG_head{align-items:center;gap:8px;display:flex}.CFSaVG_label{min-width:0;color:var(--dsw-alias-label-primary);flex:1;font-size:13px;font-weight:500;line-height:1.5}.CFSaVG_badges{align-items:center;gap:8px;display:inline-flex}.CFSaVG_badge{white-space:nowrap;background:var(--dsw-alias-bg-module-platform);color:var(--dsw-alias-label-secondary);border-radius:999px;padding:1px 8px;font-size:11px;font-weight:500;line-height:17px}.CFSaVG_reset{font:inherit;color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border:none;padding:0;font-size:12px;line-height:1.5}.CFSaVG_reset:hover:not(:disabled){color:var(--dsw-alias-label-primary)}.CFSaVG_reset:disabled{cursor:default}.CFSaVG_input{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);height:34px;font:inherit;color:var(--dsw-alias-label-primary);border-radius:8px;padding:0 12px;font-size:13px;line-height:1.5}.CFSaVG_input:focus-visible{border-color:var(--dsw-alias-brand-primary);outline:none}.CFSaVG_input:disabled{color:var(--dsw-alias-label-tertiary);cursor:default}.CFSaVG_inputInvalid{border:1px solid var(--dsw-alias-label-error);background:var(--dsw-alias-bg-layer-3);height:34px;font:inherit;color:var(--dsw-alias-label-primary);border-radius:8px;padding:0 12px;font-size:13px;line-height:1.5}.CFSaVG_invalid{color:var(--dsw-alias-label-error);margin:0;font-size:12px;line-height:1.5}.CFSaVG_hint{color:var(--dsw-alias-label-tertiary);margin:0;font-size:12px;line-height:1.5}.CFSaVG_hintIndented{margin-left:26px}.CFSaVG_radioGroup{flex-direction:column;gap:8px;display:flex}.CFSaVG_radioOption{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);border-radius:8px;flex-direction:column;gap:8px;padding:10px 12px;display:flex}.CFSaVG_radioOption:has(input[type=radio]:checked){border-color:var(--dsw-alias-brand-primary)}.CFSaVG_radioPick{cursor:pointer;align-items:flex-start;gap:10px;display:flex}.CFSaVG_radioPick input[type=radio]{width:14px;height:14px;accent-color:var(--dsw-alias-brand-primary);flex:none;margin-top:2px}.CFSaVG_radioPick input[type=radio]:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}.CFSaVG_radioText{flex-direction:column;gap:2px;min-width:0;display:flex}.CFSaVG_radioLabel{color:var(--dsw-alias-label-primary);font-size:13px;font-weight:500;line-height:1.5}.CFSaVG_radioHint{color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:1.5}.CFSaVG_radioContent{margin-left:24px}.CFSaVG_radioContent>*+*{margin-top:12px}.CFSaVG_radioContent input[type=text]:enabled{cursor:text}.CFSaVG_checkboxRow{align-items:center;gap:10px;display:flex}.CFSaVG_checkboxRow input[type=checkbox]{width:16px;height:16px;accent-color:var(--dsw-alias-brand-primary);flex:none;margin:0}.CFSaVG_checkboxRow input[type=checkbox]:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}";
|
|
484
513
|
const tagId = "dsh-web-fetch-playwright/fields.module.css";
|
|
485
514
|
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
|
|
486
515
|
const tag = document.createElement("style");
|
|
@@ -490,25 +519,26 @@ window.__ModuleLoader__.load({
|
|
|
490
519
|
document.head.appendChild(tag);
|
|
491
520
|
}
|
|
492
521
|
var fields_module_css_default = {
|
|
493
|
-
"
|
|
494
|
-
"
|
|
495
|
-
"radioPick": "CFSaVG_radioPick",
|
|
496
|
-
"label": "CFSaVG_label",
|
|
522
|
+
"badges": "CFSaVG_badges",
|
|
523
|
+
"invalid": "CFSaVG_invalid",
|
|
497
524
|
"radioContent": "CFSaVG_radioContent",
|
|
498
|
-
"
|
|
499
|
-
"radioGroup": "CFSaVG_radioGroup",
|
|
525
|
+
"hint": "CFSaVG_hint",
|
|
500
526
|
"radioLabel": "CFSaVG_radioLabel",
|
|
501
|
-
"
|
|
527
|
+
"radioGroup": "CFSaVG_radioGroup",
|
|
528
|
+
"radioText": "CFSaVG_radioText",
|
|
502
529
|
"badge": "CFSaVG_badge",
|
|
503
|
-
"invalid": "CFSaVG_invalid",
|
|
504
|
-
"badges": "CFSaVG_badges",
|
|
505
|
-
"reset": "CFSaVG_reset",
|
|
506
|
-
"input": "CFSaVG_input",
|
|
507
|
-
"head": "CFSaVG_head",
|
|
508
530
|
"fieldEmbedded": "CFSaVG_fieldEmbedded",
|
|
531
|
+
"checkboxRow": "CFSaVG_checkboxRow",
|
|
532
|
+
"hintIndented": "CFSaVG_hintIndented",
|
|
533
|
+
"input": "CFSaVG_input",
|
|
534
|
+
"radioHint": "CFSaVG_radioHint",
|
|
535
|
+
"label": "CFSaVG_label",
|
|
536
|
+
"reset": "CFSaVG_reset",
|
|
509
537
|
"inputInvalid": "CFSaVG_inputInvalid",
|
|
510
|
-
"
|
|
511
|
-
"
|
|
538
|
+
"field": "CFSaVG_field",
|
|
539
|
+
"radioPick": "CFSaVG_radioPick",
|
|
540
|
+
"head": "CFSaVG_head",
|
|
541
|
+
"radioOption": "CFSaVG_radioOption"
|
|
512
542
|
};
|
|
513
543
|
//#endregion
|
|
514
544
|
//#region src/client/fields.tsx
|
|
@@ -614,10 +644,14 @@ window.__ModuleLoader__.load({
|
|
|
614
644
|
})]
|
|
615
645
|
});
|
|
616
646
|
}
|
|
617
|
-
/**
|
|
647
|
+
/**
|
|
648
|
+
* A staged checkbox: the denoise toggle and the CDP shared-context toggle.
|
|
649
|
+
* An absent stored value formats as '' — callers render the schema default
|
|
650
|
+
* (denoise on, context shared).
|
|
651
|
+
*/
|
|
618
652
|
function CheckboxField(props) {
|
|
619
653
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
620
|
-
className: fields_module_css_default.field,
|
|
654
|
+
className: props.embedded ? fields_module_css_default.fieldEmbedded : fields_module_css_default.field,
|
|
621
655
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
622
656
|
className: fields_module_css_default.checkboxRow,
|
|
623
657
|
children: [
|
|
@@ -650,7 +684,7 @@ window.__ModuleLoader__.load({
|
|
|
650
684
|
}) : null
|
|
651
685
|
]
|
|
652
686
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
653
|
-
className: fields_module_css_default.hint,
|
|
687
|
+
className: props.embedded ? `${fields_module_css_default.hint} ${fields_module_css_default.hintIndented}` : fields_module_css_default.hint,
|
|
654
688
|
children: props.hint
|
|
655
689
|
})]
|
|
656
690
|
});
|
|
@@ -683,80 +717,116 @@ window.__ModuleLoader__.load({
|
|
|
683
717
|
state,
|
|
684
718
|
onSave: props.save,
|
|
685
719
|
onDiscard: props.discard,
|
|
686
|
-
children: [
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
720
|
+
children: [
|
|
721
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RadioGroupField, {
|
|
722
|
+
label: t("backendLabel"),
|
|
723
|
+
options: [{
|
|
724
|
+
value: "local",
|
|
725
|
+
label: t("backendLocal"),
|
|
726
|
+
hint: t("backendLocalHint"),
|
|
727
|
+
content: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ValueField, {
|
|
728
|
+
embedded: true,
|
|
729
|
+
id: "plugin-config-playwright-path",
|
|
730
|
+
label: t("playwrightPath"),
|
|
731
|
+
hint: t("playwrightPathHint"),
|
|
732
|
+
placeholder: t("playwrightPathPlaceholder"),
|
|
733
|
+
overriddenLabel: t("overridden"),
|
|
734
|
+
resetLabel: t("reset"),
|
|
735
|
+
invalidLabel: t("invalidText"),
|
|
736
|
+
disabled: disabled || backend !== "local",
|
|
737
|
+
...state.playwrightPath,
|
|
738
|
+
onEdit: (text) => {
|
|
739
|
+
props.edit("playwrightPath", text);
|
|
740
|
+
},
|
|
741
|
+
onReset: () => {
|
|
742
|
+
props.resetField("playwrightPath");
|
|
743
|
+
}
|
|
744
|
+
})
|
|
745
|
+
}, {
|
|
746
|
+
value: "cdp",
|
|
747
|
+
label: t("backendCdp"),
|
|
748
|
+
hint: t("backendCdpHint"),
|
|
749
|
+
content: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ValueField, {
|
|
750
|
+
embedded: true,
|
|
751
|
+
id: "plugin-config-playwright-cdp",
|
|
752
|
+
label: t("cdpEndpoint"),
|
|
753
|
+
hint: t("cdpEndpointHint"),
|
|
754
|
+
placeholder: "127.0.0.1:9222",
|
|
755
|
+
overriddenLabel: t("overridden"),
|
|
756
|
+
resetLabel: t("reset"),
|
|
757
|
+
invalidLabel: t("invalidText"),
|
|
758
|
+
disabled: disabled || backend !== "cdp",
|
|
759
|
+
...state.cdpEndpoint,
|
|
760
|
+
onEdit: (text) => {
|
|
761
|
+
props.edit("cdpEndpoint", text);
|
|
762
|
+
},
|
|
763
|
+
onReset: () => {
|
|
764
|
+
props.resetField("cdpEndpoint");
|
|
765
|
+
}
|
|
766
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CheckboxField, {
|
|
767
|
+
embedded: true,
|
|
768
|
+
id: "plugin-config-playwright-share-context",
|
|
769
|
+
label: t("shareBrowserContext"),
|
|
770
|
+
hint: t("shareBrowserContextHint"),
|
|
771
|
+
checked: state.shareBrowserContext.text !== "false",
|
|
772
|
+
overridden: state.shareBrowserContext.overridden,
|
|
773
|
+
overriddenLabel: t("overridden"),
|
|
774
|
+
resetLabel: t("reset"),
|
|
775
|
+
disabled: disabled || backend !== "cdp",
|
|
776
|
+
onEdit: (text) => {
|
|
777
|
+
props.edit("shareBrowserContext", text);
|
|
778
|
+
},
|
|
779
|
+
onReset: () => {
|
|
780
|
+
props.resetField("shareBrowserContext");
|
|
781
|
+
}
|
|
782
|
+
})] })
|
|
783
|
+
}],
|
|
784
|
+
text: state.backend.text,
|
|
785
|
+
overridden: state.backend.overridden,
|
|
786
|
+
overriddenLabel: t("overridden"),
|
|
787
|
+
resetLabel: t("reset"),
|
|
788
|
+
disabled,
|
|
789
|
+
onEdit: (text) => {
|
|
790
|
+
props.edit("backend", text);
|
|
791
|
+
},
|
|
792
|
+
onReset: () => {
|
|
793
|
+
props.resetField("backend");
|
|
794
|
+
}
|
|
795
|
+
}),
|
|
796
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CheckboxField, {
|
|
797
|
+
id: "plugin-config-playwright-denoise",
|
|
798
|
+
label: t("denoise"),
|
|
799
|
+
hint: t("denoiseHint"),
|
|
800
|
+
checked: state.denoise.text !== "false",
|
|
801
|
+
overridden: state.denoise.overridden,
|
|
802
|
+
overriddenLabel: t("overridden"),
|
|
803
|
+
resetLabel: t("reset"),
|
|
804
|
+
disabled,
|
|
805
|
+
onEdit: (text) => {
|
|
806
|
+
props.edit("denoise", text);
|
|
807
|
+
},
|
|
808
|
+
onReset: () => {
|
|
809
|
+
props.resetField("denoise");
|
|
810
|
+
}
|
|
811
|
+
}),
|
|
812
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ValueField, {
|
|
813
|
+
id: "plugin-config-playwright-concurrency",
|
|
814
|
+
label: t("maxConcurrency"),
|
|
815
|
+
hint: t("maxConcurrencyHint"),
|
|
816
|
+
placeholder: t("maxConcurrencyPlaceholder"),
|
|
817
|
+
overriddenLabel: t("overridden"),
|
|
818
|
+
resetLabel: t("reset"),
|
|
819
|
+
invalidLabel: t("invalidText"),
|
|
820
|
+
disabled,
|
|
821
|
+
...state.maxConcurrency,
|
|
822
|
+
onEdit: (text) => {
|
|
823
|
+
props.edit("maxConcurrency", text);
|
|
824
|
+
},
|
|
825
|
+
onReset: () => {
|
|
826
|
+
props.resetField("maxConcurrency");
|
|
827
|
+
}
|
|
828
|
+
})
|
|
829
|
+
]
|
|
760
830
|
});
|
|
761
831
|
}
|
|
762
832
|
//#endregion
|
|
@@ -775,8 +845,13 @@ window.__ModuleLoader__.load({
|
|
|
775
845
|
playwrightPathPlaceholder: "(auto: playwright from $PATH)",
|
|
776
846
|
cdpEndpoint: "CDP endpoint",
|
|
777
847
|
cdpEndpointHint: "host:port or http(s)/ws URL. Leave blank for 127.0.0.1:9222.",
|
|
848
|
+
shareBrowserContext: "Share the browser context (profile logins)",
|
|
849
|
+
shareBrowserContextHint: "Each fetch opens a tab in the remote browser’s real profile — cookies and localStorage are shared and its persistent logins apply. Unchecked: every fetch uses a fresh isolated context.",
|
|
778
850
|
denoise: "Enable the denoise algorithm",
|
|
779
851
|
denoiseHint: "Readability + DOMPurify strip nav bars, sidebars, footers, and ads before converting to markdown.",
|
|
852
|
+
maxConcurrency: "Max concurrent fetches",
|
|
853
|
+
maxConcurrencyHint: "How many pages may render at once (1–200). Blank = auto: 4 local browsers, 50 CDP tabs in the remote browser.",
|
|
854
|
+
maxConcurrencyPlaceholder: "(auto: local 4 / CDP 50)",
|
|
780
855
|
overridden: "Overridden",
|
|
781
856
|
reset: "Reset to default",
|
|
782
857
|
readOnly: "This deployment stores settings read-only.",
|
|
@@ -803,8 +878,13 @@ window.__ModuleLoader__.load({
|
|
|
803
878
|
playwrightPathPlaceholder: "(自动:按 $PATH 查找 playwright)",
|
|
804
879
|
cdpEndpoint: "CDP 地址",
|
|
805
880
|
cdpEndpointHint: "host:port 或 http(s)/ws 地址;留空默认 127.0.0.1:9222。",
|
|
881
|
+
shareBrowserContext: "共享浏览器上下文(复用登录态)",
|
|
882
|
+
shareBrowserContextHint: "每次抓取在远端浏览器的真实 profile 里开一个标签页:共享 cookie 与 localStorage、复用已登录会话,页面会看到你的登录身份;取消勾选则每次抓取使用全新隔离上下文。",
|
|
806
883
|
denoise: "启用降噪算法",
|
|
807
884
|
denoiseHint: "使用 Readability + DOMPurify 清洗导航栏、侧边栏、页脚与贴片广告后再转为 Markdown。",
|
|
885
|
+
maxConcurrency: "最大并发抓取数",
|
|
886
|
+
maxConcurrencyHint: "同时渲染的页面上限(1–200);留空自动:本地 4 个浏览器,CDP 在远端浏览器里 50 个标签页。",
|
|
887
|
+
maxConcurrencyPlaceholder: "(自动:本地 4 / CDP 50)",
|
|
808
888
|
overridden: "已覆盖",
|
|
809
889
|
reset: "恢复默认",
|
|
810
890
|
readOnly: "本部署的设置为只读。",
|