0

Third party JS libraries I use are often updated and therefore need to be referenced externally in my extension's html pages. This means they need to be included in the Content Security Policy, which causes its own problems.

I'd like to update these libraries in-place, right in my extension directory. I'm not looking to save to the computer's local directory. I know how to read from the extension's csv and text files with AJAX. Is it possible to write to such files in the extension's package directory?

If such a thing were possible, it would be useful to save csv files or text files in my extension directory rather than in local storage. Particularly with large files.

Tom
  • 1,447
  • 1
  • 12
  • 26
  • I feel this will answer your question: http://stackoverflow.com/questions/2153979/chrome-extension-how-to-save-a-file-on-disk – nitobuendia Mar 11 '17 at 05:19
  • Hi thanks for the tip. I'm aware of the download API. Have you used it? Is it as simple as giving the filepath of your Chrome Extension folder to the API? – Tom Mar 11 '17 at 10:00
  • Uhm, if you just want to write to a virtual file system, use the standard HTML5 FileSystem API, then read the file as a string and inject it in a script element or via executeScript if it's a content script. – wOxxOm Mar 11 '17 at 14:52
  • 3
    Why would you want to automate updating libraries into your production release? Updating libraries can **break** whatever application is using them (i.e. your extension). It is only something that is normally pushed to production (i.e. into a release of your extension) after testing to verify that the update did not break anything (e.g. cause some strange, unexpected behavior). Auto-updating libraries into production is a Bad Idea™. – Makyen Mar 11 '17 at 16:39
  • wOxxOM, yes that's a good idea, I'll give that a try. – Tom Mar 12 '17 at 14:16
  • Makyen - what I'm talking about here is third party JS widgets that you would have in your web page. Say pinit.js or twitter.js, or one of the payments or feedback widgets. They would normally sit as script elements in HTML. The owner of the widget can change it and you would never see the changes, so you can't test them for strange behaviour before release. – Tom Mar 12 '17 at 14:20

1 Answers1

1

It is not possible since it would be a major security hole. This would bypass standard extension update procedure that is traceable and you could alter your JS files and do whatever you wanted without any traces or security audit by the webstore.

Updating third party libraries - You can put third party scripts in your extension and update your extension each time those scripts require an update.

Storage - You can use chrome.storage.local with unlimitedStorage permission. I do not see why you are referencing limitations of "sync.storage" for saving files locally, sync storage is for synchronization to user's google account.

Igor Jerosimić
  • 13,621
  • 6
  • 44
  • 53
  • Thanks for the answer. With the third party libraries, the laborious updating of the extension like that is what I was trying to avoid. So better to just have a process that did it on a regular basis. On the storage, you're right, but for some purposes a .txt or .csv file, say the user wants to send it to someone else or to me, just seems more familiar and workable. – Tom Mar 11 '17 at 14:37