Note: I did not write the original core logic for this script. This is a modified, curated version that I hosted here for easy access by the community. Full credit goes to the original open-source creator!
A simple JavaScript snippet to extract text (like IPs) from web page elements and download it as a .txt file. Perfect for security researchers, pentesters, or anyone who wants to collect structured data from websites during OSINT gathering.
🔥 Features
- Extracts text from any HTML element using a CSS selector.
- Removes duplicates automatically.
- Downloads as a clean
.txtfile. - Works directly in the browser console.
- Optional one-click bookmarklet version.
👉 Try It Out (Drag & Drop)
The easiest way to use this tool is via a Bookmarklet. Drag the golden button below into your browser's bookmarks bar. Whenever you are on a page with IPs, just click the bookmark to instantly download the structured data!
Download IPs
Drag this button to your bookmarks bar
💻 Console Method
If you prefer using the browser console (F12 → Console tab) for more control over the selector:
function downloadIPs({ selector = "strong", filename = "ips.txt" } = {}) {
try {
const nodes = document.querySelectorAll(selector);
if (!nodes || nodes.length === 0) {
console.warn("No elements found for selector:", selector);
return;
}
// Extract text, remove quotes, trim, filter empty, and remove duplicates
const values = [...new Set(Array.from(nodes).map(n => (n.textContent || "").replace(/["']/g, "").trim()).filter(Boolean))];
const content = values.join("\n");
// Trigger download
const blob = new Blob([content], { type: "text/plain;charset=utf-8" });
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = filename;
a.style.display = "none";
document.body.appendChild(a);
a.click();
setTimeout(() => { URL.revokeObjectURL(url); a.remove(); }, 1000);
} catch (err) {
console.error("Failed to extract/download IPs:", err);
}
}
// Execute with custom selector
downloadIPs({ selector: "strong", filename: "extracted-ips.txt" });