Reputation: 327
Is there a way for a web extension add-on to listen for address fields changes when message is being edited? I need to listen for "to" address being added or changed.
Tried browser.compose.onComposeStateChanged
- it get fired (sporadically) when address editing is started/in progress, but not when the editing is actually done.is
Upvotes: 1
Views: 54
Reputation: 800
The API is not guaranteed to fire after a user finishes editing the address field.
You could try setTimeout
to poll for changes at regular intervals.
let toAddress = "";
browser.compose.onComposeStateChanged.addListener(function (tab) {
browser.compose.getComposeDetails(tab.id).then((details) => {
if (details.to !== toAddress) {
console.log("To field changed: " + details.to);
toAddress = details.to;
}
});
});
You can add this inside the onModify, onRemove, onAdd listeners depending on your needs.
Upvotes: 1