
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
iframe-finder
Advanced tools
Recursively find nested iframes by id, name, or custom criteria in the DOM tree
A lightweight TypeScript library for recursively finding nested iframes in the DOM tree.
npm install iframe-finder
import { findIframeById } from 'iframe-finder';
// Find iframe with id="myFrame" anywhere in the DOM tree
const iframe = findIframeById('myFrame');
if (iframe) {
console.log('Found iframe:', iframe);
// Access iframe content
const content = iframe.contentDocument;
}
import { findIframeByName } from 'iframe-finder';
const iframe = findIframeByName('contentFrame');
import { findElement } from 'iframe-finder';
// Find element by selector anywhere in iframe hierarchy
const healthTab = findElement('[title="Character Info"]');
// No need to know which iframe contains the element!
const button = findElement('#submitButton');
// Works with any CSS selector
const element = findElement('.special-class');
import { findAllElements } from 'iframe-finder';
// Find all matching elements across all iframes
const allButtons = findAllElements('button.submit');
// Find all elements with specific attribute
const allLinks = findAllElements('a[target="_blank"]');
import { findIframe } from 'iframe-finder';
// Find iframe by src
const iframe = findIframe((frame) =>
frame.src.includes('example.com')
);
// Find iframe by class
const iframe = findIframe((frame) =>
frame.classList.contains('special-frame')
);
// Find iframe by data attribute
const iframe = findIframe((frame) =>
frame.dataset.type === 'content'
);
import { findIframeById } from 'iframe-finder';
// Limit search depth
const iframe = findIframeById('myFrame', {
maxDepth: 3 // Only search 3 levels deep
});
// Start from specific document
const iframe = findIframeById('myFrame', {
rootDocument: someIframe.contentDocument
});
import { findAllIframes } from 'iframe-finder';
// Find all iframes with specific class
const iframes = findAllIframes((frame) =>
frame.classList.contains('content')
);
console.log(`Found ${iframes.length} iframes`);
findIframeById(id: string, options?: FindIframeOptions): HTMLIFrameElement | nullRecursively searches for an iframe by its id attribute.
Parameters:
id - The id attribute to search foroptions - Optional search optionsReturns: The found iframe element or null
findIframeByName(name: string, options?: FindIframeOptions): HTMLIFrameElement | nullRecursively searches for an iframe by its name attribute.
Parameters:
name - The name attribute to search foroptions - Optional search optionsReturns: The found iframe element or null
findIframe(predicate: IframePredicate, options?: FindIframeOptions): HTMLIFrameElement | nullRecursively searches for an iframe using a custom predicate function.
Parameters:
predicate - Function that returns true when iframe matches criteriaoptions - Optional search optionsReturns: The found iframe element or null
findAllIframes(predicate: IframePredicate, rootDocument?: Document): HTMLIFrameElement[]Finds all iframes matching the predicate (single level, non-recursive).
Parameters:
predicate - Function to test each iframerootDocument - Starting document (defaults to window.document)Returns: Array of matching iframes
FindIframeOptionsinterface FindIframeOptions {
rootDocument?: Document; // Starting document (default: window.document)
maxDepth?: number; // Maximum search depth (default: Infinity)
}
IframePredicatetype IframePredicate = (iframe: HTMLIFrameElement) => boolean;
import { findIframeById } from 'iframe-finder';
// Game UI often has deeply nested iframes
const showInfoFrame = findIframeById('showInfo');
if (showInfoFrame?.contentDocument) {
const healthElement = showInfoFrame.contentDocument
.querySelector('[title="Character Info"]');
}
import { findIframe } from 'iframe-finder';
// Find advertisement iframe
const adFrame = findIframe((frame) =>
frame.src.includes('doubleclick.net') ||
frame.classList.contains('ad-frame')
);
import { findIframeByName } from 'iframe-finder';
// Find chat or messaging iframe
const chatFrame = findIframeByName('chat-widget');
if (chatFrame) {
// Setup postMessage communication
chatFrame.contentWindow?.postMessage({ type: 'init' }, '*');
}
Works in all modern browsers that support:
querySelector / querySelectorAllHTMLIFrameElement.contentDocumentArray.fromThis includes:
MIT © Artem Deikun
Contributions are welcome! Please feel free to submit a Pull Request.
FAQs
Recursively find nested iframes by id, name, or custom criteria in the DOM tree
We found that iframe-finder demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.