Socket
Socket
Sign inDemoInstall

droideka

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

droideka - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

61

index.js

@@ -1,3 +0,3 @@

var _ = require('lodash');
var cuid = require("cuid");
var shuffle = require('knuth-shuffle-seeded');

@@ -8,36 +8,37 @@ var chars_to_encode = "\"'~!@#$%^&*()<:>[]{}.,+=-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";

var encode = function(text){
var key = _.shuffle(chars_to_encode.split("")).join("")
var encode = function(text, seed){
var key = shuffle(chars_to_encode.split(""), seed).join("");
return key + _.map(text.split(""), function(c){
var i = key.indexOf(c);
return i < 0 ? c : key[(i + text.length) % key.length];
}).join('');
return key + text.split("").map(function(c){
var i = key.indexOf(c);
return i < 0 ? c : key[(i + text.length) % key.length];
}).join('');
};
module.exports = function(html){
var inserts = {};
html = _.map(html.split(/(<a href="mailto:(?:[^"]*)">(?:[^<]*)<\/a>)/gi), function(html_block, i){
var matches = /^<a href="mailto:([^"]*)">(?:[^<]*)<\/a>$/gi.exec(html_block);
if(matches && matches.length === 2){
var email = matches[1];
var id = cuid();
inserts[id] = '<a href="mailto:'+email+'">'+email+'</a>';
return '<span id="'+id+'"><noscript>You must enable JavaScript to see the email.</noscript></span>';
}
return html_block;
}).join('');
if(!_.isEmpty(inserts)){
html += '<script type="application/javascript">';
html += 'setTimeout(function(){';
html += js_code_decode;
html += _.map(inserts, function(html, id){
return '(function(){var a=document.getElementById("'+id+'");if(!a)return;a.innerHTML=d('+JSON.stringify(encode(html))+');}());';
}).join('');
html += '}, 500);';
html += '</script>';
}
return html;
module.exports = function(html, seed){
var inserts = {};
html = html.split(/(<a href="mailto:(?:[^"]*)">(?:[^<]*)<\/a>)/gi).map(function(html_block, i){
var matches = /^<a href="mailto:([^"]*)">(?:[^<]*)<\/a>$/gi.exec(html_block);
if(matches && matches.length === 2){
var email = matches[1];
var id = cuid();
inserts[id] = '<a href="mailto:'+email+'">'+email+'</a>';
return '<span id="'+id+'"><noscript>You must enable JavaScript to see the email.</noscript></span>';
}
return html_block;
}).join('');
if(Object.keys(inserts).length > 0){
html += '<script type="application/javascript">';
html += 'setTimeout(function(){';
html += js_code_decode;
html += Object.keys(inserts).map(function(id){
var html = inserts[id];
return '(function(){var a=document.getElementById("'+id+'");if(!a)return;a.innerHTML=d('+JSON.stringify(encode(html, seed))+');}());';
}).join('');
html += '}, 500);';
html += '</script>';
}
return html;
};
module.exports.encode = encode;
module.exports.js_code_decode = js_code_decode;
{
"name": "droideka",
"version": "1.0.0",
"version": "1.1.0",
"description": "fight back against email scrapers",

@@ -23,4 +23,8 @@ "main": "index.js",

"cuid": "^1.3.8",
"lodash": "^3.10.1"
"knuth-shuffle-seeded": "^1.0.6"
},
"devDependencies": {
"lodash": "^4.12.0",
"tape": "^4.5.1"
}
}
# droideka
[![build status](https://secure.travis-ci.org/smallhelm/droideka.png)](https://travis-ci.org/smallhelm/droideka)
[![dependency status](https://david-dm.org/smallhelm/droideka.svg)](https://david-dm.org/smallhelm/droideka)
fight back against email scrapers
# What it does
## What it does

@@ -10,3 +14,3 @@ * finds all `<a href="mailto:...` email addresses in your html

# How to use it
## How to use it

@@ -17,3 +21,3 @@ ```js

## html = droideka(html)
### html = droideka(html[, seed])

@@ -49,7 +53,9 @@ Your HTML

## var encoded = droideka.encode(text)
`seed` can be any string, i.e. your package.json's version string.
### encoded = droideka.encode(text[, seed])
Lightly encrypt some text. (not cryptographically secure)
## droideka.js\_code\_decode
### droideka.js\_code\_decode

@@ -65,24 +71,3 @@ A string of JS code that creates a local function `d` that can be used for decoding.

# License
The MIT License (MIT)
Copyright (c) 2015 Small Helm LLC
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
## License
MIT
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc