├── LICENSE ├── README.md └── chrome ├── background.js ├── icon.png ├── manifest.json ├── popup.html └── popup.js /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2025 Hackersthan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # grepsubsfromwebpages 2 | Chrome extension to extract subdomains from webpages that you visit. 3 | 4 | ### Installation 5 | 1. download from release [https://github.com/hackersthan/grepsubsfromwebpages/releases/download/v1.0/grepsubsfromwebpages.zip](https://github.com/hackersthan/grepsubsfromwebpages/releases/download/v1.0/grepsubsfromwebpages.zip) and extact. 6 | 2. open `all extensions` in chrome based browser `chrome://extensions` | `brave://extensions`. 7 | 3. click `Load unpacked` and select grepsubsfromwebpages folder. 8 | 9 | 10 | ### Usage 11 | 1. Input target domain name e.g. `t-mobile.com` and click `Enable`. 12 | 2. Visit webpages, this extension will automatically grep all the subdomains 13 | 3. You can see grepped subdomains, total numbers in digit formate, `copy` them and `save as txt`. 14 | 15 | ![gthb](https://github.com/user-attachments/assets/5b70addc-7092-4977-bb4b-d475d9d2e849) 16 | 17 | 18 | Pull requests are welcome./ 19 | like <3 20 | . 21 | -------------------------------------------------------------------------------- /chrome/background.js: -------------------------------------------------------------------------------- 1 | chrome.webNavigation.onCompleted.addListener(details => { 2 | if (details.url.startsWith("chrome://") || details.url.startsWith("https://chrome.google.com/webstore")) { 3 | return; 4 | } 5 | 6 | chrome.storage.local.get(["enabled", "domain", "subdomains"], (data) => { 7 | if (!data.enabled || !data.domain) return; 8 | 9 | chrome.scripting.executeScript({ 10 | target: { tabId: details.tabId }, 11 | function: extractSubdomains, 12 | args: [data.domain] 13 | }, (results) => { 14 | if (chrome.runtime.lastError) { 15 | console.warn("Script execution failed:", chrome.runtime.lastError.message); 16 | return; 17 | } 18 | 19 | if (results && results[0] && results[0].result) { 20 | let storedSubdomains = new Set(data.subdomains || []); 21 | results[0].result.forEach(sub => storedSubdomains.add(sub)); 22 | chrome.storage.local.set({ subdomains: [...storedSubdomains] }); 23 | } 24 | }); 25 | }); 26 | }); 27 | 28 | function extractSubdomains(domain) { 29 | const regex = new RegExp(`(?:[a-zA-Z0-9-]+\\.)+${domain.replace(/\\./g, "\\.")}`, "gi"); 30 | return [...new Set([...document.documentElement.innerHTML.matchAll(regex)].map(m => m[0].replace(/^\/\//, "")))]; 31 | } -------------------------------------------------------------------------------- /chrome/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hackersthan/grepsubsfromwebpages/de305615ea83ff4b9d81d25389fc1ef189d642c9/chrome/icon.png -------------------------------------------------------------------------------- /chrome/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest_version": 3, 3 | "name": "grepsubsfromwebpages", 4 | "version": "1.0", 5 | "description": "Extracts subdomains of a specified domain from visited pages.", 6 | "permissions": [ 7 | "storage", 8 | "activeTab", 9 | "scripting", 10 | "downloads", 11 | "webNavigation" 12 | ], 13 | "host_permissions": [""], 14 | "background": { "service_worker": "background.js" }, 15 | "action": { 16 | "default_popup": "popup.html", 17 | "default_icon": { 18 | "16": "icon.png", 19 | "32": "icon.png", 20 | "48": "icon.png", 21 | "128": "icon.png" 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /chrome/popup.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | grepsubsfromwebpages 6 | 7 | 8 | 9 | 10 | 20 | 21 |

grepsubsfromwebpages

22 | 23 |
24 |
25 | 26 | 27 |

28 | 29 |

Extracted Subdomains (0):

30 | 31 | 32 | -------------------------------------------------------------------------------- /chrome/popup.js: -------------------------------------------------------------------------------- 1 | document.addEventListener("DOMContentLoaded", () => { 2 | const toggleButton = document.getElementById("toggleButton"); 3 | const domainInput = document.getElementById("domainInput"); 4 | const copyButton = document.getElementById("copyButton"); 5 | const saveButton = document.getElementById("saveButton"); 6 | const clearButton = document.getElementById("clearButton"); 7 | const subdomainList = document.getElementById("subdomainList"); 8 | const subdomainCount = document.getElementById("subdomainCount"); 9 | 10 | function updateSubdomainUI() { 11 | chrome.storage.local.get("subdomains", (data) => { 12 | const subdomains = data.subdomains || []; 13 | subdomainList.innerHTML = ""; 14 | subdomains.forEach(sub => { 15 | const li = document.createElement("li"); 16 | li.textContent = sub; 17 | subdomainList.appendChild(li); 18 | }); 19 | subdomainCount.textContent = subdomains.length; 20 | }); 21 | } 22 | 23 | chrome.storage.local.get(["enabled", "domain", "subdomains"], (data) => { 24 | if (data.enabled) toggleButton.textContent = "Disable"; 25 | if (data.domain) domainInput.value = data.domain; 26 | updateSubdomainUI(); 27 | }); 28 | 29 | toggleButton.addEventListener("click", () => { 30 | chrome.storage.local.get("enabled", (data) => { 31 | const newState = !data.enabled; 32 | chrome.storage.local.set({ enabled: newState }, () => { 33 | toggleButton.textContent = newState ? "Disable" : "Enable"; 34 | }); 35 | }); 36 | }); 37 | 38 | domainInput.addEventListener("input", () => { 39 | chrome.storage.local.get(["domain", "subdomains"], (data) => { 40 | const newDomain = domainInput.value.trim(); 41 | if (data.domain !== newDomain) { 42 | chrome.storage.local.set({ domain: newDomain, subdomains: [] }, updateSubdomainUI); 43 | } 44 | }); 45 | }); 46 | 47 | copyButton.addEventListener("click", () => { 48 | chrome.storage.local.get("subdomains", (data) => { 49 | navigator.clipboard.writeText((data.subdomains || []).join("\n")); 50 | }); 51 | }); 52 | 53 | saveButton.addEventListener("click", () => { 54 | chrome.storage.local.get(["subdomains", "domain"], (data) => { 55 | const domainName = data.domain || "subdomains"; 56 | const filename = `${domainName}-grepsubs.txt`; 57 | const blob = new Blob([(data.subdomains || []).join("\n")], { type: "text/plain" }); 58 | const url = URL.createObjectURL(blob); 59 | chrome.downloads.download({ url, filename }); 60 | }); 61 | }); 62 | 63 | clearButton.addEventListener("click", () => { 64 | chrome.storage.local.set({ subdomains: [] }, updateSubdomainUI); 65 | }); 66 | 67 | chrome.storage.onChanged.addListener(updateSubdomainUI); 68 | }); --------------------------------------------------------------------------------