chrome-devtools-mcp-for-extension 0.9.6 → 0.9.7
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,45 +69,54 @@ export async function inspectIframe(cdp, urlPattern, waitMs = 8000) {
|
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
71
|
catch (oopifError) {
|
|
72
|
-
// Fallback:
|
|
73
|
-
await cdp.send('
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
72
|
+
// Fallback: Access iframe content through parent page's DOM
|
|
73
|
+
await cdp.send('Runtime.enable');
|
|
74
|
+
const iframeAccessScript = `
|
|
75
|
+
(function() {
|
|
76
|
+
const pattern = ${urlPattern};
|
|
77
|
+
const iframes = Array.from(document.querySelectorAll('iframe'));
|
|
78
|
+
|
|
79
|
+
for (const iframe of iframes) {
|
|
80
|
+
if (pattern.test(iframe.src)) {
|
|
81
|
+
try {
|
|
82
|
+
// Try to access contentDocument/contentWindow
|
|
83
|
+
const doc = iframe.contentDocument || iframe.contentWindow?.document;
|
|
84
|
+
if (doc) {
|
|
85
|
+
return {
|
|
86
|
+
success: true,
|
|
87
|
+
src: iframe.src,
|
|
88
|
+
html: doc.documentElement.outerHTML
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
} catch (securityError) {
|
|
92
|
+
// If blocked by same-origin policy, return error details
|
|
93
|
+
return {
|
|
94
|
+
success: false,
|
|
95
|
+
src: iframe.src,
|
|
96
|
+
error: 'SecurityError: ' + securityError.message
|
|
97
|
+
};
|
|
91
98
|
}
|
|
99
|
+
}
|
|
92
100
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
await cdp.send('Runtime.
|
|
101
|
-
|
|
102
|
-
expression: 'document.documentElement.outerHTML',
|
|
101
|
+
|
|
102
|
+
return {
|
|
103
|
+
success: false,
|
|
104
|
+
error: 'Iframe not found matching pattern: ' + pattern.toString()
|
|
105
|
+
};
|
|
106
|
+
})()
|
|
107
|
+
`;
|
|
108
|
+
const evalResult = await cdp.send('Runtime.evaluate', {
|
|
109
|
+
expression: iframeAccessScript,
|
|
103
110
|
returnByValue: true,
|
|
104
|
-
contextId: executionContextId,
|
|
105
111
|
});
|
|
106
|
-
const
|
|
112
|
+
const data = evalResult?.result?.value;
|
|
113
|
+
if (!data?.success) {
|
|
114
|
+
throw new Error(`Iframe access failed: ${data?.error || 'Unknown error'}`);
|
|
115
|
+
}
|
|
107
116
|
return {
|
|
108
|
-
frameId:
|
|
109
|
-
frameUrl:
|
|
110
|
-
html,
|
|
117
|
+
frameId: null,
|
|
118
|
+
frameUrl: data.src || '',
|
|
119
|
+
html: data.html || '',
|
|
111
120
|
};
|
|
112
121
|
}
|
|
113
122
|
}
|
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.7",
|
|
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",
|