Created
March 21, 2021 16:22
-
-
Save ahmetozer/9188f0b9caf323e3210a06ad8fd5a55c to your computer and use it in GitHub Desktop.
Detect TLD 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
var links = document.getElementsByTagName("a"); | |
document.head.insertAdjacentHTML("beforeend", `<style>@keyframes intraT { 50% { opacity: 0; }}</style>`) | |
for (var i = 0; i < links.length; i++) { | |
let temp_url = "" | |
try { | |
temp_url = new URL(links[i].href); | |
} catch(err) { | |
temp_url = "err" | |
} | |
if (temp_url != "err") { | |
let a1 = temp_url.hostname.match(/\./g) | |
if (a1 == null && temp_url.hostname.length != 0 ){ | |
links[i].style.color = "tomato" | |
links[i].style.animation= "intraT 1s linear infinite" | |
console.log(temp_url.hostname) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment