My initial thinking hasn't worked out I'm afraid, each of the <div> tags used to build the UI with the message uses dynamic class selectors, meaning I can't then grab it after the message has been displayed and modify the properties, such as target="_blank" to target="_parent".
Maybe this blueprint will give me some different options to explore.
If you're using the messenger widget, you must use it as-is and constrain your efforts to the supported integration points. Hacking the DOM is unsupported and unsafe; we make no commitments about our private source code not having breaking changes.
If you wish to manage the display of messages yourself, you must build your own client using the web messaging guest API. This will give you full control over everything client-side, because you have to build it all from scratch. It's not an easy option, but your choices are to use the out of the box Messenger with the integration points it documents or build your own client if your use case falls outside of the supported options. The docs for the guest API can be found here: https://developer.genesys.cloud/commdigital/digital/webmessaging/websocketapi
That blueprint is essentially an out-of-band solution. It presents an additional alternative UI with modified output but does not alter the original screen. It's also on the agent side, not the customer. It may spur some ideas for you, but it will not satisfy your requirement of intercepting and modifying a message within Messenger.
Thanks Tim; you've hit on all the points I was concerned about when trying to change the "as-is" solution. I think our only option is to get for a fully custom UI. Thank you for your feedback on this.