chrome-devtools-mcp-for-extension 0.18.2 → 0.18.4
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.
- package/build/src/tools/gemini-web.js +19 -11
- package/package.json +1 -1
|
@@ -181,27 +181,30 @@ export const askGeminiWeb = defineTool({
|
|
|
181
181
|
response.appendResponseLine('質問を送信中...');
|
|
182
182
|
// Input text using the textbox element
|
|
183
183
|
// Gemini uses a textbox with role="textbox" or a div with contenteditable
|
|
184
|
+
// NOTE: Gemini has Trusted Types CSP, so we cannot use innerHTML directly
|
|
184
185
|
const questionSent = await page.evaluate((questionText) => {
|
|
186
|
+
// Helper to clear element content without innerHTML (CSP-safe)
|
|
187
|
+
const clearElement = (el) => {
|
|
188
|
+
while (el.firstChild) {
|
|
189
|
+
el.removeChild(el.firstChild);
|
|
190
|
+
}
|
|
191
|
+
};
|
|
185
192
|
// Try textbox first (Gemini's current implementation)
|
|
186
193
|
const textbox = document.querySelector('[role="textbox"]');
|
|
187
194
|
if (textbox) {
|
|
188
195
|
textbox.focus();
|
|
189
|
-
// Clear existing content
|
|
190
|
-
textbox
|
|
191
|
-
// Insert text
|
|
192
|
-
|
|
193
|
-
p.textContent = questionText;
|
|
194
|
-
textbox.appendChild(p);
|
|
196
|
+
// Clear existing content (CSP-safe)
|
|
197
|
+
clearElement(textbox);
|
|
198
|
+
// Insert text using textContent (CSP-safe)
|
|
199
|
+
textbox.textContent = questionText;
|
|
195
200
|
textbox.dispatchEvent(new Event('input', { bubbles: true }));
|
|
196
201
|
return true;
|
|
197
202
|
}
|
|
198
203
|
// Fallback to contenteditable
|
|
199
204
|
const editor = document.querySelector('div[contenteditable="true"]');
|
|
200
205
|
if (editor) {
|
|
201
|
-
editor
|
|
202
|
-
|
|
203
|
-
p.textContent = questionText;
|
|
204
|
-
editor.appendChild(p);
|
|
206
|
+
clearElement(editor);
|
|
207
|
+
editor.textContent = questionText;
|
|
205
208
|
editor.dispatchEvent(new Event('input', { bubbles: true }));
|
|
206
209
|
return true;
|
|
207
210
|
}
|
|
@@ -251,12 +254,17 @@ export const askGeminiWeb = defineTool({
|
|
|
251
254
|
const stopButton = buttons.find(b => b.textContent?.includes('回答を停止') ||
|
|
252
255
|
b.textContent?.includes('Stop') ||
|
|
253
256
|
b.getAttribute('aria-label')?.includes('Stop'));
|
|
257
|
+
// Check for "プロンプトを送信" button - this indicates response is complete
|
|
258
|
+
const sendButton = buttons.find(b => b.textContent?.includes('プロンプトを送信') ||
|
|
259
|
+
b.getAttribute('aria-label')?.includes('プロンプトを送信') ||
|
|
260
|
+
b.getAttribute('aria-label')?.includes('Send message'));
|
|
254
261
|
// Check for status text
|
|
255
262
|
const bodyText = document.body.innerText;
|
|
256
263
|
const isTyping = bodyText.includes('Gemini が入力中です') ||
|
|
257
264
|
bodyText.includes('Gemini is typing');
|
|
258
265
|
const isComplete = bodyText.includes('Gemini が回答しました') ||
|
|
259
|
-
bodyText.includes('Gemini has responded')
|
|
266
|
+
bodyText.includes('Gemini has responded') ||
|
|
267
|
+
!!sendButton; // "プロンプトを送信" button indicates completion
|
|
260
268
|
const isGenerating = !!stopButton || isTyping;
|
|
261
269
|
// Get the response content from model-response elements
|
|
262
270
|
const modelResponses = Array.from(document.querySelectorAll('model-response'));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chrome-devtools-mcp-for-extension",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.4",
|
|
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": "./scripts/cli.mjs",
|