Trying to determine displayed message from background script

I’ve written a simple add-on, to trash selected messages from a list, but I haven’t been able to extend this to messages displayed in their own tab/window. I tried messenger.messageDisplay.getDisplayedMessage() but it returns null, despite being able to access the current tab and see there’s a message opened in it by its URL. I created a GitHub issue for further detail. I don’t think it’s a permissions issue so I suppose I’m using the API incorrectly.

I thought of subscribing to the onMessageDisplayed event instead, but it seems like that has the potential to delete when it shouldn’t, i.e. a tab shows a message, extension notes its ID, tab remains open but stops showing a message, then the shortcut is pressed and it trashes a message that isn’t displayed.

Development questions are best asked here:

Cheers @DaveRo, I’ve asked there.