diff --git a/src/misc/markdown.rs b/src/misc/markdown.rs index 62be06a..3d5409f 100644 --- a/src/misc/markdown.rs +++ b/src/misc/markdown.rs @@ -434,15 +434,15 @@ fn mail_obfuscation(html: &str) -> (String, bool) { modified.store(true, Ordering::SeqCst); let link = el.get_attribute("href").unwrap(); - let (_uri, mail) = &link.split_at(7); + let (uri, mail) = &link.split_at(7); let (before, after) = mail.split_once('@').unwrap(); let modified_mail = format!("{before}(at){after}"); el.set_inner_content(&modified_mail, ContentType::Html); - // TODO: Change href - Ok(el.set_attribute("href", &link)?) + // Change href + Ok(el.set_attribute("href", &format!("{uri}{before} at {after}"))?) })], ..RewriteStrSettings::default() }, diff --git a/static/js/mail_obfuscation.js b/static/js/mail_obfuscation.js index 4716028..2dcde65 100644 --- a/static/js/mail_obfuscation.js +++ b/static/js/mail_obfuscation.js @@ -1,6 +1,13 @@ window.addEventListener("load", () => { Array.from(document.getElementsByClassName("at")).forEach((elem) => { - // TODO: Change link elem.textContent = "@"; + + // Change link + const a = elem.parentElement; + const href = a.getAttribute("href"); + elem.parentElement.setAttribute( + "href", + href.replace(" at ", elem.textContent) + ); }); });