dsh-chrome-bridge 1.14.0 → 1.15.0
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/download.js +229 -0
- package/index.js +68 -8
- package/package.json +2 -1
- package/refs.js +95 -16
- package/setup.js +17 -6
- package/vendor/skill/SKILL.md +4 -2
package/download.js
ADDED
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 下载文件(browser_download):带着用户在 Chrome 里的登录状态,把链接指向的文件存到本机。
|
|
3
|
+
*
|
|
4
|
+
* 只用宿主已有的 eval / cdp op —— 不改扩展,不加扩展权限(加权限得重新过商店审核,用户还要再点一次同意)。
|
|
5
|
+
*
|
|
6
|
+
* 两条路,先走第一条:
|
|
7
|
+
* ① 页面里 fetch(credentials: include):和用户点链接一样走 Chrome 的网络(登录、代理、证书都一样),
|
|
8
|
+
* 文件先留在页面里,再分块用 base64 读回来写盘。blob: / data: 链接只能走这条
|
|
9
|
+
* ② 跨站被 CORS / CSP 拦了:插件自己下,Cookie 用 CDP 的 Network.getCookies 按网址取(每一跳重定向都重取)
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import fs from 'node:fs'
|
|
13
|
+
import os from 'node:os'
|
|
14
|
+
import path from 'node:path'
|
|
15
|
+
import crypto from 'node:crypto'
|
|
16
|
+
import { refElementJs } from './refs.js'
|
|
17
|
+
|
|
18
|
+
const CHUNK = 2 * 1024 * 1024 // 页面里每次读回 2MB(base64 后约 2.7MB)
|
|
19
|
+
const PAGE_MAX = 300 * 1024 * 1024 // 页面里最多暂存这么大,再大走插件直接下
|
|
20
|
+
const TIMEOUT_MS = 10 * 60 * 1000
|
|
21
|
+
|
|
22
|
+
const EXT = {
|
|
23
|
+
'application/pdf': '.pdf', 'text/csv': '.csv', 'application/zip': '.zip', 'application/json': '.json',
|
|
24
|
+
'text/plain': '.txt', 'text/html': '.html', 'image/png': '.png', 'image/jpeg': '.jpg', 'image/gif': '.gif',
|
|
25
|
+
'image/webp': '.webp', 'image/svg+xml': '.svg', 'video/mp4': '.mp4', 'audio/mpeg': '.mp3',
|
|
26
|
+
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': '.xlsx',
|
|
27
|
+
'application/vnd.openxmlformats-officedocument.wordprocessingml.document': '.docx',
|
|
28
|
+
'application/vnd.openxmlformats-officedocument.presentationml.presentation': '.pptx',
|
|
29
|
+
'application/vnd.ms-excel': '.xls', 'application/msword': '.doc',
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Content-Disposition 里的文件名:filename*=UTF-8''… 优先,再 filename="…" */
|
|
33
|
+
export function dispositionName(header) {
|
|
34
|
+
const h = String(header || '')
|
|
35
|
+
const star = /filename\*\s*=\s*([^']*)'[^']*'([^;]+)/i.exec(h)
|
|
36
|
+
if (star) { try { return decodeURIComponent(star[2].trim().replace(/^"|"$/g, '')) } catch {} }
|
|
37
|
+
const plain = /filename\s*=\s*("((?:[^"\\]|\\.)*)"|[^;]+)/i.exec(h)
|
|
38
|
+
if (plain) return (plain[2] !== undefined ? plain[2].replace(/\\(.)/g, '$1') : plain[1]).trim()
|
|
39
|
+
return ''
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** 文件名能安全落盘:去掉路径分隔符、控制字符、开头的点(不做成隐藏文件),太长截断 */
|
|
43
|
+
export function safeName(name) {
|
|
44
|
+
let n = String(name || '').replace(/[\\/:*?"<>|\u0000-\u001f]/g, '_').replace(/^[.\s]+/, '').trim()
|
|
45
|
+
if (n.length > 180) {
|
|
46
|
+
const ext = path.extname(n).slice(0, 12)
|
|
47
|
+
n = n.slice(0, 180 - ext.length) + ext
|
|
48
|
+
}
|
|
49
|
+
return n
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** 起名:给的名字 > 服务器给的 > 链接的 download 属性 > 网址最后一段;没扩展名就按类型补 */
|
|
53
|
+
export function pickName({ filename, disposition, suggested, url, type }) {
|
|
54
|
+
let fromUrl = ''
|
|
55
|
+
try {
|
|
56
|
+
const u = new URL(url)
|
|
57
|
+
if (u.protocol === 'http:' || u.protocol === 'https:') fromUrl = decodeURIComponent(u.pathname.split('/').pop() || '')
|
|
58
|
+
} catch {}
|
|
59
|
+
let n = safeName(filename) || safeName(dispositionName(disposition)) || safeName(suggested) || safeName(fromUrl) || 'download'
|
|
60
|
+
const ext = EXT[String(type || '').split(';')[0].trim().toLowerCase()]
|
|
61
|
+
if (!path.extname(n) && ext) n += ext
|
|
62
|
+
return n
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** 不覆盖已有文件:重名就加「 (1)」「 (2)」… */
|
|
66
|
+
export function uniquePath(dir, name) {
|
|
67
|
+
const ext = path.extname(name)
|
|
68
|
+
const base = name.slice(0, name.length - ext.length)
|
|
69
|
+
for (let i = 0; i < 1000; i++) {
|
|
70
|
+
const p = path.join(dir, i ? `${base} (${i})${ext}` : name)
|
|
71
|
+
if (!fs.existsSync(p)) return p
|
|
72
|
+
}
|
|
73
|
+
throw new Error(`${dir} 里同名文件太多了:${name}`)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function humanSize(n) {
|
|
77
|
+
if (n < 1024) return `${n} B`
|
|
78
|
+
if (n < 1024 * 1024) return `${(n / 1024).toFixed(1)} KB`
|
|
79
|
+
return `${(n / 1024 / 1024).toFixed(1)} MB`
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** 默认存到「下载」文件夹(Windows、Mac、Linux 都是家目录下的 Downloads) */
|
|
83
|
+
export function downloadsDir() {
|
|
84
|
+
return path.join(os.homedir(), 'Downloads')
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** 在页面里:要下载的是哪个网址(编号 / 选择器指的链接,或直接给的网址,相对地址按页面算) */
|
|
88
|
+
const TARGET_JS = ({ ref, selector, url }) => `(() => {
|
|
89
|
+
const el = ${ref !== undefined && ref !== null ? refElementJs(ref) : selector ? `document.querySelector(${JSON.stringify(selector)})` : 'null'};
|
|
90
|
+
${(ref !== undefined && ref !== null) || selector ? "if (!el) return { error: 'gone' };" : ''}
|
|
91
|
+
const raw = el ? (el.getAttribute('href') || el.getAttribute('src') || el.currentSrc || el.getAttribute('data') || '') : ${JSON.stringify(url || '')};
|
|
92
|
+
if (!raw) return { error: 'nohref', tag: el ? el.tagName.toLowerCase() : '' };
|
|
93
|
+
const base = el ? el.ownerDocument.baseURI : document.baseURI;
|
|
94
|
+
let abs;
|
|
95
|
+
try { abs = new URL(raw, base).href; } catch { return { error: 'badurl', raw }; }
|
|
96
|
+
return { url: abs, page: location.href, ua: navigator.userAgent, lang: navigator.language,
|
|
97
|
+
suggested: (el && el.getAttribute('download')) || '' };
|
|
98
|
+
})()`
|
|
99
|
+
|
|
100
|
+
/** 在页面里:fetch 下来先放在 window.__dshDl[id],回大小和头 */
|
|
101
|
+
const FETCH_JS = (id, url) => `(async () => {
|
|
102
|
+
try {
|
|
103
|
+
const r = await fetch(${JSON.stringify(url)}, { credentials: 'include' });
|
|
104
|
+
if (!r.ok) return { status: r.status };
|
|
105
|
+
const len = Number(r.headers.get('content-length')) || 0;
|
|
106
|
+
if (len > ${PAGE_MAX}) return { tooBig: true };
|
|
107
|
+
const buf = new Uint8Array(await r.arrayBuffer());
|
|
108
|
+
if (buf.length > ${PAGE_MAX}) return { tooBig: true };
|
|
109
|
+
(window.__dshDl || (window.__dshDl = {}))[${JSON.stringify(id)}] = buf;
|
|
110
|
+
return { size: buf.length, type: r.headers.get('content-type') || '', disposition: r.headers.get('content-disposition') || '', finalUrl: r.url };
|
|
111
|
+
} catch (e) {
|
|
112
|
+
return { failed: String(e && e.message || e) };
|
|
113
|
+
}
|
|
114
|
+
})()`
|
|
115
|
+
|
|
116
|
+
const CHUNK_JS = (id, offset) => `(() => {
|
|
117
|
+
const b = window.__dshDl && window.__dshDl[${JSON.stringify(id)}];
|
|
118
|
+
if (!b) return null;
|
|
119
|
+
const part = b.subarray(${offset}, ${offset + CHUNK});
|
|
120
|
+
let s = '';
|
|
121
|
+
for (let i = 0; i < part.length; i += 0x8000) s += String.fromCharCode.apply(null, part.subarray(i, i + 0x8000));
|
|
122
|
+
return btoa(s);
|
|
123
|
+
})()`
|
|
124
|
+
|
|
125
|
+
const DROP_JS = (id) => `(() => { if (window.__dshDl) delete window.__dshDl[${JSON.stringify(id)}]; return true; })()`
|
|
126
|
+
|
|
127
|
+
/** ① 页面里取:成功回 { size, type, disposition, finalUrl };被拦了回 null(换第二条路) */
|
|
128
|
+
async function viaPage(call, tabId, url, file) {
|
|
129
|
+
const id = crypto.randomUUID()
|
|
130
|
+
const r = (await call('eval', { tabId, expression: FETCH_JS(id, url), awaitPromise: true, userGesture: false }, TIMEOUT_MS)).value || {}
|
|
131
|
+
if (r.status) throw new Error(`下载失败:服务器回 HTTP ${r.status}`)
|
|
132
|
+
if (r.failed || r.tooBig) return null
|
|
133
|
+
try {
|
|
134
|
+
const fd = fs.openSync(file, 'w')
|
|
135
|
+
try {
|
|
136
|
+
for (let off = 0; off < r.size; off += CHUNK) {
|
|
137
|
+
const b64 = (await call('eval', { tabId, expression: CHUNK_JS(id, off), userGesture: false })).value
|
|
138
|
+
if (typeof b64 !== 'string') throw new Error('页面跳走了,下载中断')
|
|
139
|
+
fs.writeSync(fd, Buffer.from(b64, 'base64'))
|
|
140
|
+
}
|
|
141
|
+
} finally {
|
|
142
|
+
fs.closeSync(fd)
|
|
143
|
+
}
|
|
144
|
+
} finally {
|
|
145
|
+
call('eval', { tabId, expression: DROP_JS(id), userGesture: false }).catch(() => {})
|
|
146
|
+
}
|
|
147
|
+
return r
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** ② 插件自己下,带上 Chrome 里这个网址的 Cookie(重定向每一跳都按新网址取) */
|
|
151
|
+
async function viaNode(call, tabId, target, file, fetchImpl = globalThis.fetch) {
|
|
152
|
+
const ctl = new AbortController()
|
|
153
|
+
const timer = setTimeout(() => ctl.abort(), TIMEOUT_MS)
|
|
154
|
+
try {
|
|
155
|
+
let url = target.url
|
|
156
|
+
let referer = target.page
|
|
157
|
+
for (let hop = 0; hop < 10; hop++) {
|
|
158
|
+
let cookie = ''
|
|
159
|
+
try {
|
|
160
|
+
const r = await call('cdp', { tabId, method: 'Network.getCookies', params: { urls: [url] } })
|
|
161
|
+
cookie = ((r.result && r.result.cookies) || []).map((c) => `${c.name}=${c.value}`).join('; ')
|
|
162
|
+
} catch {}
|
|
163
|
+
const res = await fetchImpl(url, {
|
|
164
|
+
redirect: 'manual',
|
|
165
|
+
signal: ctl.signal,
|
|
166
|
+
headers: {
|
|
167
|
+
'user-agent': target.ua || 'Mozilla/5.0',
|
|
168
|
+
'accept-language': target.lang || 'en',
|
|
169
|
+
accept: '*/*',
|
|
170
|
+
...(referer ? { referer } : {}),
|
|
171
|
+
...(cookie ? { cookie } : {}),
|
|
172
|
+
},
|
|
173
|
+
})
|
|
174
|
+
if (res.status >= 300 && res.status < 400 && res.headers.get('location')) {
|
|
175
|
+
referer = url
|
|
176
|
+
url = new URL(res.headers.get('location'), url).href
|
|
177
|
+
continue
|
|
178
|
+
}
|
|
179
|
+
if (!res.ok || !res.body) throw new Error(`下载失败:服务器回 HTTP ${res.status}`)
|
|
180
|
+
const out = fs.createWriteStream(file)
|
|
181
|
+
let size = 0
|
|
182
|
+
try {
|
|
183
|
+
for await (const chunk of res.body) {
|
|
184
|
+
size += chunk.length
|
|
185
|
+
if (!out.write(chunk)) await new Promise((r) => out.once('drain', r))
|
|
186
|
+
}
|
|
187
|
+
} finally {
|
|
188
|
+
await new Promise((r) => out.end(r))
|
|
189
|
+
}
|
|
190
|
+
return { size, type: res.headers.get('content-type') || '', disposition: res.headers.get('content-disposition') || '', finalUrl: url }
|
|
191
|
+
}
|
|
192
|
+
throw new Error('下载失败:重定向太多次')
|
|
193
|
+
} finally {
|
|
194
|
+
clearTimeout(timer)
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* @returns {{ file, size, type, via }}
|
|
200
|
+
* @param opts.dir 存到哪个文件夹(调用方已经定好)
|
|
201
|
+
*/
|
|
202
|
+
export async function download(call, tabId, { url, ref, selector, filename, dir }, deps = {}) {
|
|
203
|
+
if ((ref === undefined || ref === null) && !selector && !url) throw new Error('要给出 url、ref 或 selector 之一')
|
|
204
|
+
const target = (await call('eval', { tabId, expression: TARGET_JS({ ref, selector, url }), userGesture: false })).value
|
|
205
|
+
if (!target) throw new Error('页面没回应(可能刚跳转,重试一次)')
|
|
206
|
+
if (target.error === 'gone') throw new Error(ref !== undefined && ref !== null ? `编号 ${ref} 已失效——重新 browser_read what=snapshot` : `没找到元素: ${selector}`)
|
|
207
|
+
if (target.error === 'nohref') throw new Error(`这个 ${target.tag} 元素没有链接地址(href / src)。是按钮的话,先 browser_click 它,看会不会打开下载链接`)
|
|
208
|
+
if (target.error === 'badurl') throw new Error(`网址不对:${target.raw}`)
|
|
209
|
+
const proto = new URL(target.url).protocol
|
|
210
|
+
if (!['http:', 'https:', 'blob:', 'data:'].includes(proto)) throw new Error(`不支持这种网址:${proto}`)
|
|
211
|
+
|
|
212
|
+
fs.mkdirSync(dir, { recursive: true })
|
|
213
|
+
const part = path.join(dir, `.dsh-download-${crypto.randomUUID()}.part`)
|
|
214
|
+
try {
|
|
215
|
+
let via = 'page'
|
|
216
|
+
let meta = await viaPage(call, tabId, target.url, part)
|
|
217
|
+
if (!meta) {
|
|
218
|
+
if (proto === 'blob:' || proto === 'data:') throw new Error('页面里读不出这个文件(blob 链接可能已经失效:重新点一次生成它的按钮再试)')
|
|
219
|
+
via = 'direct'
|
|
220
|
+
meta = await viaNode(call, tabId, target, part, deps.fetch)
|
|
221
|
+
}
|
|
222
|
+
const name = pickName({ filename, disposition: meta.disposition, suggested: target.suggested, url: meta.finalUrl || target.url, type: meta.type })
|
|
223
|
+
const file = uniquePath(dir, name)
|
|
224
|
+
fs.renameSync(part, file)
|
|
225
|
+
return { file, size: meta.size, type: meta.type, via }
|
|
226
|
+
} finally {
|
|
227
|
+
try { fs.rmSync(part, { force: true }) } catch {}
|
|
228
|
+
}
|
|
229
|
+
}
|
package/index.js
CHANGED
|
@@ -18,11 +18,12 @@ import { fileURLToPath } from 'node:url'
|
|
|
18
18
|
import { AsyncLocalStorage } from 'node:async_hooks'
|
|
19
19
|
import { installImageGuard } from './image-guard.js'
|
|
20
20
|
import { ensureInstalled, installHint, assistInstall, paths, extensionId } from './setup.js'
|
|
21
|
-
import { snapshot, locate, focusShadow, elementBox } from './refs.js'
|
|
21
|
+
import { snapshot, locate, focusShadow, elementBox, selectInPage, frameTexts } from './refs.js'
|
|
22
22
|
import { consoleLog, networkLog, responseBody, clearLogs } from './devtools.js'
|
|
23
23
|
import { historyNav, waitUntil } from './nav.js'
|
|
24
24
|
import { PANEL_ROUTE, panelHandler } from './panel.js'
|
|
25
25
|
import { drag } from './drag.js'
|
|
26
|
+
import { download, downloadsDir, humanSize } from './download.js'
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
29
|
* 这里刻意不 import 任何外部包——不碰 `@deepseek-ai/dsh-tools`。
|
|
@@ -148,6 +149,7 @@ function hintOf(name, a = {}) {
|
|
|
148
149
|
return `${a.gone ? '等消失 ' : ''}${a.text ? `「${short(a.text, 20)}」` : a.url ? `网址 ${short(a.url, 30)}` : short(a.selector, 30)}`
|
|
149
150
|
case 'browser_dialog': return a.action || ''
|
|
150
151
|
case 'browser_drag': return `${el('from')} → ${el('to')}`
|
|
152
|
+
case 'browser_download': return a.ref !== undefined && a.ref !== null ? `[${a.ref}]` : short(a.selector || a.url || '', 50)
|
|
151
153
|
case 'browser_devtools': return [a.action, a.level && a.level !== 'all' ? a.level : '', a.filter ? `「${short(a.filter, 16)}」` : ''].filter(Boolean).join(' ')
|
|
152
154
|
default: return ''
|
|
153
155
|
}
|
|
@@ -545,7 +547,7 @@ export function apply(ctx, config) {
|
|
|
545
547
|
name: 'browser_read',
|
|
546
548
|
description:
|
|
547
549
|
'读页面内容。what=snapshot 列出页面上能点/能填的元素,每个带编号 [N]——要操作页面时先调它,' +
|
|
548
|
-
'之后 browser_click / browser_input 直接传 ref=N
|
|
550
|
+
'之后 browser_click / browser_input 直接传 ref=N,比猜选择器稳(同源 iframe 里的元素也会列出、也能按编号操作);' +
|
|
549
551
|
'text 取可见文字(抓内容首选);html 取外层 HTML;' +
|
|
550
552
|
'attr 取某个属性;info 取标题/URL/视口,并会告诉你有没有 alert 弹窗挡着(挡着的话先调 browser_dialog)。',
|
|
551
553
|
parameters: {
|
|
@@ -566,7 +568,16 @@ export function apply(ctx, config) {
|
|
|
566
568
|
}
|
|
567
569
|
case 'text': {
|
|
568
570
|
const r = await call('text', { tabId, selector: args.selector || undefined, limit })
|
|
569
|
-
|
|
571
|
+
let text = r.text || ''
|
|
572
|
+
// 整页读时把同源 iframe 里的字接在后面(innerText 不含框架内容);跨站的给一行提示
|
|
573
|
+
if (!args.selector) {
|
|
574
|
+
for (const f of await frameTexts(call, tabId).catch(() => [])) {
|
|
575
|
+
text += f.cross
|
|
576
|
+
? `\n\n[iframe] ${f.src}(跨站框架,读不到里面的字:browser_screenshot 看)`
|
|
577
|
+
: f.text ? `\n\n[iframe] ${f.src}\n${f.text}` : ''
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
return { text: clip(text.trim(), limit) || '(页面没有可见文字)' }
|
|
570
581
|
}
|
|
571
582
|
case 'html': {
|
|
572
583
|
const r = await call('html', { tabId, selector: args.selector || 'body', limit })
|
|
@@ -619,7 +630,7 @@ export function apply(ctx, config) {
|
|
|
619
630
|
const r = await call('clickEl', { tabId, selector: el.selector, ...withCursor() })
|
|
620
631
|
return { text: `已点击 [${args.ref}] ${r.target.tag}「${r.target.text}」@ (${r.x}, ${r.y})` }
|
|
621
632
|
}
|
|
622
|
-
// shadow DOM 里的元素(选择器够不着),或者要双击:按坐标点
|
|
633
|
+
// shadow DOM / iframe 里的元素(选择器够不着),或者要双击:按坐标点
|
|
623
634
|
const r = await call('click', { tabId, x: el.x, y: el.y, clickCount: count, ...withCursor() })
|
|
624
635
|
return { text: `已点击 [${args.ref}] ${el.tag}「${el.text}」@ (${r.x}, ${r.y})${count > 1 ? ` ×${count}` : ''}` }
|
|
625
636
|
}
|
|
@@ -667,14 +678,14 @@ export function apply(ctx, config) {
|
|
|
667
678
|
async execute(args, exec) {
|
|
668
679
|
const tabId = await resolveTab(args.tab)
|
|
669
680
|
if (args.action !== 'scroll') await emulateFocus(tabId)
|
|
670
|
-
// 有编号就先把它换成选择器;shadow DOM 里的元素换不成,下面各自按坐标/页内处理
|
|
681
|
+
// 有编号就先把它换成选择器;shadow DOM / iframe 里的元素换不成,下面各自按坐标/页内处理
|
|
671
682
|
const hasRef = args.ref !== undefined && args.ref !== null &&
|
|
672
683
|
['type', 'select', 'upload', 'focus', 'hover'].includes(args.action)
|
|
673
684
|
const el = hasRef ? await locate(call, tabId, args.ref) : null
|
|
674
685
|
const selector = el ? el.selector : args.selector
|
|
675
686
|
const target = hasRef ? `[${args.ref}]` : args.selector
|
|
676
687
|
const noShadow = (what) => {
|
|
677
|
-
if (el && el.shadow) throw new Error(`编号 ${args.ref} 在 shadow DOM 里,${what} 暂时不支持按编号——改用 browser_eval`)
|
|
688
|
+
if (el && el.shadow) throw new Error(`编号 ${args.ref} 在 shadow DOM 或 iframe 里,${what} 暂时不支持按编号——改用 browser_eval`)
|
|
678
689
|
}
|
|
679
690
|
switch (args.action) {
|
|
680
691
|
case 'type': {
|
|
@@ -695,7 +706,10 @@ export function apply(ctx, config) {
|
|
|
695
706
|
case 'select': {
|
|
696
707
|
if (!selector && !el) throw new Error('action=select 需要 ref 或 selector')
|
|
697
708
|
if (args.value === undefined) throw new Error('action=select 需要 value')
|
|
698
|
-
|
|
709
|
+
if (el && el.shadow) {
|
|
710
|
+
const r = await selectInPage(call, tabId, args.ref, args.value)
|
|
711
|
+
return { text: `已选择「${r.label}」(${r.value})` }
|
|
712
|
+
}
|
|
699
713
|
const r = await call('select', { tabId, selector, value: args.value })
|
|
700
714
|
return { text: `已选择「${r.label}」(${r.value})` }
|
|
701
715
|
}
|
|
@@ -812,9 +826,15 @@ export function apply(ctx, config) {
|
|
|
812
826
|
// 自己取框再直接截:扩展的 shot(selector) 取框只等 rAF,后台标签页里会卡满 15 秒
|
|
813
827
|
const box = await elementBox(call, tabId, { ref: hasRef ? args.ref : undefined, selector: args.selector })
|
|
814
828
|
if (!box || box.width < 1 || box.height < 1) throw new Error('这个元素没有大小(可能被隐藏了),截不了')
|
|
815
|
-
const
|
|
829
|
+
const capture = () => call('cdp', {
|
|
816
830
|
tabId, method: 'Page.captureScreenshot', params: { format, clip: { ...box, scale: 1 } },
|
|
817
831
|
}, 90000)
|
|
832
|
+
// Edge 无头偶尔第一次带 clip 的截图一直不回(之后的都正常):15 秒没回就再截一次,先发的那个结果不要了
|
|
833
|
+
const first = capture()
|
|
834
|
+
first.catch(() => {})
|
|
835
|
+
let timer
|
|
836
|
+
const late = new Promise((r) => { timer = setTimeout(r, 15000, null) })
|
|
837
|
+
const shot = (await Promise.race([first, late]).finally(() => clearTimeout(timer))) || (await capture())
|
|
818
838
|
const t = (await call('tabs')).find((x) => x.id === tabId)
|
|
819
839
|
r = { data: shot.result.data, format, url: t && t.url, title: t && t.title }
|
|
820
840
|
} else {
|
|
@@ -979,6 +999,46 @@ export function apply(ctx, config) {
|
|
|
979
999
|
},
|
|
980
1000
|
}),
|
|
981
1001
|
|
|
1002
|
+
// ── 下载 ────────────────────────────────────────────────────────────────
|
|
1003
|
+
defineTool({
|
|
1004
|
+
name: 'browser_download',
|
|
1005
|
+
description:
|
|
1006
|
+
'把链接指向的文件(发票、报表、PDF、图片……)下载到本机,带着用户在 Chrome 里的登录状态。' +
|
|
1007
|
+
'给 ref(snapshot 里的链接编号)、selector 或 url 三选一;相对地址按页面算,blob: / data: 链接也行。' +
|
|
1008
|
+
'默认存进「下载」文件夹,to=workdir 存进会话工作目录;同名不覆盖,自动加 (1)。' +
|
|
1009
|
+
'下载按钮不是链接(点了才生成文件)的话:先 browser_click 它,再用 browser_devtools action=network 找到文件网址,交给这里。',
|
|
1010
|
+
parameters: {
|
|
1011
|
+
ref: { type: 'integer', description: REF_DESC },
|
|
1012
|
+
selector: { type: 'string', description: 'CSS 选择器(指向 a / img / video / source 等带地址的元素)' },
|
|
1013
|
+
url: { type: 'string', description: '要下载的网址,可以是相对地址' },
|
|
1014
|
+
tab: { type: 'string', description: TAB_DESC },
|
|
1015
|
+
filename: { type: 'string', description: '存成什么名字;省略时用服务器给的名字或网址里的名字' },
|
|
1016
|
+
to: { type: 'string', enum: ['downloads', 'workdir'], description: 'downloads(默认)存进「下载」文件夹;workdir 存进会话工作目录' },
|
|
1017
|
+
},
|
|
1018
|
+
output: textOutput,
|
|
1019
|
+
presentCall: present('Download file'),
|
|
1020
|
+
async execute(args, exec) {
|
|
1021
|
+
const tabId = await resolveTab(args.tab)
|
|
1022
|
+
let dir = downloadsDir()
|
|
1023
|
+
if (args.to === 'workdir') {
|
|
1024
|
+
dir = sessionCwd(exec)
|
|
1025
|
+
if (!dir) throw new Error('拿不到会话工作目录,去掉 to=workdir 存进「下载」文件夹')
|
|
1026
|
+
}
|
|
1027
|
+
const r = await download(call, tabId, {
|
|
1028
|
+
url: args.url || undefined,
|
|
1029
|
+
ref: args.ref ?? undefined,
|
|
1030
|
+
selector: args.selector || undefined,
|
|
1031
|
+
filename: args.filename || undefined,
|
|
1032
|
+
dir,
|
|
1033
|
+
})
|
|
1034
|
+
const type = (r.type || '').split(';')[0].trim()
|
|
1035
|
+
const warn = /^text\/html/i.test(type)
|
|
1036
|
+
? '\n⚠️ 下到的是网页(text/html),多半是登录页或「下载即将开始」的中转页,不是文件本身:打开看看,或者换成真正的文件链接'
|
|
1037
|
+
: ''
|
|
1038
|
+
return { text: `已下载:${r.file}(${humanSize(r.size)}${type ? `,${type}` : ''})${warn}` }
|
|
1039
|
+
},
|
|
1040
|
+
}),
|
|
1041
|
+
|
|
982
1042
|
// ── 调试:控制台 / 网络 ──────────────────────────────────────────────────
|
|
983
1043
|
defineTool({
|
|
984
1044
|
name: 'browser_devtools',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-chrome-bridge",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.0",
|
|
4
4
|
"description": "DSH plugin: native browser_* tools that drive the Chrome you are already using — over native messaging + CDP. No WebSocket, no port, no Connect button. The native host and the MV3 extension ship inside this package and are installed automatically on first load; the only manual step left is picking ~/dsh-bridge-extension once at chrome://extensions (Chrome ≥137 has no programmatic extension install). Until then browser_* tools fail loudly with those exact steps.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"devtools.js",
|
|
39
39
|
"nav.js",
|
|
40
40
|
"drag.js",
|
|
41
|
+
"download.js",
|
|
41
42
|
"panel.js",
|
|
42
43
|
"cordis.patch.yml",
|
|
43
44
|
"client.js",
|
package/refs.js
CHANGED
|
@@ -8,8 +8,9 @@
|
|
|
8
8
|
* 编号怎么记:
|
|
9
9
|
* · 元素上打 data-dsh-ref="N" → 编号本身就是选择器 [data-dsh-ref="N"],
|
|
10
10
|
* 现成的 clickEl / type / select / upload / hover / shot 全都直接能用
|
|
11
|
-
* · 开放 shadow root 里的元素 document.querySelector 够不着,另记一份 WeakRef
|
|
12
|
-
* 在 window.__dshSnap.shadow
|
|
11
|
+
* · 开放 shadow root 里的元素、同源 iframe 里的元素 document.querySelector 够不着,另记一份 WeakRef
|
|
12
|
+
* 在 window.__dshSnap.shadow,动作时退回按坐标操作(框架里的坐标加上框架在页面上的位置)
|
|
13
|
+
* · 跨站的 iframe 读不到里面(浏览器不让),只列一行提示
|
|
13
14
|
* · 同一个元素再快照沿用旧编号(模型手里的旧编号继续有效);页面跳转后全部失效
|
|
14
15
|
*/
|
|
15
16
|
|
|
@@ -32,7 +33,9 @@ const SNAPSHOT_JS = (scope, maxItems) => `(() => {
|
|
|
32
33
|
const SKIP = new Set(['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEMPLATE', 'HEAD', 'META', 'LINK']);
|
|
33
34
|
const FORM = new Set(['INPUT', 'SELECT', 'TEXTAREA']);
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
// 框架里的元素按它自己那一页算样式
|
|
37
|
+
const css = (el) => (el.ownerDocument.defaultView || window).getComputedStyle(el);
|
|
38
|
+
const cursorOf = (el) => { try { return css(el).cursor } catch { return '' } };
|
|
36
39
|
const shown = (el, st) => {
|
|
37
40
|
const r = el.getBoundingClientRect();
|
|
38
41
|
if (r.width < 1 || r.height < 1) return false;
|
|
@@ -109,7 +112,7 @@ const SNAPSHOT_JS = (scope, maxItems) => `(() => {
|
|
|
109
112
|
const h = el.getAttribute('href');
|
|
110
113
|
if (!h || h.startsWith('javascript:')) return '';
|
|
111
114
|
try {
|
|
112
|
-
const u = new URL(h,
|
|
115
|
+
const u = new URL(h, el.baseURI);
|
|
113
116
|
return u.origin === location.origin ? (u.pathname + u.search + u.hash) : (u.host + u.pathname);
|
|
114
117
|
} catch { return h; }
|
|
115
118
|
};
|
|
@@ -154,15 +157,25 @@ const SNAPSHOT_JS = (scope, maxItems) => `(() => {
|
|
|
154
157
|
const lines = [];
|
|
155
158
|
let count = 0, more = 0, scanned = 0;
|
|
156
159
|
const MAX = ${Number(maxItems) || 300};
|
|
157
|
-
const walk = (parent) => {
|
|
160
|
+
const walk = (parent, depth = 0) => {
|
|
158
161
|
for (const el of parent.children) {
|
|
159
162
|
if (++scanned > 30000) return;
|
|
160
163
|
if (SKIP.has(el.tagName) || el.id === '__dsh_cursor__') continue;
|
|
161
164
|
let st;
|
|
162
|
-
try { st =
|
|
165
|
+
try { st = css(el); } catch { continue; }
|
|
163
166
|
if (st.display === 'none') continue;
|
|
164
167
|
if (el.tagName === 'IFRAME' || el.tagName === 'FRAME') {
|
|
165
|
-
if (shown(el, st))
|
|
168
|
+
if (!shown(el, st)) continue;
|
|
169
|
+
const label = '[iframe] ' + cut(el.getAttribute('src') || el.getAttribute('title') || el.getAttribute('name') || '', 80);
|
|
170
|
+
let doc = null;
|
|
171
|
+
try { doc = el.contentDocument; } catch {}
|
|
172
|
+
if (doc && doc.body && depth < 5) {
|
|
173
|
+
lines.push(label + ' ↓');
|
|
174
|
+
walk(doc.body, depth + 1);
|
|
175
|
+
lines.push('[/iframe]');
|
|
176
|
+
} else {
|
|
177
|
+
lines.push(label + '(跨站框架,读不到里面:browser_screenshot 看,按坐标 x/y 点)');
|
|
178
|
+
}
|
|
166
179
|
continue;
|
|
167
180
|
}
|
|
168
181
|
const hm = /^H([1-3])$/.exec(el.tagName);
|
|
@@ -179,8 +192,8 @@ const SNAPSHOT_JS = (scope, maxItems) => `(() => {
|
|
|
179
192
|
}
|
|
180
193
|
}
|
|
181
194
|
if (el.tagName === 'SELECT' || el.tagName === 'svg') continue;
|
|
182
|
-
walk(el);
|
|
183
|
-
if (el.shadowRoot) walk(el.shadowRoot);
|
|
195
|
+
walk(el, depth);
|
|
196
|
+
if (el.shadowRoot) walk(el.shadowRoot, depth);
|
|
184
197
|
}
|
|
185
198
|
};
|
|
186
199
|
walk(root);
|
|
@@ -198,7 +211,8 @@ const LOCATE_JS = (ref, wantPoint) => `(async () => {
|
|
|
198
211
|
el = w && w.deref();
|
|
199
212
|
shadow = true;
|
|
200
213
|
}
|
|
201
|
-
|
|
214
|
+
// 框架跳转过的话,旧元素还「连着」它那份已经作废的文档:defaultView 没了就算失效
|
|
215
|
+
if (!el || !el.isConnected || !el.ownerDocument.defaultView) return { gone: true };
|
|
202
216
|
// 密码框的 value 绝不拿出来(会进工具结果、上光标名牌)
|
|
203
217
|
const out = { shadow, selector: shadow ? null : sel, tag: el.tagName.toLowerCase(),
|
|
204
218
|
text: (el.innerText || (el.type === 'password' ? '' : el.value) || el.getAttribute('aria-label') || '').replace(/\\s+/g, ' ').trim().slice(0, 60) };
|
|
@@ -206,20 +220,33 @@ const LOCATE_JS = (ref, wantPoint) => `(async () => {
|
|
|
206
220
|
return { ...out, ...(await ${BOX_FN}(el)) };
|
|
207
221
|
})()`
|
|
208
222
|
|
|
209
|
-
/**
|
|
223
|
+
/**
|
|
224
|
+
* 页内函数:滚进视口,给出中点和框(整页视口坐标)。后台标签页会暂停 rAF,所以定时器兜底(和扩展里 __dsh_point 同一个坑)。
|
|
225
|
+
* 同源 iframe 里的元素:先由外到里把每层框架滚进视口,坐标再加上每层框架内容区在外层的位置(框 + 边框 + 内边距)。
|
|
226
|
+
*/
|
|
210
227
|
const BOX_FN = `(async (el) => {
|
|
228
|
+
const frames = [];
|
|
229
|
+
for (let w = el.ownerDocument.defaultView; w && w !== window && w.frameElement; w = w.parent) frames.push(w.frameElement);
|
|
230
|
+
for (let i = frames.length - 1; i >= 0; i--) frames[i].scrollIntoView({ block: 'center', inline: 'center', behavior: 'instant' });
|
|
211
231
|
el.scrollIntoView({ block: 'center', inline: 'center', behavior: 'instant' });
|
|
212
232
|
await new Promise((res) => { requestAnimationFrame(() => requestAnimationFrame(res)); setTimeout(res, 120); });
|
|
213
233
|
const r = el.getBoundingClientRect();
|
|
214
|
-
|
|
215
|
-
|
|
234
|
+
let left = r.left, top = r.top;
|
|
235
|
+
for (const f of frames) {
|
|
236
|
+
const fr = f.getBoundingClientRect();
|
|
237
|
+
const fs = f.ownerDocument.defaultView.getComputedStyle(f);
|
|
238
|
+
left += fr.left + f.clientLeft + (parseFloat(fs.paddingLeft) || 0);
|
|
239
|
+
top += fr.top + f.clientTop + (parseFloat(fs.paddingTop) || 0);
|
|
240
|
+
}
|
|
241
|
+
return { x: Math.round(left + r.width / 2), y: Math.round(top + r.height / 2),
|
|
242
|
+
box: { x: left, y: top, width: r.width, height: r.height } };
|
|
216
243
|
})`
|
|
217
244
|
|
|
218
|
-
/** 页内表达式:编号 → 元素(找不到是 null)。普通元素按属性找,shadow
|
|
245
|
+
/** 页内表达式:编号 → 元素(找不到是 null)。普通元素按属性找,shadow / 框架里的查 WeakRef 表。 */
|
|
219
246
|
export const refElementJs = (ref) => `(document.querySelector(${JSON.stringify(`[${ATTR}="${Number(ref)}"]`)}) || (() => {
|
|
220
247
|
const w = window.__dshSnap && window.__dshSnap.shadow.get(${Number(ref)});
|
|
221
248
|
const el = w && w.deref();
|
|
222
|
-
return el && el.isConnected ? el : null;
|
|
249
|
+
return el && el.isConnected && el.ownerDocument.defaultView ? el : null;
|
|
223
250
|
})())`
|
|
224
251
|
|
|
225
252
|
const goneError = (ref) =>
|
|
@@ -289,7 +316,7 @@ export async function focusShadow(call, tabId, ref) {
|
|
|
289
316
|
expression: `(() => {
|
|
290
317
|
const w = window.__dshSnap && window.__dshSnap.shadow.get(${n});
|
|
291
318
|
const el = w && w.deref();
|
|
292
|
-
if (!el || !el.isConnected) return null;
|
|
319
|
+
if (!el || !el.isConnected || !el.ownerDocument.defaultView) return null;
|
|
293
320
|
el.focus();
|
|
294
321
|
return el.getRootNode().activeElement === el;
|
|
295
322
|
})()`,
|
|
@@ -297,3 +324,55 @@ export async function focusShadow(call, tabId, ref) {
|
|
|
297
324
|
if (r.value === null) throw goneError(n)
|
|
298
325
|
if (!r.value) throw new Error(`编号 ${n} 聚焦失败(元素可能不可聚焦)`)
|
|
299
326
|
}
|
|
327
|
+
|
|
328
|
+
/** shadow DOM / 框架里的下拉框:直接在页面里选(扩展的 select 只认 document.querySelector 找得到的)。 */
|
|
329
|
+
export async function selectInPage(call, tabId, ref, value) {
|
|
330
|
+
const n = Number(ref)
|
|
331
|
+
const r = await call('eval', {
|
|
332
|
+
tabId,
|
|
333
|
+
expression: `(() => {
|
|
334
|
+
const el = ${refElementJs(n)};
|
|
335
|
+
if (!el) return null;
|
|
336
|
+
if (el.tagName !== 'SELECT') return { ok: false, why: '不是 <select> 元素' };
|
|
337
|
+
const v = ${JSON.stringify(String(value))};
|
|
338
|
+
const opts = [...el.options];
|
|
339
|
+
const hit = opts.find((o) => o.value === v) || opts.find((o) => (o.textContent || '').trim() === v);
|
|
340
|
+
if (!hit) return { ok: false, why: '没有这个选项', options: opts.map((o) => o.value).slice(0, 20) };
|
|
341
|
+
el.value = hit.value;
|
|
342
|
+
el.dispatchEvent(new Event('input', { bubbles: true }));
|
|
343
|
+
el.dispatchEvent(new Event('change', { bubbles: true }));
|
|
344
|
+
return { ok: true, value: hit.value, label: (hit.textContent || '').trim() };
|
|
345
|
+
})()`,
|
|
346
|
+
userGesture: false,
|
|
347
|
+
})
|
|
348
|
+
const v = r.value
|
|
349
|
+
if (v === null) throw goneError(n)
|
|
350
|
+
if (!v.ok) throw new Error(`选择失败:${v.why}${v.options ? '(可选值:' + v.options.join(', ') + ')' : ''}`)
|
|
351
|
+
return v
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/** 同源 iframe 里的可见文字(document.body.innerText 不含框架内容);跨站的只给一行提示。 */
|
|
355
|
+
export async function frameTexts(call, tabId) {
|
|
356
|
+
const r = await call('eval', {
|
|
357
|
+
tabId,
|
|
358
|
+
expression: `(() => {
|
|
359
|
+
const out = [];
|
|
360
|
+
const walk = (doc, depth) => {
|
|
361
|
+
for (const f of doc.querySelectorAll('iframe, frame')) {
|
|
362
|
+
const b = f.getBoundingClientRect();
|
|
363
|
+
if (b.width < 2 || b.height < 2) continue;
|
|
364
|
+
const src = (f.getAttribute('src') || f.getAttribute('title') || f.getAttribute('name') || '').slice(0, 120);
|
|
365
|
+
let d = null;
|
|
366
|
+
try { d = f.contentDocument; } catch {}
|
|
367
|
+
if (!d || !d.body) { out.push({ src, cross: true }); continue; }
|
|
368
|
+
out.push({ src, text: (d.body.innerText || '').trim() });
|
|
369
|
+
if (depth < 4) walk(d, depth + 1);
|
|
370
|
+
}
|
|
371
|
+
};
|
|
372
|
+
walk(document, 0);
|
|
373
|
+
return out.slice(0, 30);
|
|
374
|
+
})()`,
|
|
375
|
+
userGesture: false,
|
|
376
|
+
})
|
|
377
|
+
return Array.isArray(r.value) ? r.value : []
|
|
378
|
+
}
|
package/setup.js
CHANGED
|
@@ -147,13 +147,24 @@ export function storeExtension(home = os.homedir()) {
|
|
|
147
147
|
return null
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
/**
|
|
151
|
-
|
|
150
|
+
/**
|
|
151
|
+
* Windows 注册表里某一项的默认值;读不到回 null。
|
|
152
|
+
* 用 reg export 导出成 UTF-16 文件再读:reg query 的输出按控制台代码页编码,DSH 桌面版里没有控制台,中文路径会变成问号。
|
|
153
|
+
*/
|
|
154
|
+
export function regValue(key) {
|
|
155
|
+
const file = path.join(os.tmpdir(), `dsh-bridge-reg-${process.pid}.reg`)
|
|
152
156
|
try {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
+
execFileSync('reg', ['export', key, file, '/y'], { stdio: 'ignore', windowsHide: true })
|
|
158
|
+
return parseRegExport(fs.readFileSync(file, 'utf16le'))
|
|
159
|
+
} catch { return null } finally {
|
|
160
|
+
try { fs.rmSync(file, { force: true }) } catch {}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/** reg export 导出的文本里取默认值(@="…",反斜杠和引号是转义过的) */
|
|
165
|
+
export function parseRegExport(text) {
|
|
166
|
+
const m = /^@="((?:[^"\\]|\\.)*)"/m.exec(text)
|
|
167
|
+
return m ? m[1].replace(/\\(.)/g, '$1') : null
|
|
157
168
|
}
|
|
158
169
|
|
|
159
170
|
/**
|
package/vendor/skill/SKILL.md
CHANGED
|
@@ -12,12 +12,12 @@ whenToUse: 任务要在"用户已经登录的那个浏览器"里做事情,或
|
|
|
12
12
|
|
|
13
13
|
## 首选:`browser_*` 原生工具
|
|
14
14
|
|
|
15
|
-
装了 Chrome Bridge 插件就有这
|
|
15
|
+
装了 Chrome Bridge 插件就有这 12 个工具,比走 shell 快、也不用引号转义:
|
|
16
16
|
|
|
17
17
|
| 工具 | 用途 |
|
|
18
18
|
|---|---|
|
|
19
19
|
| `browser_tabs` | 列 / 找 / 开 / 关 / 切标签页(**先拿 tabId**) |
|
|
20
|
-
| `browser_read` | **`what=snapshot` 给能点/能填的元素编号 [N]
|
|
20
|
+
| `browser_read` | **`what=snapshot` 给能点/能填的元素编号 [N]**(要操作页面先调它;同源 iframe 里的元素也在里面,夹在 `[iframe] … ↓` 和 `[/iframe]` 之间);`text` 读可见文字;`html` / `attr` / `info`(info 会告诉你有没有弹窗挡着) |
|
|
21
21
|
| `browser_click` | 按 `ref`(编号,最稳)/ `selector` / `text` / 坐标点(真实鼠标事件) |
|
|
22
22
|
| `browser_input` | `type` / `key` / `select` / `upload` / `focus` / `hover` / `scroll` |
|
|
23
23
|
| `browser_nav` | `go` 跳转 / `back` 后退 / `forward` 前进 / `reload` 刷新,都等加载完 |
|
|
@@ -26,6 +26,7 @@ whenToUse: 任务要在"用户已经登录的那个浏览器"里做事情,或
|
|
|
26
26
|
| `browser_wait` | 等 `selector` 元素 / `text` 文字 / `url` 网址出现;`gone=true` 等它消失(加载圈) |
|
|
27
27
|
| `browser_dialog` | 放行 alert / confirm / prompt |
|
|
28
28
|
| `browser_drag` | 拖拽:起点终点各用 `ref` / `selector` / `text` / 坐标;放置区一般没编号,用 `toText` |
|
|
29
|
+
| `browser_download` | 下载文件:`ref` / `selector` / `url` 三选一,带用户的登录状态;默认存「下载」文件夹,`to=workdir` 存会话工作目录。下载按钮不是链接时,先点它,再从 `browser_devtools network` 里找文件网址 |
|
|
29
30
|
| `browser_devtools` | `console` 控制台 + JS 报错(`level=error` 只看报错)/ `network` 请求列表(`reload=true` 抓整页加载)/ `response` 看某个请求的返回内容 / `clear` |
|
|
30
31
|
|
|
31
32
|
## 备用:`cb` 命令行
|
|
@@ -66,6 +67,7 @@ cb cdp <tab> <方法> '{...}' # 原始 CDP 逃生口
|
|
|
66
67
|
7. **页面不对劲(点了没反应、数据没出来、白屏)先查 `browser_devtools`**:`console level=error` 看报错,
|
|
67
68
|
`network` 看接口是不是 4xx/5xx,再 `response` 看返回内容——别靠猜。
|
|
68
69
|
8. 等异步内容用 `browser_wait`(等文字 / 网址 / 加载圈消失),别干等。
|
|
70
|
+
9. **要文件就用 `browser_download`**,别去点浏览器的下载(存到哪、叫什么你都拿不到)。快照里写着「跨站框架」的 iframe 读不到里面:截图看,按坐标点。
|
|
69
71
|
|
|
70
72
|
## 什么时候别用它
|
|
71
73
|
|