1

I am very new to javascript and chrome-extension, I try to create extension that block a few domain. I want to store these domains in a file, maybe the same way adblock do it.

I know there is localstorage but is it the only way to store data ?

If stored in a file how can I open it from javascript extension ?

Thank you

Boris Le Méec
  • 2,383
  • 1
  • 16
  • 31

3 Answers3

7

For large data it's recommended to use Indexed DB.

You can ask for permission to use large amount of data with chrome.storage.local (and Indexed DB) using the unlimitedStorage permission (in addition to the regular storage permission).

  • 2
    Note, same permission applies to IndexedDB. Also, only `chrome.storage.local` is unlimited with that permission. – Xan Aug 21 '17 at 13:38
  • I've just stored 100MB of data in extension's IndexedDB with no unlimitedStorage permission and no errors were displayed. The data was actually stored and survived restarting the browser. Chrome 60, 62. I wonder if this is a bug. – wOxxOm Aug 21 '17 at 15:30
0

I think you would be limited in size for safety reason, adblock (to my knowledge) uses external database (public if I'm not mistaking) so you could do the same, like using a google doc shared publicly. According to this : What is the max size of localStorage values? the max size is 10Mb

Hope that can help :)

zurricanjeep
  • 38
  • 1
  • 6
0

You could use chrome.storage.local in the chrome storage api: https://developer.chrome.com/extensions/storage

yezzz
  • 2,990
  • 1
  • 10
  • 19