<commit_before>window.addEventListener("load", function (event) {
  // TODO: check with local storage
  // TODO: if there is a record, fetch the element by index and compute hash
  // TODO: if there is a change on hash,
  //       send the update to the backend (through event page?)
});

// TODO: listen on selecting new region event
// TODO: send adding new region event to event page
<commit_msg>DOM encode/decode<commit_after>function encodeDOM(elem) {
  var breadcrumbs = [];

  while (elem != document) {
    if (elem.id) {
      breadcrumbs.unshift('#' + elem.id);
      break;
    }

    var idx = Array.prototype.indexOf.call(elem.parentNode.childNodes, elem);
    breadcrumbs.unshift(idx);


    elem = elem.parentNode;
  }

  return breadcrumbs.join(' ');
}

function decodeDOM(index_str) {
  var elem = document;
  var indexes = index_str.split(' ');

  for (var i in indexes) {
    if (indexes[i].startsWith('#')) {
      elem = elem.getElementById(indexes[i].substr(1));
    } else {
      elem = elem.childNodes[indexes[i]];
    }
  }

  return elem;
}

window.addEventListener("load", function (event) {
  // check with local storage
  chrome.storage.local.get("monitoring", function (items) {
    var curr_url = window.location.host + "/" + window.location.pathname;
    var monitoring_regions = items.monitoring[curr_url];

    // if there is a record, fetch the element by index and compute hash
    if (monitoring_regions) {
      for (var i in monitoring_regions) {

      }
    }
  });

  // TODO: if there is a change on hash,
  //       send the update to the backend (through event page?)
});

chrome.runtime.onMessage.addListener(
  function(request, sender, sendResponse) {
    // TODO:
    //   selecting new region
  });

// TODO: listen on selecting new region event
// TODO: send adding new region event to event page

{'fraction_non_alphanumeric': 0.12222823147647377, 'fraction_numerical': 0.0005408328826392645, 'mean_word_length': 3.030501089324619, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5118852', 'n_tokens_mistral': 564, 'n_tokens_neox': 555, 'n_words': 177}