Can I use the code that marks external links to rewrite them?

This question is about rewriting external links.
I want external links to always pass users to a custom page (similar to the screenshot below) before moving them to the external page:

I figure the same mechanism that currently marks external links is probably able to also rewrite them.

Our team has already implemented a JS based solution but there has to be a Plone/Python way.

Hmm... Unless I'm missing something it looks like Plone is using js to do this anyway (Plone 5 with mockup at least)

You are correct: it's always been entirely js based, both in Plone 5 and in earlier versions.

wil wild guess.... can you use the approach

@espenmn... that isn't what I'm looking for.

Since Plone uses Javascript for this stuff then it is no different from what we're doing already to implement redirects. I guess we're fine.