I am using a JavaScript function erot13. As it is advised by some articles, this function suppose to obfuscate the email, so the email harvesting bots are not able to extract it from the website.
function erot13(s) {
return (s ? s : this).split("").map(function (_) {
if (!_.match(/[A-za-z]/)) return _;
var c = Math.floor(_.charCodeAt(0) / 97);
var k = (_.toLowerCase().charCodeAt(0) - 83) % 26 || 26;
return String.fromCharCode(k + ((c == 0) ? 64 : 96));
}).join("");
}
function erot13_onload(event) {
var elements = window.document.querySelectorAll("a[data-erot13]");
for (var j = 0; j < elements.length; j++) {
var element = elements[j];
var email = element.dataset.erot13;
var overwrite = element.dataset.erot13Overwrite !== undefined;
if (email !== undefined) {
element.href = "mailto:" + erot13(email);
if (overwrite) {
element.innerHTML = erot13(email);
}
}
}
}
window.addEventListener("load", erot13_onload);
A step by step process how I implement it looks like this:
- I place this function in a separate js file and place a script tag in index.html:
<script src="erot13.js"></script>
I go to this website to get the encrypted version of my email: https://rot13.com/
Finally, I add tag to my index.html with data-erot13 attribute where I place my encrypted email:
<a data-erot13="yvanf.zbpkjavf@tznvy.pbz"><span class="email"></span>Email Me</a>
Everything suppose to work fine, but if I inspect my email in the browser I see my real email but not the encrypted version of it. Does that mean the erot13 function does not work? How to figure out is it really encrypted or not for the bots?