Detect and edit external links

I want to say that I’m aware of similar questions on SO, but since my situation is slightly different I thought it would be better to open a new question. I did search for an hour, I may have missed...