feat(text): 'get text --pierce' reads through CLOSED shadow DOM (#30)
Some injected UI (browser-extension debug panels, web components) renders into a CLOSED shadow root that eval/innerText cannot read. --pierce walks the CDP DOM tree (DOM.getDocument depth:-1 pierce:true), which includes closed shadow roots and child documents, and collects text nodes (skipping script/style/etc). Review-safe: rides the per-tab debugger session already attached, no new Chrome permission and no ab-connect/extension change — so it works in extension-relay mode without touching the published extension. Verified live: a closed-shadow panel that main-world eval reports HIDDEN is read in full via --pierce. First slice of #30 (read extension/injected-panel content). Deeper extension introspection (background SW / chrome.storage) stays a launch-mode / raw-CDP concern, deliberately NOT done by expanding ab-connect's debugger powers.
This commit is contained in:
@@ -3628,6 +3628,15 @@ async fn handle_gettext(cmd: &Value, state: &mut DaemonState) -> Result<Value, S
|
||||
}));
|
||||
}
|
||||
|
||||
// `get text --pierce` reads text through CLOSED shadow roots and child
|
||||
// documents via the CDP DOM tree — content `innerText`/`eval` can't see,
|
||||
// e.g. an extension's injected panel in a closed shadow DOM (#30).
|
||||
if cmd.get("pierce").and_then(|v| v.as_bool()) == Some(true) {
|
||||
let text = super::element::get_pierced_text(&mgr.client, &session_id).await?;
|
||||
let url = mgr.get_url().await.unwrap_or_default();
|
||||
return Ok(json!({ "text": text, "origin": url, "pierce": true }));
|
||||
}
|
||||
|
||||
// `get text --main` returns the page's main-content region (readability-lite),
|
||||
// skipping global header/nav/footer/sidebar boilerplate (#27).
|
||||
if cmd.get("main").and_then(|v| v.as_bool()) == Some(true) {
|
||||
|
||||
Reference in New Issue
Block a user