I haven’t tested this, but I think it would work. Your background script runs in the background page, so in the background you could
- use
document.createElement()to create an anchor tag - give it the
downloadattribute - set the URL to the file that you want the user to download
- the append it to the background document
- use JavaScript to call
.click()on the element
I think that would allow you to download the file unless the user has the “Always ask where to save file” setting enabled as @juraj.masiar described.