How to create a firefox extension with a variable which takes the value from an external link?

Hi!

   I am trying to make an extension for firefox but I don't know to do something, so please, help me with some advices. I want to create variable which takes the array value from an external link (like www.domain.com/database.txt). And after I publish the extension, I will update that database.txt every day. Any idea how to do this? Or any other similar idea? I don't want to update the extension everytime to only update the variable...

Thanks in advance!

There are in fact many extensions that do very similar things. Almost every ad blocker for example. What they do is use fetch to load the file every so often and then save it in their database/storage.

Yes, but I want to integrate this to my extension, do you know how can achieve this?

I’m not sure what you mean by “integrate”, but in general doing this will involve coding in JavaScript. If you’re not sure what that involves, I’d recommend to start with https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/What_are_WebExtensions

Yes, exactly. I am developing an firefox extension… and I don’t know where to ask and who, to find out how can I fetch some datas from an external link, adding the value to a variable

I linked you to the docs of a function that lets you download the contents of the file. It’s called fetch and it’s available in extensions. As one of the “Getting started” articles explains, you have all the web APIs available.

You probably don’t want to only “add it to a variable” but store it in some storage like storage.local (or indexedDB).

I tried something with fetch but I didn’t got it to work :)) I will try more, thank you for your time

You probably ran into https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS. Since you probably don’t want your txt to be readable by every website out there, you may want to instead add a host permission for the file: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions#Host_permissions

P.S.: stating your exact problem makes it much easier to help, no guessing needed then…

Exactly… I didn’t used the permisions…