update QUICK_START pdf, userscript v0.31, tmwebdriver postMessage docs

This commit is contained in:
Liang Jiaqing
2026-02-26 18:11:43 +08:00
parent 06f7f630e4
commit e30ee43298
3 changed files with 11 additions and 2 deletions

Binary file not shown.

View File

@@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name ljq_web_driver // @name ljq_web_driver
// @namespace http://tampermonkey.net/ // @namespace http://tampermonkey.net/
// @version 0.3 // @version 0.31
// @description Execute JS via ljq_web_driver // @description Execute JS via ljq_web_driver
// @require https://code.jquery.com/jquery-3.6.0.min.js // @require https://code.jquery.com/jquery-3.6.0.min.js
// @author You // @author You

View File

@@ -49,3 +49,12 @@ fetch('PDF_URL').then(r=>r.blob()).then(b=>{
- 备选:`window.open(location.href,'_blank')` 前台开新标签→win32截图→完后close - 备选:`window.open(location.href,'_blank')` 前台开新标签→win32截图→完后close
- GM_openInTab在web_execute_js不可用非油猴上下文 - GM_openInTab在web_execute_js不可用非油猴上下文
- 浏览器无JS API切标签页只能开新的来保证前台 - 浏览器无JS API切标签页只能开新的来保证前台
## 跨域iframe操控(postMessage中继)
- 跨域iframe的contentDocument不可访问web_execute_js只在顶层执行
- TM脚本已改造iframe内不return改为监听postMessage并eval执行+回传结果
- 顶层发送:`iframe.contentWindow.postMessage({type:'ljq_exec', id, code}, '*')`
- iframe回传`{type:'ljq_result', id, result}` 通过window.addEventListener('message')接收
- ⚠只能eval表达式不支持return/函数体包装,构造代码时注意
- 流程发postMessage→等→读window._ljqResults[id]获取结果
- 已验证读取iframe内DOM(document.title)、填写input均成功