chrome-devtools-mcp-for-extension 0.8.6 → 0.8.8

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.
@@ -277,13 +277,16 @@ export const reloadExtension = defineTool({
277
277
  if (shadowRoot) {
278
278
  const name = shadowRoot.querySelector('#name')?.textContent?.trim() || '';
279
279
  if (name.toLowerCase().includes(searchName.toLowerCase())) {
280
- // Try multiple selectors for reload button
281
- let reloadButton = shadowRoot.querySelector('#reload-button');
280
+ // Try multiple selectors for reload button (dev-reload-button in developer mode)
281
+ let reloadButton = shadowRoot.querySelector('#dev-reload-button');
282
282
  if (!reloadButton) {
283
- reloadButton = shadowRoot.querySelector('cr-icon-button[id="reload-button"]');
283
+ reloadButton = shadowRoot.querySelector('#reload-button');
284
+ }
285
+ if (!reloadButton) {
286
+ // Try finding by aria-label (supports both English and Japanese)
287
+ reloadButton = shadowRoot.querySelector('[aria-label*="再読み込み"]');
284
288
  }
285
289
  if (!reloadButton) {
286
- // Try finding by aria-label or title
287
290
  reloadButton = shadowRoot.querySelector('[aria-label*="Reload"]');
288
291
  }
289
292
  if (reloadButton && !reloadButton.hasAttribute('hidden')) {
@@ -445,7 +448,7 @@ export const toggleExtensionState = defineTool({
445
448
  });
446
449
  export const openExtensionPopup = defineTool({
447
450
  name: 'open_extension_popup',
448
- description: `Open a Chrome extension's popup in a testable context. The popup will be opened as a page that can be interacted with using standard tools like take_snapshot, click, and evaluate_script.`,
451
+ description: `Select an already-opened Chrome extension popup window for testing. The user should manually click the extension icon first to open the popup, then this tool will detect and select it. After selection, you can use take_snapshot, click, evaluate_script, etc. on the popup.`,
449
452
  annotations: {
450
453
  category: ToolCategories.EXTENSION_DEVELOPMENT,
451
454
  readOnlyHint: false,
@@ -491,54 +494,38 @@ export const openExtensionPopup = defineTool({
491
494
  }
492
495
  response.appendResponseLine(`🔍 Found extension: ${extensionInfo.name} (${extensionInfo.id})`);
493
496
  try {
494
- // Find service worker target
495
497
  const browser = page.browser();
496
498
  if (!browser) {
497
499
  response.appendResponseLine('❌ Failed to get browser instance.');
498
500
  return;
499
501
  }
500
- const targets = await browser.targets();
501
- const workerTarget = targets.find((target) => target.type() === 'service_worker' &&
502
- target.url().includes(extensionInfo.id));
503
- if (!workerTarget) {
504
- response.appendResponseLine('❌ Service worker not found. Extension may not have a service worker (MV2 extensions are not supported).');
505
- return;
506
- }
507
- const worker = await workerTarget.worker();
508
- if (!worker) {
509
- response.appendResponseLine('❌ Failed to get service worker context.');
510
- return;
511
- }
512
- response.appendResponseLine('🔧 Opening popup via service worker...');
513
- // Open popup
514
- await worker.evaluate('chrome.action.openPopup();');
515
- // Wait for popup target
516
- const popupTarget = await browser.waitForTarget((target) => target.type() === 'page' &&
517
- target.url().includes(extensionInfo.id) &&
518
- target.url().includes('popup'), { timeout: 5000 });
519
- if (!popupTarget) {
520
- response.appendResponseLine('❌ Popup did not open within timeout.');
521
- return;
502
+ response.appendResponseLine('🔧 Looking for open popup window...');
503
+ // Get all pages
504
+ const pages = await browser.pages();
505
+ // Find popup page by URL (contains extension ID)
506
+ let popupPage = null;
507
+ let popupIndex = -1;
508
+ for (let i = 0; i < pages.length; i++) {
509
+ const p = pages[i];
510
+ const url = p.url();
511
+ if (url && url.includes(extensionInfo.id)) {
512
+ popupPage = p;
513
+ popupIndex = i;
514
+ break;
515
+ }
522
516
  }
523
- const popupPage = await popupTarget.page();
524
517
  if (!popupPage) {
525
- response.appendResponseLine('❌ Failed to get popup page reference.');
518
+ response.appendResponseLine('❌ Popup window not found.');
519
+ response.appendResponseLine('💡 Please manually click the extension icon to open the popup first.');
526
520
  return;
527
521
  }
528
- // Add popup page to context and select it
529
- const pages = await browser.pages();
530
- const popupIndex = pages.indexOf(popupPage);
531
- if (popupIndex !== -1) {
532
- context.setSelectedPageIdx(popupIndex);
533
- response.appendResponseLine('');
534
- response.appendResponseLine(`✅ Popup opened: ${extensionInfo.name}`);
535
- response.appendResponseLine(`📄 Popup URL: ${popupPage.url()}`);
536
- response.appendResponseLine('');
537
- response.appendResponseLine('💡 You can now use take_snapshot, click, evaluate_script, etc. on the popup');
538
- }
539
- else {
540
- response.appendResponseLine('⚠️ Popup opened but could not be selected automatically.');
541
- }
522
+ // Select the popup page
523
+ context.setSelectedPageIdx(popupIndex);
524
+ response.appendResponseLine('');
525
+ response.appendResponseLine(`✅ Popup window selected: ${extensionInfo.name}`);
526
+ response.appendResponseLine(`📄 Popup URL: ${popupPage.url()}`);
527
+ response.appendResponseLine('');
528
+ response.appendResponseLine('💡 You can now use take_snapshot, click, evaluate_script, etc. on the popup');
542
529
  }
543
530
  catch (error) {
544
531
  response.appendResponseLine(`❌ Error: ${error instanceof Error ? error.message : String(error)}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chrome-devtools-mcp-for-extension",
3
- "version": "0.8.6",
3
+ "version": "0.8.8",
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",