I have the following script added to my footer that is automatically adding target="_blank" to every external link:
<script type="text/javascript">
function linkopener(a) {
var b = a ? "_blank" : "_self";
var c = document.links;
for (var i = 0; i < c.length; i++) {
if (c[i].href.search("www.mydomain.tld") == -1) {
c[i].addEventListener("click", function () {
this.target = b;
});
}
}
};
$(document).ready(function(){
linkopener(true);
});
</script>
Now I would like to extend this to a small indicator at the end of every link so that a user is aware that it is an external link and for that I found this solution: https://stackoverflow.com/a/52058198 but I cannot make it work. How to integrate this into my working script?