<commit_before>import { send as sendMessage } from './messaging';
import { $ } from './util';

let nameFormat;

sendMessage({ action: 'get', key: 'nm_disp' }, (response) => {
  nameFormat = response.val;
});

function removeElMatchingSel(sel, node) {
  if (!$(sel, node) || !sel) {
    return;
  }

  $(sel, node)[0].remove();
}

export function rewriteElMatchingSel(sel, node, html) {
  if (!$(sel, node) || !sel) {
    return;
  }

  $(sel, node)[0].innerHTML = html;
}

export function format({ node, user, fSel, uSel }) {
  switch (nameFormat) {
    default:
      break;

    case 'fullname':
      removeElMatchingSel(uSel, node);
      rewriteElMatchingSel(fSel, node, user.name);
      break;

    case 'username':
      removeElMatchingSel(uSel, node);
      rewriteElMatchingSel(fSel, node, user.screenName);
      break;

    case 'inverted':
      rewriteElMatchingSel(fSel, node, user.screenName);
      rewriteElMatchingSel(uSel, node, user.name);
      break;
  }
}

export function formatGroupDM({ node, participants, fSel }) {
  switch (nameFormat) {
    default:
      break;

    case 'inverted':
    case 'username':
      ($(fSel, node) || []).forEach((el, i) => {
        el.innerHTML = participants[i].screenName;
      });
      break;
  }
}<commit_msg>:wrench: use the emojifiedName to substitute names<commit_after>import { send as sendMessage } from './messaging';
import { $ } from './util';

let nameFormat;

sendMessage({ action: 'get', key: 'nm_disp' }, (response) => {
  nameFormat = response.val;
});

function removeElMatchingSel(sel, node) {
  if (!$(sel, node) || !sel) {
    return;
  }

  $(sel, node)[0].remove();
}

export function rewriteElMatchingSel(sel, node, html) {
  if (!$(sel, node) || !sel) {
    return;
  }

  $(sel, node)[0].innerHTML = html;
}

export function format({ node, user, fSel, uSel }) {
  switch (nameFormat) {
    default:
      break;

    case 'fullname':
      removeElMatchingSel(uSel, node);
      rewriteElMatchingSel(fSel, node, user.emojifiedName || user.name);
      break;

    case 'username':
      removeElMatchingSel(uSel, node);
      rewriteElMatchingSel(fSel, node, user.screenName);
      break;

    case 'inverted':
      rewriteElMatchingSel(fSel, node, user.screenName);
      rewriteElMatchingSel(uSel, node, user.emojifiedName || user.name);
      break;
  }
}

export function formatGroupDM({ node, participants, fSel }) {
  switch (nameFormat) {
    default:
      break;

    case 'inverted':
    case 'username':
      ($(fSel, node) || []).forEach((el, i) => {
        el.innerHTML = participants[i].screenName;
      });
      break;
  }
}
{'fraction_non_alphanumeric': 0.15787476280834914, 'fraction_numerical': 0.0015180265654648956, 'mean_word_length': 3.1642969984202214, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '1746961', 'n_tokens_mistral': 938, 'n_tokens_neox': 884, 'n_words': 206}