<commit_before>// ==UserScript==
// @name           FallenSwordHelper
// @namespace      terrasoft.gr
// @description    Fallen Sword Helper
// @include        https://www.fallensword.com/*
// @include        https://guide.fallensword.com/*
// @include        https://fallensword.com/*
// @include        https://*.fallensword.com/*
// @include        https://local.huntedcow.com/fallensword/*
// @exclude        https://forum.fallensword.com/*
// @exclude        https://wiki.fallensword.com/*
// @exclude        https://www.fallensword.com/app.php*
// @exclude        https://www.fallensword.com/fetchdata.php*
// @version        $_VER
// @downloadURL    $_DLURL
// @grant          none
// ==/UserScript==

// No warranty expressed or implied. Use at your own risk.

// EVERYTHING MUST BE IN main()
function fshMain(ver) {

  window.FSH = window.FSH || {};
  window.FSH.version = ver;

  var cssFiles = ['$_CALFCSS'];
  var scriptFiles = [
    'https://cdnjs.cloudflare.com/ajax/libs/localforage/1.5.3/localforage.min.js',
    '$_CALFJS'
  ];
  if (typeof window.jQuery !== 'undefined') {
    scriptFiles.push('https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js');
  }
  var count = cssFiles.length + scriptFiles.length;

  function onPageLoad() {
    count -= 1;
    if (count === 0) {FSH.dispatch();}
  }

  cssFiles.forEach(function(c) {
    var linkTag = document.createElement('link');
    linkTag.type = 'text/css';
    linkTag.rel = 'stylesheet';
    linkTag.onload = onPageLoad;
    linkTag.href = c;
    document.body.appendChild(linkTag);
  });

  scriptFiles.forEach(function(s) {
    var scriptTag = document.createElement('script');
    scriptTag.type = 'text/javascript';
    scriptTag.onload = onPageLoad;
    scriptTag.src = s;
    document.body.appendChild(scriptTag);
  });

} // end of var main

function setVer() {
  var ver = '$_VER';
  if (typeof GM_info === 'undefined') {return ver + '_native';}
  if (GM_info.scriptHandler === 'Greasemonkey' &&
      Number(GM_info.version.split('.')[0]) >= 4) {return;}
  return ver;
}

function injectFsh(fshVer) {
  var script = document.createElement('script');
  script.textContent = '(' + fshMain.toString() + ')(\'' + fshVer + '\');';
  document.body.appendChild(script);
  document.body.removeChild(script);
}

var getVer = setVer();
if (getVer) {injectFsh(getVer);}<commit_msg>reduce complexity (updated eslint rule 4.14.0)<commit_after>// ==UserScript==
// @name           FallenSwordHelper
// @namespace      terrasoft.gr
// @description    Fallen Sword Helper
// @include        https://www.fallensword.com/*
// @include        https://guide.fallensword.com/*
// @include        https://fallensword.com/*
// @include        https://*.fallensword.com/*
// @include        https://local.huntedcow.com/fallensword/*
// @exclude        https://forum.fallensword.com/*
// @exclude        https://wiki.fallensword.com/*
// @exclude        https://www.fallensword.com/app.php*
// @exclude        https://www.fallensword.com/fetchdata.php*
// @version        $_VER
// @downloadURL    $_DLURL
// @grant          none
// ==/UserScript==

// No warranty expressed or implied. Use at your own risk.

// EVERYTHING MUST BE IN main()
function fshMain(ver) {

  window.FSH = window.FSH || {};
  window.FSH.version = ver;

  var cssFiles = ['$_CALFCSS'];
  var scriptFiles = [
    'https://cdnjs.cloudflare.com/ajax/libs/localforage/1.5.3/localforage.min.js',
    '$_CALFJS'
  ];
  if (typeof window.jQuery !== 'undefined') {
    scriptFiles.push('https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js');
  }
  var count = cssFiles.length + scriptFiles.length;

  function onPageLoad() {
    count -= 1;
    if (count === 0) {FSH.dispatch();}
  }

  cssFiles.forEach(function(c) {
    var linkTag = document.createElement('link');
    linkTag.type = 'text/css';
    linkTag.rel = 'stylesheet';
    linkTag.onload = onPageLoad;
    linkTag.href = c;
    document.body.appendChild(linkTag);
  });

  scriptFiles.forEach(function(s) {
    var scriptTag = document.createElement('script');
    scriptTag.type = 'text/javascript';
    scriptTag.onload = onPageLoad;
    scriptTag.src = s;
    document.body.appendChild(scriptTag);
  });

} // end of var main

var verTest = [
  [
    function() {return GM_info === 'undefined';},
    function(ver) {return ver + '_native';}
  ],
  [
    function() {
      return GM_info.scriptHandler === 'Greasemonkey' &&
        Number(GM_info.version.split('.')[0]) >= 4;
    },
    function() {return false;}
  ],
  [function() {return true;}, function(ver) {return ver;}]
];

function setVer() {
  var ver = '$_VER';
  return verTest.find(function(e) {return e[0]();})[1](ver);
}

function injectFsh(fshVer) {
  var script = document.createElement('script');
  script.textContent = '(' + fshMain.toString() + ')(\'' + fshVer + '\');';
  document.body.appendChild(script);
  document.body.removeChild(script);
}

var getVer = setVer();
if (getVer) {injectFsh(getVer);}
{'fraction_non_alphanumeric': 0.1773448483631251, 'fraction_numerical': 0.006025306286402892, 'mean_word_length': 2.9618138424821003, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 22, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5298979', 'n_tokens_mistral': 1701, 'n_tokens_neox': 1654, 'n_words': 306}