Skip to main content
Glama

Lighthouse MCP

by mizchi
analyze-sites.tsโ€ข6.69 kB
#!/usr/bin/env tsx /** * Analyze third-party impact on nicovideo.jp and goal.com * * Usage: pnpm tsx scripts/analyze-sites.ts */ import { executeL2ThirdPartyImpact } from '../src/tools/l2-third-party-impact.js'; async function analyzeSite(url: string, siteName: string) { console.log(`\n${'='.repeat(60)}`); console.log(` ${siteName} (${url})`); console.log(`${'='.repeat(60)}\n`); try { // Step 1: Analyze third-party scripts console.log('๐Ÿ“Š Analyzing third-party scripts...\n'); const analysisResult = await executeL2ThirdPartyImpact({ url, device: 'mobile', compareMode: 'analyze', gather: true, }); if (analysisResult.analysis) { const { summary, entities, impact } = analysisResult.analysis; console.log('๐Ÿ“ˆ Summary:'); console.log(` โ€ข Third-party entities: ${summary.entityCount}`); console.log(` โ€ข Total blocking time: ${Math.round(summary.totalBlockingTime)}ms`); console.log(` โ€ข Total main thread time: ${Math.round(summary.totalMainThreadTime)}ms`); console.log(` โ€ข Total transfer size: ${Math.round(summary.totalTransferSize / 1024)}KB`); console.log(); console.log('๐ŸŽฏ Estimated Impact:'); console.log(` โ€ข Performance score impact: ${(impact.performanceScore * 100).toFixed(1)}%`); console.log(` โ€ข FCP impact: ${(impact.fcpImpact * 100).toFixed(1)}%`); console.log(` โ€ข LCP impact: ${(impact.lcpImpact * 100).toFixed(1)}%`); console.log(` โ€ข TBT impact: ${(impact.tbtImpact * 100).toFixed(1)}%`); console.log(); console.log('๐Ÿ”ฅ Top 5 Performance Offenders:'); entities.slice(0, 5).forEach((entity, i) => { const blockingRatio = entity.blockingTime / entity.mainThreadTime; console.log(` ${i + 1}. ${entity.entity}`); console.log(` โ€ข Blocking: ${Math.round(entity.blockingTime)}ms (${(blockingRatio * 100).toFixed(1)}% of main thread)`); console.log(` โ€ข Transfer: ${Math.round(entity.transferSize / 1024)}KB`); console.log(` โ€ข Scripts: ${entity.subRequests.length}`); }); console.log(); // Get high-impact domains for testing const highImpactDomains: string[] = []; for (const entity of entities.slice(0, 3)) { for (const subRequest of entity.subRequests.slice(0, 3)) { try { const requestUrl = new URL(subRequest.url); if (!highImpactDomains.includes(requestUrl.hostname)) { highImpactDomains.push(requestUrl.hostname); } } catch {} } } if (highImpactDomains.length > 0) { console.log('๐Ÿšซ Testing with blocking top domains...\n'); console.log(` Blocking: ${highImpactDomains.slice(0, 5).join(', ')}`); if (highImpactDomains.length > 5) { console.log(` ... and ${highImpactDomains.length - 5} more`); } console.log(); // Compare with blocking const compareResult = await executeL2ThirdPartyImpact({ url, device: 'mobile', compareMode: 'compare', blockDomains: highImpactDomains.slice(0, 10), gather: true, }); if (compareResult.comparison) { const { baseline, withThirdParty, impact: compareImpact } = compareResult.comparison; console.log('โšก Performance Comparison:'); console.log(' โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”'); console.log(' โ”‚ Metric โ”‚ With 3P โ”‚ Without 3P โ”‚'); console.log(' โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค'); console.log(` โ”‚ Score โ”‚ ${(withThirdParty.score * 100).toFixed(0).padEnd(11)} โ”‚ ${(baseline.score * 100).toFixed(0).padEnd(12)} โ”‚`); console.log(` โ”‚ FCP (ms) โ”‚ ${withThirdParty.fcp.toFixed(0).padEnd(11)} โ”‚ ${baseline.fcp.toFixed(0).padEnd(12)} โ”‚`); console.log(` โ”‚ LCP (ms) โ”‚ ${withThirdParty.lcp.toFixed(0).padEnd(11)} โ”‚ ${baseline.lcp.toFixed(0).padEnd(12)} โ”‚`); console.log(` โ”‚ TBT (ms) โ”‚ ${withThirdParty.tbt.toFixed(0).padEnd(11)} โ”‚ ${baseline.tbt.toFixed(0).padEnd(12)} โ”‚`); console.log(` โ”‚ CLS โ”‚ ${withThirdParty.cls.toFixed(3).padEnd(11)} โ”‚ ${baseline.cls.toFixed(3).padEnd(12)} โ”‚`); console.log(' โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜'); console.log(); console.log('๐Ÿ“Š Impact Summary:'); const scoreImprovement = compareImpact.scoreDelta * 100; console.log(` โ€ข Score: ${scoreImprovement > 0 ? '+' : ''}${scoreImprovement.toFixed(0)} points`); console.log(` โ€ข FCP: ${compareImpact.fcpDelta > 0 ? '+' : ''}${Math.round(compareImpact.fcpDelta)}ms`); console.log(` โ€ข LCP: ${compareImpact.lcpDelta > 0 ? '+' : ''}${Math.round(compareImpact.lcpDelta)}ms`); console.log(` โ€ข TBT: ${compareImpact.tbtDelta > 0 ? '+' : ''}${Math.round(compareImpact.tbtDelta)}ms`); if (scoreImprovement > 10) { console.log(`\n ๐ŸŽ‰ Significant improvement potential: ${scoreImprovement.toFixed(0)} points!`); } else if (scoreImprovement > 5) { console.log(`\n โœ… Moderate improvement potential: ${scoreImprovement.toFixed(0)} points`); } else { console.log(`\n โ„น๏ธ Minor improvement potential: ${scoreImprovement.toFixed(0)} points`); } } } if (analysisResult.recommendations) { console.log('\n๐Ÿ’ก Recommendations:'); analysisResult.recommendations.slice(0, 5).forEach(rec => { console.log(` โ€ข ${rec}`); }); } } } catch (error) { console.error(`โŒ Error analyzing ${siteName}:`, error); } } async function main() { console.log('๐Ÿš€ Third-Party Script Impact Analysis\n'); console.log('Analyzing two sites: nicovideo.jp and goal.com'); console.log('This will take several minutes...\n'); // Analyze nicovideo.jp await analyzeSite('https://www.nicovideo.jp/', 'ใƒ‹ใ‚ณใƒ‹ใ‚ณๅ‹•็”ป'); // Analyze goal.com await analyzeSite('https://www.goal.com/', 'Goal.com'); console.log(`\n${'='.repeat(60)}`); console.log(' Analysis Complete'); console.log(`${'='.repeat(60)}\n`); } main().catch(console.error);

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mizchi/lighthouse-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server