aboutsummaryrefslogtreecommitdiffstats
path: root/main.js
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2025-10-17 00:02:39 +0200
committerGuilhem Moulin <guilhem@fripost.org>2025-10-17 00:02:39 +0200
commitbac5a58a46b27e64d12eb562b6d91726bbe3e288 (patch)
tree80c7549a3854f19e138a80bb3308ab5e84ab2aa9 /main.js
parent4ed72c781b591004582c8e3b259e3e7900585eeb (diff)
Obfuscate email address.
Diffstat (limited to 'main.js')
-rw-r--r--main.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/main.js b/main.js
index 2822cf4..80b487d 100644
--- a/main.js
+++ b/main.js
@@ -424,6 +424,30 @@ if (window.location === window.parent.location) {
};
}
+const decodeEmailAddress = function(element) {
+ const MAILTO = 'mailto:';
+ const CLASSNAME = 'email-address-b64';
+ for (const a of element.getElementsByClassName(CLASSNAME)) {
+ if (a.tagName.toLowerCase() === 'a' && a.href.toLowerCase().startsWith(MAILTO)) {
+ let href = MAILTO;
+ for (const part of a.href.substr(MAILTO.length).split(/\s+/)) {
+ switch (part) {
+ case '__AT__':
+ href += '@';
+ break;
+ case '__DOT__':
+ href += '.';
+ break;
+ default:
+ href += atob(part);
+ }
+ }
+ a.href = href;
+ a.classList.remove(CLASSNAME);
+ }
+ }
+};
+
/* info button */
(function() {
const div = document.createElement('div');
@@ -447,6 +471,7 @@ if (window.location === window.parent.location) {
const modal = new Modal(panel, {
backdrop: false,
});
+ decodeEmailAddress(panel);
const backdrop = document.getElementById('info-modal-backdrop');
backdrop.onclick = function() {