Fix Everything

var FixEverything = {
  JQUERY: '//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js',
  LOCATIONS: {
    '^https?://codereview.nasuni.net': 'reviewboard',
  },

  reviewboard: function() {
    $('.page-sidebar-row .count').remove();
  },

  log: function(msg) {
    console.log('[FIX] '+ msg)
  },

  load_jquery: function(callback) {
    if (window.$ !== undefined) { return callback(); }
    this.log('Loading script: '+ this.JQUERY);
    var script = document.createElement('script');
    script.src = this.JQUERY;
    script.type = 'text/javascript';
    script.onload = function() { $ = window.jQuery; callback(); };
    document.getElementsByTagName('head')[0].appendChild(script);
  },

  init: function() {
    var self = this;
    var location = null;
    if (window.self !== window.top) { return; }
    this.log('Fixing all teh things!');
    for (var regex in this.LOCATIONS) {
        var re = new RegExp(regex, 'i');
      var match = window.location.href.match(re);
      if (match) { location = this.LOCATIONS[regex]; }
    }
    if (location !== null) {
      this.log('Matched '+ location);
      this.load_jquery(function() {
        self[location]();
      });
    }
  },

}

document.addEventListener("loaded-everything", function(e) {
  FixEverything.init();
});