Write a sort of logfile to local disk or in a textarea on user action?

Since i haven’t found a way to save a textfile to the local disc, i wonder, if it is possible to write messages like a http request or values from my addon to a textarea in the my addons options page. This textarea should only be displayed and the http request logged, then the user clicks on a button or enables a option. How can i do that?

See https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Working_with_files on how to write back files.

Also, what you want to do is achievable by doing exactly what you described. It appears to me that you however seem to be missing some piece of the puzzle, like messaging with runtime.sendMessage/onMessage.

Or are you unsure how to hide and unhide elements with html, css or js?

Hiding via css isnt the problem. But how can i access/target for example the text or value attribute of a simple textarea in the addons options page? Currently is use console.log(“my example output”) to make things available for me. For example:

let jsonobj = encodeURIComponent(JSON.stringify({ "id": object_id, "index": object_index, "folderIndex": object_folder }));
console.log(jsonobj);

but i want something like:

let jsonobj = encodeURIComponent(JSON.stringify({ "id": object_id, "index": object_index, "folderIndex": object_folder }));
optionspage.textarea_id.value = old_optionspage.textarea_id.value + newline + jsonobj;

How exactly is that not working for you? Are you checking your logs in the correct console? https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Debugging#Debugging_options_pages

I don’t have a idea, how the second line, addressing the textarea, must be build, to access the textarea value. Are there any special keywords that i must using? Whats the name of the optionspage object?

Oh, I see. You’d want this JS to run in the options page, so you use normal DOM to get the value. If you need that value in the background script (though in most cases you probably don’t, since the options page has full API access), or you need something from the bg script, you can use runtime.sendMessage/onMessage, as mentioned before.

Ok. than i try that today. Many thx. This is only for getting a logfile from the users in case, they need help or somethings goes wrong. Im not the best developer for Addons and this is my first try with such things. And sometimes i can only assume whats going on at the users side. So this could help to make the things a little bit clearer.

To offer debugging files/logs I can recommend the downloads.download method mentioned in the files guide I linked earlier: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Working_with_files#Download_files_using_the_downloads_API

How about adding your strings –

JSON.stringify({ "id": object_id, "index": object_index, "folderIndex": object_folder })

– to an array? It should persist as long as your extension is enabled, until you clear it. Then when your user opens the options page, you can populate the textarea with the contents of the array at that time.

I’m working on something along those lines, but since I want columns and will mix action buttons in, it’s going into an HTML table instead of a textarea.