<commit_before><commit_msg>Added listeners to add HTTP Host on the right reqs<commit_after>var hostName = '';
var hostHeader = '';

chrome.storage.onChanged.addListener( function syncConfig() {
  chrome.storage.sync.get({
      hostName: '',
      hostHeader: ''
    }, function(items) {
      console.log("loaded config")
      hostName = items.hostName;
      console.log("Filtering requests for %s", hostName)
      hostHeader = items.hostHeader;
      console.log("setting Host to", hostHeader)
    });
})

chrome.webRequest.onBeforeSendHeaders.addListener(
  function filterRequest(details) {
    console.log("hostName is %s, length of %d", hostName, hostName.length)
    // if no hostName is given
    // or the url does not contain the hostname
    // stop processing
    if ((hostName.length == 0) || (details.url.indexOf(hostName) <= -1)) {
      return;
    }
    console.log("Redirecting %s to %s", details.url, hostHeader)
    details.requestHeaders.push({ "name":"Host", "value":hostHeader})

    return {requestHeaders: details.requestHeaders};
  }
  ,
  {urls: ["<all_urls>"]},
  ["blocking", "requestHeaders"]);
{'fraction_non_alphanumeric': 0.14463176574977818, 'fraction_numerical': 0.001774622892635315, 'mean_word_length': 3.6040816326530614, 'pattern_counts': {'":': 2, '<': 5, '<?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': '5164446', 'n_tokens_mistral': 342, 'n_tokens_neox': 339, 'n_words': 83}