6

I would like to know how is it possible to create custom file located in extension root directory using JavaScript or Chrome API.

Extension root directory looks like:

  • popup.html
  • popup.js
  • manifest.json
  • icon.png

And I would like to create JSON file called test in that root directory.

So after that it should look like:

  • popup.html
  • popup.js
  • manifest.json
  • icon.png
  • test.json

test.json should contain:

{
  "data": "123456789"
}

It is not duplicate, because that post is for File Dialog and I need to save it at fixed location and in extension folder. And as I said I want to create it, not download it.

tomsk
  • 967
  • 2
  • 13
  • 29
  • Possible duplicate of [JavaScript: Create and save file](https://stackoverflow.com/questions/13405129/javascript-create-and-save-file) – Sheshank S. Jun 24 '18 at 21:12
  • @SheshankS. No because it is for File Dialog, but I need to save it at fixed location and in extension folder. And as I said I want to create it, not download it. – tomsk Jun 24 '18 at 21:19
  • Oh I see @tomsk – Sheshank S. Jun 28 '18 at 21:47

1 Answers1

6

You can't. The extension directory cannot be used for storage -- its contents are not synchronized across machines, and the directory is replaced entirely when the extension is upgraded.

If you need to store data in a Chrome extension, use the chrome.storage API.