A Chrome extension that captures screenshots of PageSpeed Insights performance scores with automatic domain detection and dual device support.
- 🎯 Smart Cropping: Automatically detects and crops just the performance score gauges
- 📱💻 Dual Device Support: Captures both mobile and desktop screenshots automatically
- 🏷️ Smart Filename: Uses the tested domain name extracted from the page
- ⚡ High Quality: Supports device pixel ratio for crisp images
- 🔔 User Feedback: Shows notifications and status updates
- ⚙️ Configurable: Easy-to-adjust timeouts and cropping settings
- Clone or download this repository
- Open Chrome and navigate to
chrome://extensions/
- Enable "Developer mode" in the top right corner
- Click "Load unpacked" and select the extension folder
- The extension icon should appear in your Chrome toolbar
- Navigate to a PageSpeed Insights results page:
https://pagespeed.web.dev
- Wait for the performance results to fully load
- Click the extension icon in the Chrome toolbar
- The extension will automatically:
- Capture a mobile screenshot
- Switch to desktop view
- Capture a desktop screenshot
- Download both files with descriptive names
Screenshots are saved with the format:
pagespeed-score-{domain}-{device}-{timestamp}.png
Examples:
pagespeed-score-example_com-mobile-2024-01-15T10-30-45.png
pagespeed-score-example_com-desktop-2024-01-15T10-30-47.png
automate-pagespeed-screenshots/
├── manifest.json # Extension configuration
├── background.js # Background service worker
├── content.js # Content script for page interaction
├── icons/ # Extension icons
│ ├── icon16.png
│ ├── icon32.png
│ ├── icon48.png
│ └── icon128.png
└── README.md # This file
- Content Script: Runs on PageSpeed Insights pages to detect when results are loaded
- Background Script: Handles the browser action click and orchestrates the screenshot process
- Element Detection: Uses multiple CSS selectors to find the performance score element
- Screenshot Capture: Uses
chrome.tabs.captureVisibleTab()
to capture the full page - Image Cropping: Crops the full screenshot to only the target element using Canvas API
- Auto Download: Automatically downloads the cropped image with a descriptive filename
activeTab
- Access to the current tab for screenshot capturedownloads
- Permission to download the screenshot filehttps://pagespeed.web.dev/*
- Host permission for PageSpeed Insights
- Make sure you've enabled "Developer mode" in Chrome extensions
- Try refreshing the extensions page after loading
- Ensure you're on a PageSpeed Insights results page (
https://pagespeed.web.dev/*
) - Wait for the performance results to fully load before clicking the extension icon
- Check the browser console for any error messages
- The extension will show a notification if the performance score element isn't found
- Try waiting longer for the page to load completely
- Some PageSpeed Insights pages may have different layouts - the extension uses multiple selectors to handle this
To modify the extension:
- Make changes to the relevant files
- Go to
chrome://extensions/
- Click the refresh icon on the extension card
- Test your changes
To add support for other elements, modify the selectors
array in background.js
:
const selectors = [
"your-new-selector",
// ... existing selectors
];
This project is provided as-is for educational and personal use.