<commit_before>import insertHtmlBeforeEnd from '../common/insertHtmlBeforeEnd';
import querySelector from '../common/querySelector';
import regExpFirstCapture from '../common/regExpFirstCapture';
import addCommas from '../system/addCommas';

function getIntFromRegExp(theText, rxSearch) {
  const matches = regExpFirstCapture(rxSearch, theText.replace(/,/g, ''));
  return matches ? parseInt(matches, 10) : 0;
}

function mightBePositive(actualXP, xpLockXP) {
  let sign = '';
  if (actualXP > xpLockXP) { sign = '+'; }
  return sign + addCommas(actualXP - xpLockXP);
}

function injectLock(xpLock) {
  const xpLockmouseover = xpLock.dataset.tipped;
  const xpLockXP = getIntFromRegExp(xpLockmouseover, /XP Lock: <b>(?<lockXp>\d*)/);
  const actualXP = getIntFromRegExp(xpLockmouseover, /XP: <b>(?<realXp>\d*)/);
  insertHtmlBeforeEnd(
    xpLock.parentNode.nextElementSibling,
    ` (<b>${mightBePositive(actualXP, xpLockXP)}</b>)`,
  );
}

export default function guildXPLock() {
  const xpLock = querySelector('#pCC a[data-tipped^="<b>Guild XP</b>"]');
  if (xpLock) { injectLock(xpLock); }
}<commit_msg>hide-guildxplock (#460)<commit_after>import insertHtmlBeforeEnd from '../common/insertHtmlBeforeEnd';
import querySelector from '../common/querySelector';
import regExpFirstCapture from '../common/regExpFirstCapture';
import calf from '../support/calf';
import addCommas from '../system/addCommas';

function getIntFromRegExp(theText, rxSearch) {
  const matches = regExpFirstCapture(rxSearch, theText.replace(/,/g, ''));
  return matches ? parseInt(matches, 10) : 0;
}

function mightBePositive(actualXP, xpLockXP) {
  let sign = '';
  if (actualXP > xpLockXP) { sign = '+'; }
  return sign + addCommas(actualXP - xpLockXP);
}

function injectLock(xpLock) {
  const xpLockmouseover = xpLock.dataset.tipped;
  const xpLockXP = getIntFromRegExp(xpLockmouseover, /XP Lock: <b>(?<lockXp>\d*)/);
  const actualXP = getIntFromRegExp(xpLockmouseover, /XP: <b>(?<realXp>\d*)/);
  insertHtmlBeforeEnd(
    xpLock.parentNode.nextElementSibling,
    ` (<b>${mightBePositive(actualXP, xpLockXP)}</b>)`,
  );
}

export default function guildXPLock() {
  if (!calf.userIsDev) return; // guildXPLock
  const xpLock = querySelector('#pCC a[data-tipped^="<b>Guild XP</b>"]');
  if (xpLock) { injectLock(xpLock); }
}
{'fraction_non_alphanumeric': 0.15871639202081528, 'fraction_numerical': 0.0039028620988725065, 'mean_word_length': 5.390581717451523, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 21, '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': '6253345', 'n_tokens_mistral': 845, 'n_tokens_neox': 799, 'n_words': 155}