From bac5a58a46b27e64d12eb562b6d91726bbe3e288 Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Fri, 17 Oct 2025 00:02:39 +0200 Subject: Obfuscate email address. --- main.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'main.js') 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() { -- cgit v1.2.3