chrome-devtools-mcp-for-extension 0.9.0 → 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.
|
@@ -12,38 +12,30 @@ export async function findExtensionIdViaTargets(cdp) {
|
|
|
12
12
|
}
|
|
13
13
|
export async function waitForFrameByUrlMatch(cdp, pattern, timeoutMs = 5000) {
|
|
14
14
|
await cdp.send('Page.enable');
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (hit)
|
|
19
|
-
return hit;
|
|
20
|
-
// Then wait for navigation events
|
|
15
|
+
await cdp.send('Runtime.enable');
|
|
16
|
+
await cdp.send('DOM.enable');
|
|
17
|
+
// Strategy: Use Page.getFrameTree and match by pattern
|
|
21
18
|
const start = Date.now();
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
function onTimeout() {
|
|
31
|
-
cleanup();
|
|
32
|
-
reject(new Error(`Timeout waiting for frame by url match: ${pattern}`));
|
|
19
|
+
while (Date.now() - start < timeoutMs) {
|
|
20
|
+
try {
|
|
21
|
+
const tree = await cdp.send('Page.getFrameTree');
|
|
22
|
+
const hit = findFrameByPattern(tree.frameTree, pattern);
|
|
23
|
+
if (hit)
|
|
24
|
+
return hit;
|
|
33
25
|
}
|
|
34
|
-
|
|
35
|
-
|
|
26
|
+
catch (e) {
|
|
27
|
+
// Frame tree may not be ready yet, continue waiting
|
|
36
28
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
});
|
|
41
|
-
function
|
|
29
|
+
// Wait a bit before retry
|
|
30
|
+
await new Promise(resolve => setTimeout(resolve, 100));
|
|
31
|
+
}
|
|
32
|
+
throw new Error(`Timeout waiting for iframe by url match: ${pattern}`);
|
|
33
|
+
function findFrameByPattern(node, rx) {
|
|
42
34
|
if (node?.frame?.url && rx.test(node.frame.url)) {
|
|
43
35
|
return { frameId: node.frame.id, frameUrl: node.frame.url };
|
|
44
36
|
}
|
|
45
37
|
for (const c of node.childFrames ?? []) {
|
|
46
|
-
const r =
|
|
38
|
+
const r = findFrameByPattern(c, rx);
|
|
47
39
|
if (r)
|
|
48
40
|
return r;
|
|
49
41
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chrome-devtools-mcp-for-extension",
|
|
3
|
-
"version": "0.9.
|
|
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",
|