mail obfuscater: change link
This commit is contained in:
parent
024fa67682
commit
ed404bacca
2 changed files with 11 additions and 4 deletions
|
@ -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()
|
||||
},
|
||||
|
|
|
@ -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)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue