aboutsummaryrefslogtreecommitdiff
path: root/static/email.js
diff options
context:
space:
mode:
authorJieiku2022-07-21 13:18:15 -0700
committerJieiku2022-07-21 13:18:15 -0700
commit72ed630089e1aaa7d8ed88fd3b4d03d55af52326 (patch)
tree463d7986b0d12467515bdb2893fbc8bb00a827fb /static/email.js
parentef6a407d837940704f5bb6137b77954f63eb74df (diff)
downloadabridge-72ed630089e1aaa7d8ed88fd3b4d03d55af52326.tar.gz
abridge-72ed630089e1aaa7d8ed88fd3b4d03d55af52326.tar.bz2
abridge-72ed630089e1aaa7d8ed88fd3b4d03d55af52326.zip
email obfuscation
Diffstat (limited to 'static/email.js')
-rw-r--r--static/email.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/static/email.js b/static/email.js
new file mode 100644
index 0000000..47aafc8
--- /dev/null
+++ b/static/email.js
@@ -0,0 +1,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;
+}