Private addon loading data from a .txt file

Hi, I need to develop an addon for a single user (so, no need for distribution through the official channels).

I red the docs but I could not find anything similar, so I really don’t know where to start.

The needs of the user:

  • she needs to fill multiple times a particular, large order form, many times a day too (she actually fills the form manually copying the data from files. Data are from her customers and can be retrieved multiple times over the year: so she places many orders for the same customer);

She has stored in single .txt files 90% of the details of a single customer. So, any single file contains data about a specific customer of her. All the files are stored in a precise directory on the user machine.

The addon should do the following:

  • when she is in the page where she manually fills the form, she clicks an extension icon and she directly accesses the directory where she stored the files. Then, she chooses a file and the form gets filled with data coming from the file;

Is this possible? How?

You can not read files directly from within an extension, the user would have to select the file using a file picker: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Working_with_files#Open_files_in_an_extension_using_a_file_picker

The rest of it should just be parsing the text file and then filling in the form using a content script.

Obviously you could also program a database within the extension and offer an import function for their existing file format.

1 Like

The extension also could store the field=>value pairs in extension storage (browser.storage.local) after the first upload – however that happens – so that access is faster in the future.

1 Like

Thanks. The inner database is not an option for user workflow and ‘mindset’ reasons (it took me an entire week just convincing her to switch to a decent browser) :slight_smile:

P.S.: I must say I prefer this other way: “Process files in a local app” (paragraph from your link)

Thanks. Problem here is data can change, eg. a customer could change address.

In general, I was just looking for something easier than filling 28 fields (of course, the easier the better, but it would be just fine the file picking) :slight_smile: