It looks like setComposeDetails()
is what you want.
setComposeDetails(tabId, details)
Updates the compose window. Specify only fields that you want to change. Currently only the to/cc/bcc/replyTo/followupTo/newsgroups fields and the subject are implemented.
tabId
(integer)
details
(ComposeDetails)
I have note tried it, but I suppose that either details.body
or details.plainTextBody
from the ComposeDetails
object can be used to pass the default text you want to use. So I would try something like this in the background script:
let details = {
body: "This is my default text",
};
browser.messages.setComposeDetails(tabId, details);
You might have to combine it with a call to messages.getComposeDetails()
if empty fields in details
reset the values in the composer window (I don't know).
If you want to call this when the user opens a new compose window, I would look at the window.onCreated
event. If you want to do it right before the message is sent instead, you should look at the compose.onBeforeSend
event. All of them are described in the API documentation.