<commit_before>window.MK = {};
(function (module) {
  /**
   * Simple wrapping function that allows me to inject code when a certain methon or function is called.
   **/
  function wrap(tag, functionToPatch, functionScope, halt) {
    functionScope = functionScope || this;
    var wrapper = function () {
      var args = Array.prototype.slice.apply(arguments, [0]);
      var result = wrapper.orig.apply(functionScope, args);
      console.log(tag, args, result);
      if (halt) {
        debugger;
      }
      return result;
    };
    wrapper.orig = functionToPatch;
    return wrapper;
  }

  // This is what I did to figure out how to get the records. I started with the global scope and found the PB
  // namespace and the interresting looking Crypto "module". Halting the in the decrypt method with a debugger statement
  // gave me a stack frame where I could find other "namespaces". This in turn pointed me to the "assets" in the
  // FA.Background namespace.
  //PB.Crypto.PBKDF2.derive = wrap('PBKDF2', PB.Crypto.PBKDF2.derive, this);
  //PB.crypto.AES.decrypt = wrap('AES', PB.crypto.AES.decrypt, this, true);

  function getDecryptedRecords() {
    var records = [];
    FA.Background.assets.models.forEach(function (item) {
      if (!item.belongsToMe()) {
        return;
      }

      if (item.attributes.memo_k) {
        var clearText = FA.Background.decryptWithAES(item.attributes.memo_k);
        if (FA.isJson(clearText)) {
          item.attributes.memo = JSON.decode(clearText);
        } else {
          item.attributes.memo = clearText;
        }
      }

      if (item.attributes.password_k) {
        item.attributes.password = FA.Background.decryptWithAES(item.attributes.password_k);
      }

      records.push(item.attributes);
    });
    console.log('Extracted ' + records.length + ' records from your database.');
    return records;
  }

  function arrayToCsvRow(cols) {
    // TODO(klingenm): Escape " properly.
    return cols.map(function (col) {
      if (col.indexOf(',') !== -1 || col.indexOf('"') !== -1 || col.indexOf(' ') !== -1) {
        return '"' + col + '"';
      } else {
        return col;
      }
    }).join(', ');
  }

  function isLoggedIn() {
    return FA.Background.fa_login !== null;<commit_msg>JSON.decode -> JSON.parse<commit_after>window.MK = {};
(function (module) {
  /**
   * Simple wrapping function that allows me to inject code when a certain methon or function is called.
   **/
  function wrap(tag, functionToPatch, functionScope, halt) {
    functionScope = functionScope || this;
    var wrapper = function () {
      var args = Array.prototype.slice.apply(arguments, [0]);
      var result = wrapper.orig.apply(functionScope, args);
      console.log(tag, args, result);
      if (halt) {
        debugger;
      }
      return result;
    };
    wrapper.orig = functionToPatch;
    return wrapper;
  }

  // This is what I did to figure out how to get the records. I started with the global scope and found the PB
  // namespace and the interresting looking Crypto "module". Halting the in the decrypt method with a debugger statement
  // gave me a stack frame where I could find other "namespaces". This in turn pointed me to the "assets" in the
  // FA.Background namespace.
  //PB.Crypto.PBKDF2.derive = wrap('PBKDF2', PB.Crypto.PBKDF2.derive, this);
  //PB.crypto.AES.decrypt = wrap('AES', PB.crypto.AES.decrypt, this, true);

  function getDecryptedRecords() {
    var records = [];
    FA.Background.assets.models.forEach(function (item) {
      if (!item.belongsToMe()) {
        return;
      }

      if (item.attributes.memo_k) {
        var clearText = FA.Background.decryptWithAES(item.attributes.memo_k);
        if (FA.isJson(clearText)) {
          item.attributes.memo = JSON.parse(clearText);
        } else {
          item.attributes.memo = clearText;
        }
      }

      if (item.attributes.password_k) {
        item.attributes.password = FA.Background.decryptWithAES(item.attributes.password_k);
      }

      records.push(item.attributes);
    });
    console.log('Extracted ' + records.length + ' records from your database.');
    return records;
  }

  function arrayToCsvRow(cols) {
    // TODO(klingenm): Escape " properly.
    return cols.map(function (col) {
      if (col.indexOf(',') !== -1 || col.indexOf('"') !== -1 || col.indexOf(' ') !== -1) {
        return '"' + col + '"';
      } else {
        return col;
      }
    }).join(', ');
  }

  function isLoggedIn() {
    return FA.Background.fa_login !== null;
{'fraction_non_alphanumeric': 0.1335095836087244, 'fraction_numerical': 0.0030843798193434676, 'mean_word_length': 2.6378205128205128, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '848587', 'n_tokens_mistral': 1403, 'n_tokens_neox': 1373, 'n_words': 366}