FlightRising GUI Improvements Sandboxed Portion

Runs potentially unsafe code in a protective sandbox.

// Generated by CoffeeScript 1.9.3

/* UserScript options {{{1
// ==UserScript==
// @name         FlightRising GUI Improvements Sandboxed Portion
// @description  Runs potentially unsafe code in a protective sandbox.
// @namespace    ahto
// @version      1.1.2
// @include      http://*flightrising.com/*
// @require      https://greasyfork.org/scripts/10922-ahto-library/code/Ahto%20Library.js?version=75750
// @grant        GM_addStyle
// ==/UserScript==
 */
var addCheckboxListeners, updateCheckbox;

if (new RegExp('http://www1\.flightrising\.com/msgs$', 'i').test(document.location.href)) {
  GM_addStyle('#ajaxbody tr.highlight-tr.selected-tr {\n    background-color: #CAA;\n}\n\n#ajaxbody tr.selected-tr {\n    background-color: #CBB;\n}');
  updateCheckbox = function(targetCheckbox) {
    var tr;
    tr = targetCheckbox.parents('tr');
    if (targetCheckbox.prop('checked')) {
      return tr.addClass('selected-tr');
    } else {
      return tr.removeClass('selected-tr');
    }
  };
  addCheckboxListeners = function() {
    return findMatches('#ajaxbody tr input[type=checkbox]').click(function(event) {
      return updateCheckbox($(event.target));
    });
  };
  addCheckboxListeners();
  findMatches('input#set', 1, 1).click(function(event) {
    var i, j, len, ref, results;
    ref = findMatches('#ajaxbody tr input[type=checkbox]');
    results = [];
    for (j = 0, len = ref.length; j < len; j++) {
      i = ref[j];
      results.push(updateCheckbox($(i)));
    }
    return results;
  });
  findMatches('img#prev, img#next, button#delete-confirm-yes', 0, 3).click(function(event) {
    return setTimeout((function() {
      return addCheckboxListeners();
    }), 500);
  });
}