1.0.0 • Published 9 years ago

deferer v1.0.0

Weekly downloads
4
License
MIT
Repository
github
Last release
9 years ago

deferer

A drop-in script for handling traffic from unwanted sources.

Usage

Drop the following code in to the <head> tag of your document.

<script type="text/javascript">
  ;(function() {
    var dfrr = document.createElement('script'); dfrr.type = 'text/javascript'; dfrr.async = true;
    dfrr.src = 'deferer.min.js';
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(dfrr, s);
  })();
</script>

By default, traffic sent from reddit.com will be redirected to an innocuous destination.

To configure the host blacklist or redirect URL, use the _deferer object to pass options to the script:

<script type="text/javascript">
  var _deferer = {};
  _deferer['hosts'] = ['reddit.com', 'news.ycombinator.com'];
  _deferer['redirect'] = 'http://google.com/';

  ;(function() {
    var dfrr = document.createElement('script'); dfrr.type = 'text/javascript'; dfrr.async = true;
    dfrr.src = 'deferer.min.js';
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(dfrr, s);
  })();
</script>

Available options are:

  • hosts: an array of hostnames specified as strings
  • redirect: a URL to redirect traffic to specified as a string

FAQ

  1. Shouldn't it be spelled "deferrer"?

    No.

Local Development

Dependencies:

  • node
  • npm
  • uglify-js

To generate the minified asset, run:

npm run-script prepublish
1.0.0

9 years ago