diff options
author | Guilhem Moulin <guilhem@fripost.org> | 2025-10-17 00:02:39 +0200 |
---|---|---|
committer | Guilhem Moulin <guilhem@fripost.org> | 2025-10-17 00:02:39 +0200 |
commit | bac5a58a46b27e64d12eb562b6d91726bbe3e288 (patch) | |
tree | 80c7549a3854f19e138a80bb3308ab5e84ab2aa9 /main.js | |
parent | 4ed72c781b591004582c8e3b259e3e7900585eeb (diff) |
Obfuscate email address.
Diffstat (limited to 'main.js')
-rw-r--r-- | main.js | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -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() { |