jizy-obfuscator
v1.0.5
Published
UnObfuscate email addresses from the DOM
Readme
jizy-obfuscator
Un-obfuscate email addresses (and other sensitive strings) in the DOM at runtime, keeping them hidden from most scrapers.
Content is stored ROT13-encoded inside placeholder elements and decoded client-side on page load.
Install
npm install jizy-obfuscatorHow it works
Server-side, encode each email with ROT13 and emit a placeholder with a matching id:
Contact: <span id="obfuscated-0"></span> Support: <span id="obfuscated-1"></span>Client-side, pass the ROT13-encoded strings (in the same order as the ids) to
Obfuscator.decode:import { Obfuscator } from 'jizy-obfuscator'; Obfuscator.decode([ '<n uers="znvygb:[email protected]">[email protected]</n>', // -> <a href="mailto:[email protected]">[email protected]</a> '<n uers="znvygb:[email protected]">[email protected]</n>' ]);Each entry replaces
#obfuscated-<index>viaouterHTML, so the decoded HTML can include links or any markup.
API
Obfuscator.decode(obfuscated)
obfuscated—string[]of ROT13-encoded HTML fragments. Indexireplaces the element#obfuscated-i.
ROT13 is its own inverse: encode and decode use the same transform. Non-letter characters (digits, @, ., tags, attributes) pass through unchanged.
Browser build
A prebuilt bundle is available at dist/js/jizy-obfuscator.min.js for direct <script> inclusion.
License
MIT © Joffrey Demetz
