mail obfuscater: change link

This commit is contained in:
Mylloon 2024-05-29 20:51:04 +02:00
parent 024fa67682
commit ed404bacca
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
2 changed files with 11 additions and 4 deletions

View file

@ -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}<span class='at'>(at)</span>{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()
},

View file

@ -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)
);
});
});