Author: | bearbyt3z |
---|---|
Views Total: | 22 views |
Official Page: | Go to website |
Last Update: | March 27, 2023 |
License: | MIT |
Preview:

Description:
A powerful and user-friendly JavaScript solution to protect spambots from harvesting email addresses from your website.
The library encodes email addresses using ROT13 letter substitution cipher and automatically decodes them whenever the user clicks on the mailto
link.
How to use it:
1. Download and import the email-protector.js into the page.
<script src="email-protector.js"></script>
2. Use the rot()
function to encode an email address
// encoded with 13 let myEmail = EmailProtector.rot('[email protected]'); // encoded with 11 let myEmail = EmailProtector.rot('[email protected]', 11); // encoded with 36 let myEmail = EmailProtector.rot('[email protected]', 36);
3. Insert the encoded email address into the page.
<span id="email-protector"></span>
// using append() method EmailProtector.append('email-protector', myEmail); // using write() method EmailProtector.write(myEmail); // decoding with 15, because it was encoded with 11 EmailProtector.write('[email protected]', { code: 15 }); // or ... EmailProtector.write({ email: '[email protected]', subject: 'Message from www', body: 'Hi, I\'m contacting you', cc: '[email protected]', bcc: '[email protected]' });
4. You can also specify an email link label.
EmailProtector.append('email-protector', '[email protected]', { linkLabel: 'email link label' });
5. Using global parameters and configuration.
EmailProtector.setGlobalParams({ email: '[email protected]', subject: 'Message from www' }); EmailProtector.setGlobalConfig({ code: 15, hiddenSpan: false, htmlComments: false }); ... EmailProtector.write(); // reset params and configs EmailProtector.resetParams(); EmailProtector.resetConfig(); ... EmailProtector.write('[email protected]');
6. All default parameters and configs for append()
and write()
functions
EmailProtector.write('[email protected]', { code: 13, cssReverse: true, hiddenSpan: true, htmlComments: true });
Changelog:
v0.6.1 (03/27/2023)
- Bugfix
v0.5.2 (05/21/2022)
- Replaced deprecated String.prototype.substr() with substring()
04/23/2021
- Fixed bug with decoding a user name containing dots