Search code examples
google-chrome-extensioncontent-script

How to download a file via a Chrome Content Script?


This SO answer details how to download a file via a Chrome Extension, but I am using a Content Script, which has limited access to Chrome's APIs. In other words, I don't have access to the chrome.downloads object. I also tried this vanilla JS solution, but it did not work for me. Does anyone have a solution for Content Scripts or know why the second solution doesn't work?


Solution

  • Write a background page or event page and do it from there using the example in your linked answer. Communicate from/to the content script with chrome messages.