feat: CDP bridge extension integration - ext_ws session type, DOM-channel CDP/batch/cookies/tabs, autofill bringToFront fix, await support in SOP
This commit is contained in:
@@ -5,9 +5,9 @@
|
||||
- 非Selenium/Playwright,不需调试浏览器或新数据目录
|
||||
- 支撑 `web_scan`(只读DOM) / `web_execute_js`(执行JS) 等高层工具
|
||||
|
||||
## 通用限制
|
||||
- ⚠web_execute_js中**禁止使用await**,会报SyntaxError(非async上下文)(BBS#34验证)
|
||||
- 需要异步操作时用`.then()`链式调用或回调
|
||||
## 通用特性
|
||||
- ✅web_execute_js**完美支持顶层await**(v0.4+),可直接`await fetch()`/`await new Promise()`等
|
||||
- ⚠使用await时需**显式`return`**才能拿到返回值(底层async包裹,不写return则返回null)
|
||||
|
||||
## 限制(isTrusted)
|
||||
- JS dispatch的事件`isTrusted=false`,敏感操作(文件上传/部分按钮)会被浏览器拦截
|
||||
@@ -53,7 +53,7 @@ fetch('PDF_URL').then(r=>r.blob()).then(b=>{
|
||||
⚠TID密钥:首次运行自动生成到`assets/tmwd_cdp_bridge/config.js`(已gitignore),扩展通过manifest引用
|
||||
调用:MutationObserver监听addedNodes(id=TID),⚠每次必须remove旧→createElement新→设textContent JSON→appendChild
|
||||
```js
|
||||
// TID从assets/tmwd_cdp_bridge/config.js读取,示例用'__ljq_ctrl'占位
|
||||
// TID从assets/tmwd_cdp_bridge/config.js读取
|
||||
const old = document.getElementById(TID);
|
||||
if (old) old.remove();
|
||||
const el = document.createElement('div');
|
||||
@@ -128,14 +128,16 @@ document.body.appendChild(el); // 响应写回el.textContent
|
||||
|
||||
## autofill获取与登录 (需 v0.4+ 脚本支持 await)
|
||||
检测:web_scan输出input带`data-autofilled="true"`,value显示为受保护提示(非真实值,Chrome安全保护需点击释放)
|
||||
- ⭐**一键释放与登录**:利用 v0.4 脚本的顶层 `await`,在单次 `web_execute_js` 中连贯完成:
|
||||
1. JS获取输入框坐标。
|
||||
2. CDP发送 `Input.dispatchMouseEvent` (mousePressed) 物理点击释放autofill。
|
||||
3. `await new Promise(r => setTimeout(r, 500))` 等待释放。
|
||||
4. 派发 `input`/`change` 事件唤醒前端框架(解禁登录按钮)。
|
||||
5. 触发登录点击。
|
||||
- ⚠**前置条件:必须先CDP `Page.bringToFront` 切tab到前台**,Chrome仅在前台tab释放autofill保护值,后台tab物理点击无效
|
||||
- ⭐**一键释放与登录**:利用顶层 `await`,在单次 `web_execute_js` 中连贯完成:
|
||||
1. CDP batch发送 `Page.bringToFront` 切到前台。
|
||||
2. JS获取输入框坐标。
|
||||
3. CDP发送 `Input.dispatchMouseEvent` (mousePressed) 物理点击释放autofill。
|
||||
4. `await new Promise(r => setTimeout(r, 500))` 等待释放。
|
||||
5. 派发 `input`/`change` 事件唤醒前端框架(解禁登录按钮)。
|
||||
6. 触发登录点击。
|
||||
- ⚠只需 `mousePressed`,无需 `mouseReleased`。点击一个字段即释放全页。
|
||||
- ⚠已淘汰旧版跨 tab 查 tabId 或 Python 轮询的繁琐流程,直接在当前页异步完成。
|
||||
- ⚠使用await时需显式`return`返回值,否则async包裹层默认返回null。
|
||||
|
||||
## 验证码/页面视觉截图
|
||||
- ⭐首选CDP截图:`Page.captureScreenshot`(format:'png')→返回base64,无需前台/后台tab也行,全页高清
|
||||
|
||||
Reference in New Issue
Block a user