Last active
September 23, 2021 20:57
-
-
Save jxxe/34560bfbaa3d65a7e3ee39f4ce50db19 to your computer and use it in GitHub Desktop.
Hide email addresses from crawlers
This file contains hidden or 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
<a email="ZW5jb2RlZEBlbWFpbC5jb20=">Enable JavaScript to view this email address</a> | |
<a email="YW5vdGhlckBlbWFpbC5jb20=">Enable JavaScript to view this email address</a> | |
<script> | |
document.querySelectorAll('[email]').forEach(email => { | |
let decodedEmail = atob(email.getAttribute('email')); | |
email.innerText = decodedEmail; | |
email.href = 'mailto:'+decodedEmail; | |
email.removeAttribute('email'); | |
}) | |
</script> | |
<!-- Bonus Code Golf --> | |
<script>q='email';document.querySelectorAll(`[${q}]`).forEach(l=>{e=atob(l.getAttribute(q));l.innerText=e;l.href='mailto:'+e;l.removeAttribute(q)});</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment