From 9c68737c4074f9bec8366224cdb9f11628c71ef4 Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Sat, 18 Oct 2025 13:22:09 +0200 Subject: Email de-obfuscation: Use a custom "data-mailto-b64" attribute. Rather than an href. This avoids validators complaining that the href value is invalid. --- main.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'main.js') diff --git a/main.js b/main.js index 93edd14..9840746 100644 --- a/main.js +++ b/main.js @@ -483,12 +483,12 @@ if (window.location === window.parent.location) { }; /* de-obfuscate email address */ - const MAILTO = 'mailto:'; const CLASSNAME = 'email-address-b64'; + const ATTRNAME = 'data-mailto-b64'; for (const a of panel.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+/)) { + if (a.tagName.toLowerCase() === 'a' && a.hasAttribute(ATTRNAME)) { + let href = 'mailto:'; + for (const part of a.getAttribute(ATTRNAME).split(/\s+/)) { switch (part) { case '__AT__': href += '@'; @@ -500,8 +500,9 @@ if (window.location === window.parent.location) { href += atob(part); } } - a.href = href; a.classList.remove(CLASSNAME); + a.removeAttribute(ATTRNAME); + a.href = href; } } -- cgit v1.2.3