How to customize page/comment preview?

Hello. I need to dynamically modify the page/comment preview content in Confluence and pretty much stucked with this one. I cannot do it via editing decorators because it seems like the preview being generated on javascript. I am not sure, but if that’s the case, is there any way to override javascript content?