chrome-devtools-mcp-for-extension 0.9.4 → 0.9.6
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.
|
@@ -69,37 +69,44 @@ export async function inspectIframe(cdp, urlPattern, waitMs = 8000) {
|
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
71
|
catch (oopifError) {
|
|
72
|
-
// Fallback: Try regular iframe via
|
|
73
|
-
await cdp.send('
|
|
74
|
-
const {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
72
|
+
// Fallback: Try regular iframe via DOM.querySelectorAll
|
|
73
|
+
await cdp.send('DOM.enable');
|
|
74
|
+
const { root } = await cdp.send('DOM.getDocument', { depth: -1 });
|
|
75
|
+
// Query all iframes
|
|
76
|
+
const { nodeIds } = await cdp.send('DOM.querySelectorAll', {
|
|
77
|
+
nodeId: root.nodeId,
|
|
78
|
+
selector: 'iframe',
|
|
79
|
+
});
|
|
80
|
+
// Find the iframe matching the pattern
|
|
81
|
+
let targetFrameId = null;
|
|
82
|
+
let targetFrameUrl = null;
|
|
83
|
+
for (const nodeId of nodeIds) {
|
|
84
|
+
const { node } = await cdp.send('DOM.describeNode', { nodeId });
|
|
85
|
+
const src = node.attributes?.find((attr, i, arr) => attr === 'src' && arr[i + 1]);
|
|
86
|
+
const srcValue = src ? node.attributes[node.attributes.indexOf(src) + 1] : '';
|
|
87
|
+
if (urlPattern.test(srcValue)) {
|
|
88
|
+
targetFrameId = node.frameId || null;
|
|
89
|
+
targetFrameUrl = srcValue;
|
|
90
|
+
break;
|
|
85
91
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const frame = findFrame(frameTree);
|
|
89
|
-
if (!frame) {
|
|
92
|
+
}
|
|
93
|
+
if (!targetFrameId || !targetFrameUrl) {
|
|
90
94
|
throw new Error(`Iframe not found (tried both OOPIF and regular iframe): ${urlPattern}`);
|
|
91
95
|
}
|
|
92
|
-
// Execute in the frame context
|
|
96
|
+
// Execute in the frame context using Page.createIsolatedWorld
|
|
97
|
+
const { executionContextId } = await cdp.send('Page.createIsolatedWorld', {
|
|
98
|
+
frameId: targetFrameId,
|
|
99
|
+
});
|
|
93
100
|
await cdp.send('Runtime.enable');
|
|
94
101
|
const htmlResult = await cdp.send('Runtime.evaluate', {
|
|
95
102
|
expression: 'document.documentElement.outerHTML',
|
|
96
103
|
returnByValue: true,
|
|
97
|
-
contextId:
|
|
104
|
+
contextId: executionContextId,
|
|
98
105
|
});
|
|
99
106
|
const html = String(htmlResult?.result?.value ?? '');
|
|
100
107
|
return {
|
|
101
|
-
frameId:
|
|
102
|
-
frameUrl:
|
|
108
|
+
frameId: targetFrameId,
|
|
109
|
+
frameUrl: targetFrameUrl,
|
|
103
110
|
html,
|
|
104
111
|
};
|
|
105
112
|
}
|
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.6",
|
|
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",
|