I’m trying download this, by popup.js and popup.html where i created button of it, to click and download the data from that.. my current code heres ,but No content found in localStorage,the code:
// Add event listener for download button
document.querySelector("#downloadBtn").addEventListener('click', () => {
// Retrieve the stored data from localStorage
const storedData = localStorage.getItem('x.txt');
if (storedData) {
// Split the string into individual links
const links = storedData.split('n').filter(link => link.trim() !== ''); // Remove empty strings
// Convert the array of links to a string for download
const content = links.join('n');
// Create a Blob containing the text content
const blob = new Blob([content], { type: 'text/plain' });
// Create a link element to trigger the download
const link = document.createElement('a');
link.href = URL.createObjectURL(blob);
link.download = 'x.txt'; // Set the filename for the download
link.click();
// Clean up resources
URL.revokeObjectURL(link.href);
} else {
console.error('No content found in localStorage.');
}
});
});
chrome.runtime.onMessage.addListener((msg) => {
document.body.innerHTML += `<div>${msg.text}</div>`;
});`
[heres the console](https://i.stack.imgur.com/ktjQa.png)
just wanna extract the lines of url text in a txt file, it seems its basic from you all. doing this all day nothing happens. hope you catch my simple explanation, ill add up if theres need to specify
New contributor
Iso I is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.