function downloadLinksAsTxt() { // Get all anchor (link) elements on the page const allLinks = Array.from(document.querySelectorAll('a')); // Extract and create a list of href attributes const hrefList = allLinks.map(link => link.getAttribute('href')); // Convert the list of href attributes to a plain text string const textContent = hrefList.join('\n'); // Create a Blob with the text content const blob = new Blob([textContent], { type: 'text/plain' }); // Create a temporary download link and trigger the download const a = document.createElement('a'); a.href = window.URL.createObjectURL(blob); a.download = 'links.txt'; a.style.display = 'none'; document.body.appendChild(a); a.click(); window.URL.revokeObjectURL(a.href); document.body.removeChild(a); } // Call the function to initiate the download downloadLinksAsTxt();