How to insert char dynamically

What would be the simplest way to make an extension that analyses the editor and inserts a single character based on the document contents? Should work on load as well as on change.

Can someone suggest a brief outline of the building blocks needed to achieve this? What extension(s) to look at?
Iā€™m a bit lost :face_exhaling: