Skip to content

Commit 5ed93c2

Browse files
authored
Update jep.js2
1 parent 4ea894a commit 5ed93c2

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

jep.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
function jep_link(domain, user) {
2-
const email = `${user}@${domain}`;
3-
const mailto = `mailto:${email}`;
4-
5-
const encode = str => [...str].map(c => `&#${c.charCodeAt(0)};`).join('');
1+
/* jep.js - JavaScript Email Protection (JEP) */
62

7-
const a = document.createElement("a");
8-
a.setAttribute("href", encode(mailto));
9-
a.innerHTML = encode(email);
3+
function jep_link(domain, user) {
4+
// Create email string
5+
let email = `${user}@${domain}`;
6+
7+
// Obfuscate each character using HTML entity codes
8+
let encodedEmail = "";
9+
let encode = str => [...str].map(c => `&#${c.charCodeAt(0)};`).join('');
1010

11-
// Append to a target container (like the calling script's parent)
12-
const scriptEl = document.currentScript;
13-
scriptEl.parentNode.insertBefore(a, scriptEl.nextSibling);
11+
// Insert the obfuscated email link into the DOM
12+
document.write(`<a href="${encode(mailto)}">${encode(email)}</a>`);
1413
}

0 commit comments

Comments
 (0)