<commit_before>function replaceContent(text){
  var x = document.getElementsByClassName("_2pie");
  x[0].innerHTML = text
}

function getHackerNews(){
  var xhr = new XMLHttpRequest();
  var text = ""
  xhr.onreadystatechange = function() {
      if (xhr.readyState == XMLHttpRequest.DONE) {
          text = processHTML(xhr.responseText)
          replaceContent(text)
      }
  }
  xhr.open('GET', 'https://news.ycombinator.com/', true);
  xhr.send(null);
  return
}
var badlinks = new Array("item", "item", "vote", "newest", "news", "threads", "new","show", "ask", "jobs", "submit", "security", "lists", "bookmark", "dmca", "flag", "hide", "user", "logout", "login", "from")

function processHTML(text){
  var newHTML = ""
  var lines = text.split('\n');

  for(var i = 0;i < lines.length;i++){
    var tempLine = lines[i]
    for(var j = 0; j < badlinks.length; j++){
      index = tempLine.search("href=\"" + badlinks[j])

      if (index != -1){
        tempLine = tempLine.slice(0, index + 5) + "\"https://news.ycombinator.com/" + tempLine.slice(index+6)
      }
    }
    newHTML = newHTML.concat(tempLine) + "\n"
  }
  return newHTML
}

var boo = false
var loop = setInterval(function() {
  var x = document.getElementsByClassName("_2pie")
  var y = document.getElementsByClassName("newsFeedComposer")

  if (x[0] != null){
    if (y[0] != null){
      if (window.boo == false){
      getHackerNews()
      window.boo = true
      }
    }
    else window.boo = false
  }
}, 20);<commit_msg>added comments<commit_after>// replace newsfeed with text
function replaceContent(text){
  var x = document.getElementsByClassName("_2pie");
  x[0].innerHTML = text
}

// get hackernews html and replace newsfeed with it
function getHackerNews(){
  var xhr = new XMLHttpRequest();
  var text = ""
  xhr.onreadystatechange = function() {
      if (xhr.readyState == XMLHttpRequest.DONE) {
          text = processHTML(xhr.responseText)
          replaceContent(text)
      }
  }
  xhr.open('GET', 'https://news.ycombinator.com/', true);
  xhr.send(null);
  return
}

// convert local urls to absolute urls
var badlinks = new Array("item", "item", "vote", "newest", "news", "threads", "new","show", "ask", "jobs", "submit", "security", "lists", "bookmark", "dmca", "flag", "hide", "user", "logout", "login", "from")
function processHTML(text){
  var newHTML = ""
  var lines = text.split('\n');

  for(var i = 0;i < lines.length;i++){
    var tempLine = lines[i]
    for(var j = 0; j < badlinks.length; j++){
      index = tempLine.search("href=\"" + badlinks[j])

      if (index != -1){
        tempLine = tempLine.slice(0, index + 5) + "\"https://news.ycombinator.com/" + tempLine.slice(index+6)
      }
    }
    newHTML = newHTML.concat(tempLine) + "\n"
  }
  return newHTML
}

// checks for newsfeed or mutation to inject hackernews
var boo = false
var loop = setInterval(function() {
  var x = document.getElementsByClassName("_2pie")
  var y = document.getElementsByClassName("newsFeedComposer")

  if (x[0] != null){
    if (y[0] != null){
      if (window.boo == false){
      getHackerNews()
      window.boo = true
      }
    }
    else window.boo = false
  }
}, 20);
{'fraction_non_alphanumeric': 0.17506297229219145, 'fraction_numerical': 0.00818639798488665, 'mean_word_length': 3.2701612903225805, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 4, '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': '64494', 'n_tokens_mistral': 1116, 'n_tokens_neox': 1088, 'n_words': 259}