It isn't, at least not in the way you think.
Visited links have always looked different from unvisited ones, and the moment you could customize how links looked via CSS, browsers also had to implement styling for visited links specifically.
Modern browsers put a lot of care into making the changes to those styles observable to the user, but not to Javascript.
This is an extremely hard problem, and browsers have had a lot of security issues related to this behavior. Nowadays, you can only apply a very limited subset of CSS properties to those styles, to avoid side-channel timing attacks and such.
This means you can display a banner to anybody who has a certain URL in their browser history, but you can't observe whether that banner actually shows up with JS or transmit that information to your server.
<!doctype html>
<style>a { color: white; background-color: white; } a:visited { color: black; }</style>
<body><a href="https://example.com/abracadabra" onclick="return false">you are a bad person</a>
[1] https://developer.mozilla.org/en-US/docs/Web/CSS/:visited#pr...How do they stop you from using Canvas to see the output and send it back?
The screen recording/screen sharing API can be used for this but security is the reason you have to give explicit permission to the site before it can do this.
There was also that asteroids game / captcha where links were white/black squares and your goal was to click all the black ones. Of course, clicking a square revealed that you knew the square was black, which meant the URL under it was in your history.