Last active
December 20, 2019 06:15
-
-
Save MoOx/9167991 to your computer and use it in GitHub Desktop.
a (really) simple way to hide mailto to bots
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
;[].forEach.call(document.getElementsByClassName("js-MailTo"), function(el) { | |
el.setAttribute("href", "mailto:" + el.getAttribute("data-mailto-user") + "@" + (el.getAttribute("data-mailto-domain") || window.location.host)) | |
}) |
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
<!-- will create a href="mailto:hello+from-website@{current domain}" --> | |
<a class="js-MailTo" data-mailto-user="hello+from-website">this is a mail to a user from this domain<a/> | |
<!-- will create a href="mailto:[email protected]" --> | |
<a class="js-MailTo" data-mailto-user="hello+from-another" data-mailto-domain="domain.com">this is a mail to a user with his own domain<a/> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Clever : i used to regex on the regex, but yours stays accessible.