-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobsmail.hashed.min.js
6 lines (6 loc) · 1.07 KB
/
obsmail.hashed.min.js
1
2
3
4
5
6
/**
* @preserve: Obscure Email - Hashed, v1.1.1
* @url: https://github.com/madebygrant/obsmail
* @author: Grant, https://madebygrant.com
*/
const obsMail={_d:function(encodedString){let string="",keyInHex=encodedString.substr(0,2),key=parseInt(keyInHex,16);for(let n=2;n<encodedString.length;n+=2){let charInHex=encodedString.substr(n,2),output=parseInt(charInHex,16)^key;string+=String.fromCharCode(output)}return string},hashed:function(){const emailLinks=document.getElementsByClassName("obs-mail");if(0!==emailLinks.length)for(let i=0;i<emailLinks.length;++i){let emailA=emailLinks[i].getAttribute("data-link"),updated_email=this._d(emailA),label=emailLinks[i].querySelector("span");label&&""==label.innerHTML&&(label.textContent=updated_email),emailLinks[i].addEventListener("click",(function(e){e.preventDefault();let emailA2=updated_email,emailS=e.target.parentNode.getAttribute("data-subject");window.location.href="undefined"!=emailS&&null!=emailS?"mailto:"+emailA2+"?subject="+emailS:"mailto:"+emailA2}))}}};document.addEventListener("DOMContentLoaded",(function(){obsMail.hashed()}));