aboutsummaryrefslogtreecommitdiff
path: root/static/email.js
blob: 47aafc8cf55b81f7f48f98b557eacd8da617a10f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//btoa(unescape(encodeURIComponent(str))))
//atob(escape(decodeURIComponent(str))))

// Find all the elements on the page that use class="m-protected"
var allElements = document.getElementsByClassName('m-protected');

// Loop through all the elements, and update them
for (var i = 0; i < allElements.length; i++) {
    updateAnchor(allElements[i]);
}

function updateAnchor(el) {
    // fetch the hex-encoded string from the title property
    var encoded = el.getAttribute('title');

    // replace the title
    el.title = 'Mail';

    // decode the email address and remove the added string 'abridge'.
    var decoded = atob(encoded).substring(7);

    // Set the link to be a "mailto:" link
    el.href = 'mailto:' + decoded;
}