(function(root, factory) {
  if(typeof define === 'function' && define.amd) {
    define([], factory);
  } else if(typeof exports === 'object') {
    module.exports = factory();
  } else {
    root.lsbridge = factory();
  }
}(this, function() {

  /* 
    - Storing messages in localStorage.
    - Clients subscribe to the changes and
      they get notified if a new message arrives.
  */

  var api = {};

  api.isLSAvailable = (function() {
    var mod = '_';
    try {
      localStorage.setItem(mod, mod);
      localStorage.removeItem(mod);
      return true;
    } catch(e) {
      return false;
    }
  })();

  if(api.isLSAvailable) {

    var interval = 100
      , intervalForRemoval = 200
      , ls = localStorage
      , listeners = {}
      , isLoopStarted = false
      , buffer = {};

    var loop = function () {
      for(var namespace in listeners) {
        var data = ls.getItem(namespace);
        if (data && buffer[namespace] && buffer[namespace].indexOf(data) === -1) {
          buffer[namespace].push(data);
          try {
            var parsed = JSON.parse(data);
            if(parsed) data = parsed;
          } catch(e) {}
          for (var i = 0; i < listeners[namespace].length; i++) {
            listeners[namespace][i](data);
          }
          if(!ls.getItem(namespace + '-removeit')) {
            ls.setItem(namespace + '-removeit', '1');
          }

          (function (n) {
              setTimeout(function () {
                  console.log("remove");
                  ls.removeItem(n);
                  ls.removeItem(n + '-removeit');
                  buffer[namespace] = [];
              }, intervalForRemoval);
          })(namespace);

        } else if (!data) {
          buffer[namespace] = [];
        }
      }
      setTimeout(loop, interval);
      return true;
    };

    api.send = function (namespace, data) {
      var raw = '';
      if(typeof data === 'function') { data = data(); }
      if(typeof data === 'object') {
        raw = JSON.stringify(data);
      } else {
        raw = data;
      }
      ls.setItem(namespace, raw);
    };

    
    api.subscribe = function (namespace, cb) {
      if(!listeners[namespace]) {
        listeners[namespace] = [];
        buffer[namespace] = [];
      }
      listeners[namespace].push(cb);
      if(!isLoopStarted) {
        isLoopStarted = loop();
      }
    };

    api.getBuffer = function() {
      return buffer;
    }

  } else {
    api.send = api.subscribe = function() {
      throw new Error('localStorage not supported.');
    }
  }

  return api;
}));

@@ -810,33 +810,32 @@
  loop = function
- 
 () %7B%0A      for(v
@@ -915,17 +915,16 @@
       if
- 
 (data &&
@@ -1165,25 +1165,20 @@
  for
- 
 (var i
- = 
+=
 0; i
- %3C 
+%3C
 list
@@ -1383,17 +1383,16 @@
       %7D%0A
-%0A
         
@@ -1406,17 +1406,14 @@
 tion
- 
 (n) %7B%0A
-  
     
@@ -1443,59 +1443,13 @@
 tion
- 
 () %7B%0A
-                  console.log(%22remove%22);%0A    
     
@@ -1476,20 +1476,16 @@
 tem(n);%0A
-    
         
@@ -1532,28 +1532,24 @@
             
- 
-   
 buffer%5Bnames
@@ -1556,26 +1556,24 @@
 pace%5D = %5B%5D;%0A
-  
             
@@ -1621,17 +1621,16 @@
 space);%0A
-%0A
         
@@ -1638,17 +1638,16 @@
  else if
- 
 (!data) 
@@ -1776,33 +1776,32 @@
 .send = function
- 
 (namespace, data
@@ -2071,17 +2071,16 @@
 function
- 
 (namespa

Update lsbridge.js