I'm not good in JS, but I need to implement simple solution for my website. Website contains a lot of articles with this different links type:

1. Internal links
2. External links
3. External links with target="_blank"
4. External links without target="_blank"
5. Some other JS scripts that manipulate a="#" links.

My task is add JS script that will be open all external links in a new tab. I already try some code, that check if current link is not equal current website than open it on a new tab. But it's broke links N5, because this code t"think" that # is not equal current website url.

Somewhere I saw great and simple solution for that, in few lines of code, but lost this link and can't find again. Please help me…