You can hook on vanilla JS if you want to without having to extend Flarum by making an extension, I've got a couple of functions doing that. Onscroll is probably sufficient for what you're doing:
function modifyLinks(){
$(".Post-body a").each(function () {
var parent = $(this).parent().html().trim();
var myTag = $(this).wrap("<p/>").parent().html().trim();
$(this).unwrap();
if (parent === myTag) {
$(this).addClass("standalone");
} else {
$(this).addClass("inline");
}
});
}
// Launch link function on scroll (this may load additional posts)
window.onscroll = () => {modifyLinks();}
// Launch link function once document loads
let appF = document.getElementById("app"), ob = new MutationObserver(function(){modifyLinks();});
ob.observe(appF,{attributes: true, attributeFilter: ["class"]});
The one thing that won't trigger on is dynamically loading one post to another post, but vanilla Flarum doesn't support that anyway, and the extension for it does it wrong IMO. I might fork the extension and fix it, with all due respect to others if you can't figure out how to do this correctly without the potential for your extension to create potentially unwanted behaviour then I should probably just make my own version. 😉