A Chrome browser extension that detects iframes on web pages and allows you to inject scripts into specific iframes for DOM inspection and accessibility testing.
- 🔍 Iframe Detection: Automatically scans and lists all iframes on the current page
- 📋 Iframe Information: Shows iframe URLs and frame IDs
- 📌 Selective Injection: Inject scripts into specific iframes or all iframes at once
- 🎯 DOM Access: Injected script can access and manipulate the DOM of the selected iframe
- 🖱️ Interactive Elements: Click elements to inspect them, double-click to toggle highlighting
- ⌨️ Keyboard Shortcuts: Use Escape to clear selection, 'I' to re-inspect current selection
- Open Chrome and navigate to
chrome://extensions/ - Enable "Developer mode" in the top right
- Click "Load unpacked" and select the
iframe-extensionfolder - The extension icon should appear in your browser toolbar
- Open the provided
iframe-test-page.htmlin Chrome to test with multiple iframes - Click the extension icon in the toolbar to open the popup
- The extension will automatically scan for iframes and display them
- Refresh: Click the "🔄 Refresh" button to rescan the current page for iframes
- Inject All: Click "📌 Inject All" to inject the script into all detected iframes
- Inject Specific: Click "📌 Inject Script" on any specific iframe to inject only into that frame
Once injected, the script (bkp.js) provides the following functionality:
- Element Highlighting: All elements get a red border and slight background tint
- Click to Inspect: Click any element to select it and view detailed information in the console
- Double-click Toggle: Double-click anywhere to toggle the highlighting on/off
- Keyboard Controls:
Escape: Clear current selectionI: Re-inspect current selection
The following functions are available in the iframe's console after injection:
highlightAllElements(): Highlight all elements with red bordersremoveHighlighting(): Remove all highlightingselectElement(element): Select and inspect a specific elementgetCurrentSelection(): Get the currently selected element
iframe-extension/
├── manifest.json # Extension configuration
├── popup.html # Extension popup interface
├── popup.js # Popup logic and iframe detection
├── background.js # Background service worker
├── bkp.js # Script to inject into iframes
└── inject.js # Alternative injection script
The extension requires the following permissions:
tabs: Access to browser tabsscripting: Script injection capabilitieswebNavigation: Access to frame informationactiveTab: Current tab access<all_urls>: Access to all websites
- Detection: Uses
chrome.webNavigation.getAllFrames()to detect all frames on the page - Filtering: Filters out the main frame (frameId 0) to show only iframes
- Injection: Uses
chrome.scripting.executeScript()to inject the script into specific frames - DOM Access: The injected script runs in the iframe's context and can access its DOM
- Some iframes may block script injection due to cross-origin policies
- Sites with strict Content Security Policy (CSP) may prevent injection
- The extension will show success/error messages for injection attempts
Edit bkp.js to customize what happens when the script is injected into an iframe. The current script:
- Highlights all elements
- Provides click-to-inspect functionality
- Logs detailed element information
- Supports keyboard shortcuts
- Modify
popup.htmlfor UI changes - Update
popup.jsfor new functionality - Edit
manifest.jsonfor additional permissions - Enhance
bkp.jsfor new injection behaviors
- Ensure you're on a webpage (not chrome:// pages)
- Check if the page has iframes
- Verify the extension is enabled in chrome://extensions/
- Some sites block cross-origin script injection
- Check the browser console for error messages
- Try on the test page first to verify functionality
- Refresh the page and try again
- Some iframes load dynamically and may not be immediately detected
- Use the refresh button in the extension popup
Use the included iframe-test-page.html to test the extension. It contains:
- Multiple iframes with different sources
- Local HTML content iframes
- External website iframes (some may be blocked)
- Dynamic content examples
Feel free to enhance this extension by:
- Adding more inspection features
- Improving the UI
- Adding better error handling
- Supporting more iframe scenarios