1

I am new to building Chrome extensions. I want it to be able to allow the user to choose a local folder and one random picture from there should be displayed for every new tab.

As of now, I have the images in the extension folder and have hardcoded the image names for access.

I read the following SO questions around this:

Open (Import) file in a chrome extension

Access Local Files using a Google Chrome Extension

But I am not sure which one to implement and if they are the way to go.

Community
  • 1
  • 1
Bharg
  • 311
  • 1
  • 2
  • 15

1 Answers1

2

It's not possible* with an extension to maintain a persistent access to a folder in a filesystem. Chrome Apps can do it, extensions cannot.

Your best bet is to allow upload of files into a virtual filesystem. But it will not allow modifying the pictures without interacting with your extension again.

Alternatively, you could integrate with some cloud provider, i.e. monitor a folder in Dropbox.


* P.S. Regarding NPAPI, yes, it's being deprecated, but there is an alternative: you can have a Native Host program that your extension talks to. However, it makes it very awkward to distribute the extension - Native Host can't be submitted to Chrome Web Store. But in principle that can give you the full power of a native app.

Xan
  • 74,770
  • 16
  • 179
  • 206