<commit_before>var NEW_PAGE_CHECK_DELAY = 1000;
var GITPRINT_APPLIED_CLASS_FLAG = 'gitprintified';
var CONTAINER_SELECTOR = '#file:not(.' + GITPRINT_APPLIED_CLASS_FLAG + '), #readme:not(.' + GITPRINT_APPLIED_CLASS_FLAG + ')';

function insertButtonsIntoPage($el) {
  var headers = $el.find('> span.name');
  if(headers.length === 0) {
    headers = $el.parent().find('.meta');
  }

  for(var i=0; i<headers.length; i++) {
    var $header = $(headers[i]);

    var $lnkPrint = $(
      '<a class="minibutton gitprint tooltipped tooltipped-n" ' +
          'href="https://gitprint.com' + window.location.pathname + '?print" ' +
          'aria-label="Print this markdown file with GitPrint.com">' +
        '<span class="octicon octicon-file-text"></span> Print'+
      '</a>'
    );

    var $lnkDownload = $(
      '<a class="minibutton gitprint-download tooltipped tooltipped-n" ' +
          'href="https://gitprint.com' + window.location.pathname + '?download" ' +
          'aria-label="Download this markdown file as PDF from GitPrint.com">' +
        '<span class="octicon octicon-file-pdf"></span> Download'+
      '</a>'
    );

    if($el.hasClass('md')) {
      var $actions = $('<div class="actions"><div class="button-group"></div></div>');
      var $btnBar = $actions.find('.button-group');
      
      $btnBar.prepend($lnkDownload);
      $btnBar.prepend($lnkPrint);

      $header.append($actions);
    } else {
      $header.find('.button-group').prepend($lnkDownload, $lnkPrint);
    }
  }
}

function markAsGitified($el) {
  $el.addClass(GITPRINT_APPLIED_CLASS_FLAG);
}

function addGitPrintToPage() {
  $(CONTAINER_SELECTOR).each(
    function(i, el) {
      var $el = $(el);
      insertButtonsIntoPage($el);
      markAsGitified($el);
    }
  );
}

// Add to non-gitprintified markdown areas
$(document).ready(function() {
  addGitPrintToPage();
});<commit_msg>Cleanup, add setInterval to get around pjax<commit_after>var NEW_PAGE_CHECK_DELAY = 1000;
var GITPRINT_APPLIED_CLASS_FLAG = 'gitprintified';
var CONTAINER_SELECTOR = '#file:not(.' + GITPRINT_APPLIED_CLASS_FLAG + '), #readme:not(.' + GITPRINT_APPLIED_CLASS_FLAG + ')';

function insertButtonsIntoPage($el) {
  var headers = $el.find('> span.name');
  if(headers.length === 0) {
    headers = $el.parent().find('.meta');
  }

  for(var i=0; i<headers.length; i++) {
    var $header = $(headers[i]);

    var $lnkPrint = $(
      '<a class="minibutton gitprint tooltipped tooltipped-n" ' +
          'href="https://gitprint.com' + window.location.pathname + '?print" ' +
          'aria-label="Print this markdown file with GitPrint.com">' +
        '<span class="octicon octicon-file-text"></span> Print'+
      '</a>'
    );

    var $lnkDownload = $(
      '<a class="minibutton gitprint-download tooltipped tooltipped-n" ' +
          'href="https://gitprint.com' + window.location.pathname + '?download" ' +
          'aria-label="Download this markdown file as PDF from GitPrint.com">' +
        '<span class="octicon octicon-file-pdf"></span> Download'+
      '</a>'
    );

    if($el.hasClass('md')) {
      var $actions = $('<div class="actions"><div class="button-group"></div></div>');
      var $btnBar = $actions.find('.button-group');
      
      $btnBar.prepend($lnkDownload);
      $btnBar.prepend($lnkPrint);

      $header.append($actions);
    } else {
      $header.find('.button-group').prepend($lnkDownload, $lnkPrint);
    }
  }
}

function markAsGitified($el) {
  $el.addClass(GITPRINT_APPLIED_CLASS_FLAG);
}

function addGitPrintToPage() {
  $(CONTAINER_SELECTOR).each(
    function(i, el) {
      var $el = $(el);
      insertButtonsIntoPage($el);
      markAsGitified($el);
    }
  );
}

// Add to non-gitprintified markdown areas
$(document).ready(function() {
  addGitPrintToPage();
  setInterval(addGitPrintToPage, NEW_PAGE_CHECK_DELAY);
});
{'fraction_non_alphanumeric': 0.17825635703165543, 'fraction_numerical': 0.0031136481577581734, 'mean_word_length': 3.436133486766398, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7215093', 'n_tokens_mistral': 1354, 'n_tokens_neox': 1320, 'n_words': 224}