Alternatively, you could simply hide the editor toggle switch with CSS. I imagine that’s a bit simpler than using MutationObserver.
To do so, simply install a new component here: https://discourse.yoursite.com/admin/config/customize/components
Then, add a little CSS snippet to the code for that component that looks like so:
.composer-toggle-switch {
display: none;
}
I used this to enforce the default Markdown editor, since the rich editor does not (yet) work well with the Discourse Math plugin.