npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gulp-hide-email

v0.4.4

Published

A robust gulp email obfuscation plugin wtih the support for streaming and file buffers.

Downloads

6

Readme

gulp-hide-email

Build Status npm version npm Dependencies Coverage Status

A robust email obfuscation (pseudo-encryption) plugin with the support for streaming and file buffers, perfectly suited for complex gulp tasks. gulp-hide-email automatically detects email links and replaces them with efficient, non-blocking inline JavaScript.

gulp-hide-email can process the most common HTML5 mailto cases including:

<a href="mailto:[email protected]?subject=Job%20Application">Apply now</a>

which after processing becomes,

<span id="">
  <script>document.getElementById("").innerHTML='<n uers="znvygb:[email protected]?fhowrpg=Wbo%20Nccyvpngvba">Nccyl abj</n>'.replace(/[a-zA-Z]/g,function(c){return String.fromCharCode((c<="Z"?90:122)>=(c=c.charCodeAt(0)+13)?c:c-26);});
  </script>
</span>

gulp-hide-email is perfectly suited for heavily nested cases with multiple DOM elements in-between the <a>...</a> e.g.

<a href="mailto:[email protected]?subject=Job%20Application">
  <span id="something" class="x1 x2 x3" style="padding-bottom: -20px;">
    <div>Test</div>
  </span>
</a>

The resultant JavaScript is efficient and unobtrusive, hence you should not observe any noticeable drop in the rendering performance, nor a render-blocking behavior.

Please check http://www.tamiola.com for working demo. Multiple mailto: instances have been effectively processed on our page.

Usage

First, install gulp-hide-email as a development dependency:

npm install --save-dev gulp-hide-email

Then, add it to your gulpfile.js.

Email obfuscation

This is an example workflow with the human-readable (verbose:true) output, so you can monitor what goes into gulp-hide-email.

var obfuscateEmail = require('gulp-hide-email');

gulp.task('obfuscate', function(){
  gulp.src(['index.html'])
    // Obfuscate Block
    .pipe(obfuscateEmail({verbose: true}))
    // End of Obfuscate Block
    .pipe(gulp.dest('build/index.html'));
});

API

gulp-hide-email accepts options in a form of a typical JSON Object.

options

Type: Object

options.idPrefix

Type: string
Default: null

Generate custom DOM id tags, labeled in a sequential order for the inline JavaScript code. This option may come in handy, when you want to do some extra operations on the "injected" JavaScript code, and need to know the DOM id tags a priori. By default, gulp-hide-email generates random labels.

.pipe(obfuscateEmail({ idPrefix:"obfuscate_" }))

will yield,

<span id="obfuscate_1"><script>document.getElementById("obfuscate_1").innerHTML='<!---OBFUSCATED CODE--->'.replace(/[a-zA-Z]/g,function(c){return String.fromCharCode((c<="Z"?90:122)>=(c=c.charCodeAt(0)+13)?c:c-26);});</script></span>
options.verbose

Type: boolean
Default: false

Produce detailed output from obfuscation. Useful for debugging and supervision, especially when you deal with multiple mailto: instances and you want to see what went into gulp-hide-email.

.pipe(obfuscateEmail({ verbose:true }))
options.test

Type: boolean
Default: false

Disable automated generation of DOM id elements. (This option is implemented only for testing purposes, and should be set to false in all gulp production scripts.)