/* @name Link Extractor @description Extract all hyperlinks from the current page and download them as a TXT file @author Pablo Murad ยท https://pablomurad.com */ (() => { const links = new Set(); document.querySelectorAll('a[href], area[href]').forEach(element => { const href = element.getAttribute('href').trim(); if (!href || /^javascript:/i.test(href)) return; try { links.add(new URL(href, document.baseURI).href); } catch { /* Ignore invalid URLs */ } }); if (links.size === 0) { alert('No links found!'); return; } const blob = new Blob( [Array.from(links).join('\n')], { type: 'text/plain;charset=utf-8' } ); const url = URL.createObjectURL(blob); const download = document.createElement('a'); download.href = url; download.download = `links-${location.hostname}.txt`; document.body.appendChild(download); download.click(); download.remove(); setTimeout(() => URL.revokeObjectURL(url), 1000); alert(`${links.size} unique links extracted!`); })();