Options.html (as popup) & file picker

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

  1. use document.createElement() to create an anchor tag
  2. give it the download attribute
  3. set the URL to the file that you want the user to download
  4. the append it to the background document
  5. 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.

1 Like