Last active
April 22, 2022 18:38
-
-
Save mvogelgesang/5f6ba01c6f9f56a2e007905231fc5987 to your computer and use it in GitHub Desktop.
Add External Link Arrow to Relevant Links
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const validUrls = []; // to add | |
document.addEventListener("DOMContentLoaded", function(event) { | |
setTimeout(() => { | |
var anchors = document.getElementsByTagName("a"); | |
for (var i=0; i<anchors.length; i++) { | |
if (!anchors[i].href.includes(".gov") && //ignore .gov links | |
!anchors[i].href.includes(".mil") && //ignore .mil links | |
!anchors[i].href.includes("javascript:void(0)") && //ignore blanks | |
!anchors[i].href.includes("mailto:") && //ignore email links | |
!anchors[i].href.includes("tel:") && //ignore telephone links | |
!anchors[i].href.includes("livepreview.") //ignore Salesforce preview pane | |
) { | |
// font awesome | |
// anchors[i].innerHTML += ' <i class="fas fa-external-link-alt" aria-hidden="true"></i>'; | |
// USWDS | |
anchors[i].innerHTML += '<svg class="usa-icon" aria-hidden="true" focusable="false" role="img"><use xlink:href="/assets/img/sprite.svg#launch"></use></svg>'; | |
} | |
} | |
}, 3000); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment