File tree Expand file tree Collapse file tree 1 file changed +11
-10
lines changed Expand file tree Collapse file tree 1 file changed +11
-10
lines changed Original file line number Diff line number Diff line change 1- /* jep.js - JavaScript Email Protection (JEP) */
2-
31function 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 ( '' ) ;
2+ const email = `${ user } @${ domain } ` ;
3+ const mailto = `mailto:${ email } ` ;
4+
5+ const encode = str => [ ...str ] . map ( c => `&#${ c . charCodeAt ( 0 ) } ;` ) . join ( '' ) ;
6+
7+ const a = document . createElement ( "a" ) ;
8+ a . setAttribute ( "href" , encode ( mailto ) ) ;
9+ a . innerHTML = encode ( email ) ;
1010
11- // Insert the obfuscated email link into the DOM
12- document . write ( `<a href="${ encode ( mailto ) } ">${ encode ( email ) } </a>` ) ;
11+ // Append to a target container (like the calling script's parent)
12+ const scriptEl = document . currentScript ;
13+ scriptEl . parentNode . insertBefore ( a , scriptEl . nextSibling ) ;
1314}
You can’t perform that action at this time.
0 commit comments