(function (window) {
  var TIMEOUT = 10000;

  tryAndFindMarty(1);

  function tryAndFindMarty(time) {
    if (window.Marty) {
      listenToMarty(window.Marty);
    } else {
      if (time > TIMEOUT) {
        postMessage('PAGE_LOADED', {
          martyFound: false
        });
        return;
      }

      setTimeout(function () {
        tryAndFindMarty(time * 2);
      }, time);
    }
  }

  function listenToMarty(Marty) {
    if (Marty.Diagnostics) {
      Marty.Diagnostics.devtoolsEnabled = true;
    }

    postMessage('PAGE_LOADED', {
      martyFound: true,
      stores: Marty.dehydrate().toJSON()
    });

    var Dispatcher = Marty.Dispatcher.getDefault();

    Marty.addStoreChangeListener(onStoreChanged);
    Dispatcher.onActionDispatched(onActionDispatched);

    function onActionDispatched(action) {
      postMessage('ACTION_DISPATCHED', action.toJSON());
    }

    function onStoreChanged(state, store) {
      var state = (store.dehydrate || store.getState).call(store)

      postMessage('STORE_CHANGED', {
        id: store.id,
        state: state,
        displayName: store.displayName
      });
    }
  }

  function postMessage(type, payload) {
    try {
      window.postMessage(message(type, payload), '*');
    } catch (e) {
      console.error('failed to post message', payload, e);
    }
  }

  function message(type, payload) {
    return {
      type: type,
      payload: payload || {},
      source: 'marty-extension'
    };
  }
})(window);
@@ -38,16 +38,730 @@
 10000;%0A%0A
+  var MartyDevTools = %7B%0A    serializers: %7B%0A      immutable: %7B%0A        canSerialize: function (obj) %7B%0A          return !!obj.toJS;%0A        %7D,%0A        serialize: function (obj) %7B%0A          return obj.toJS();%0A        %7D%0A      %7D%0A    %7D,%0A    registerSerializer: function (serializer) %7B%0A      if (!serializer.id) %7B%0A        throw new Error('Serializer must have an Id');%0A      %7D%0A%0A      if (!serializer.serialize) %7B%0A        throw new Error('Serializer must have a %60serialize%60 function');%0A      %7D%0A%0A      if (!serializer.canSerialize) %7B%0A        throw new Error('Serializer must have a %60canSerialize%60 function');%0A      %7D%0A%0A      this.serializers%5Bserializer.id%5D = serializer;%0A    %7D%0A  %7D;%0A%0A  window.MartyDevTools = MartyDevTools;%0A%0A
   tryAnd
@@ -774,16 +774,16 @@
 rty(1);%0A
-
 %0A  funct
@@ -1839,32 +1839,660 @@
  %7D);%0A    %7D%0A  %7D%0A%0A
+  function serialize(obj) %7B%0A    var result;%0A    var serialized = false;%0A%0A    Object.keys(MartyDevTools.serializers).forEach(function (id) %7B%0A      var serializer = MartyDevTools.serializers%5Bid%5D;%0A%0A      try %7B%0A        if (serializer.canSerialize(obj)) %7B%0A          result = serializer.serializer(obj);%0A          serialized = true;%0A        %7D%0A      %7D catch (e) %7B%0A        console.error('The', id, 'serializer failed to serialize', obj, e);%0A      %7D%0A    %7D);%0A%0A    if (!serialized) %7B%0A      result = defaultSerializer(obj);%0A    %7D%0A%0A    return result;%0A  %7D%0A%0A  function defaultSerializer(obj) %7B%0A    return JSON.parse(JSON.stringify(obj));%0A  %7D%0A%0A
   function postM
@@ -2739,38 +2739,8 @@
 pe,%0A
-      payload: payload %7C%7C %7B%7D,%0A
     
@@ -2766,16 +2766,66 @@
 tension'
+,%0A      payload: payload ? serialize(payload) : %7B%7D
 %0A    %7D;%0A

Add support for serializers