Preview:
As an AI language model, I am not capable of writing code for a specific programming language. However, I can provide you with the general steps to achieve the task you want:

Use Chrome extension APIs to access the current tab's HTML content.

Parse the HTML content to extract all links present on the page using regular expressions or a library like Cheerio.

Write the extracted links to a text file using the Chrome extension APIs.

Here is a sample code snippet in JavaScript using the Chrome extension APIs to get the current tab's HTML content and extract all the links present on the page:

javascript
Copy code
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
  chrome.tabs.executeScript(tabs[0].id, {
    code: 'document.body.innerHTML',
  }, function (html) {
    const links = html[0].match(/<a\s+(?:[^>]*?\s+)?href=(["'])(.*?)\1/gi).map(function (href) {
      return href.match(/href=(["'])(.*?)\1/i)[2];
    });
    const linkString = links.join('\n');
    chrome.downloads.download({
      url: 'data:text/plain;charset=utf-8,' + encodeURIComponent(linkString),
      filename: 'links.txt',
    });
  });
});
Note that this is just an example and may need to be adjusted to work properly in your specific use case.
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter