Created
March 2, 2022 12:57
-
-
Save jjmss/fe37613a68e0669cf22eb1f74ff23386 to your computer and use it in GitHub Desktop.
Add the script to bookmark to detect external links that doesn't open in a new window
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
javascript:(function(){var o=document.querySelectorAll("a");for(i=0;i<o.length;i++){if(!o[i].href.includes(window.location.hostname) && !o[i].href.includes('mailto') && !o[i].href.includes('tel') && !o[i].href.includes('javascript:void')){if(o[i].getAttribute("target")!=="_blank"){o[i].setAttribute("style","border-bottom: 3px solid #f75959 !important;");console.log(o[i]);console.log(o[i]+" does not open in a new tab, element:");console.log("\n");}else{o[i].setAttribute("style","border-bottom: 5px solid #02f049 !important;");}}}})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment