chrome-devtools-mcp-for-extension 0.9.1 → 0.9.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.
@@ -14,54 +14,28 @@ export async function waitForFrameByUrlMatch(cdp, pattern, timeoutMs = 5000) {
14
14
  await cdp.send('Page.enable');
15
15
  await cdp.send('Runtime.enable');
16
16
  await cdp.send('DOM.enable');
17
- // Strategy: Find iframe in DOM, then match Frame ID
17
+ // Strategy: Use Page.getFrameTree and match by pattern
18
18
  const start = Date.now();
19
19
  while (Date.now() - start < timeoutMs) {
20
20
  try {
21
- // Get document root
22
- const { root } = await cdp.send('DOM.getDocument', { depth: -1 });
23
- // Query all iframes
24
- const { nodeIds } = await cdp.send('DOM.querySelectorAll', {
25
- nodeId: root.nodeId,
26
- selector: 'iframe',
27
- });
28
- // Check each iframe's src
29
- for (const nodeId of nodeIds) {
30
- const attrs = await cdp.send('DOM.getAttributes', { nodeId });
31
- const srcIndex = attrs.attributes.indexOf('src');
32
- if (srcIndex >= 0 && srcIndex + 1 < attrs.attributes.length) {
33
- const src = attrs.attributes[srcIndex + 1];
34
- if (pattern.test(src)) {
35
- // Get contentDocument frame ID
36
- const { node } = await cdp.send('DOM.describeNode', { nodeId });
37
- if (node.contentDocument) {
38
- const frameId = node.contentDocument.frameId || node.frameId;
39
- if (frameId) {
40
- return { frameId, frameUrl: src };
41
- }
42
- }
43
- // Fallback: try Frame Tree match
44
- const tree = await cdp.send('Page.getFrameTree');
45
- const hit = findFrameByUrl(tree.frameTree, src);
46
- if (hit)
47
- return hit;
48
- }
49
- }
50
- }
21
+ const tree = await cdp.send('Page.getFrameTree');
22
+ const hit = findFrameByPattern(tree.frameTree, pattern);
23
+ if (hit)
24
+ return hit;
51
25
  }
52
26
  catch (e) {
53
- // DOM may not be ready yet, continue waiting
27
+ // Frame tree may not be ready yet, continue waiting
54
28
  }
55
29
  // Wait a bit before retry
56
30
  await new Promise(resolve => setTimeout(resolve, 100));
57
31
  }
58
32
  throw new Error(`Timeout waiting for iframe by url match: ${pattern}`);
59
- function findFrameByUrl(node, url) {
60
- if (node?.frame?.url === url) {
33
+ function findFrameByPattern(node, rx) {
34
+ if (node?.frame?.url && rx.test(node.frame.url)) {
61
35
  return { frameId: node.frame.id, frameUrl: node.frame.url };
62
36
  }
63
37
  for (const c of node.childFrames ?? []) {
64
- const r = findFrameByUrl(c, url);
38
+ const r = findFrameByPattern(c, rx);
65
39
  if (r)
66
40
  return r;
67
41
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chrome-devtools-mcp-for-extension",
3
- "version": "0.9.1",
3
+ "version": "0.9.2",
4
4
  "description": "MCP server for Chrome extension development with Web Store automation. Fork of chrome-devtools-mcp with extension-specific tools.",
5
5
  "type": "module",
6
6
  "bin": "./build/src/index.js",