Add class to link if link is external and is anchor text and not plain url

Add class to link if link is external and is anchor text and not plain url

So the idea is that if I type www.example.com nothing happens. But if I type in <a href="example.com">Example.com or example</a> it adds what you see on hover here:



the output url. This makes it easier to check were a link goes to. instead of having to look down in your browser you see it presented before you.


However I never done anything like this before,


The idea is to let js check if the url is internal or external and if its external add a class to the link like say "external" and what you see in the css in the fiddle gets added to the link.

So it has to check the domain its on and any link that is onsite doesn't need any extra class only external links. 

BUT ONLY if the link is written with an anchor text. Otherwise what is the point? If I type in my posts example.com its clear were it goes. But if I hide it behind a text then you need to hover to see the full url and in that case the script goes into action. 


Can you help me? This is beyond my skill level.