nike / Kamihime Project R - Display accessory percentages and slots

// ==UserScript==
// @name         Kamihime Project R - Display accessory percentages and slots
// @description  Displays accessory percentages and potential slots directly on accessory card.
// @updateURL    https://openuserjs.org/meta/nike/Kamihime_Project_R_-_Display_accessory_percentages_and_slots.meta.js
// @license      MIT
// @match        https://gnkh-api-r.prod.nkh.dmmgames.com/front/cocos2d-proj/components-pc/game/app.html
// @run-at       document-start
// ==/UserScript==
(function () {

  var interval = setInterval(function () {
    if (typeof kh !== 'undefined' && kh.CoreCardAccessoryUI) {
      clearInterval(interval);

      var _orig_accessory_card_set_data = kh.CoreCardAccessoryUI.prototype.setData

      kh.CoreCardAccessoryUI.prototype.setData = function (record, sortCondition, componentName) {
        _orig_accessory_card_set_data.apply(this, arguments)

        switch (this._currentActionName) {
          case this.ACTION_NAME_FULL:
            var nodeNameExp = /^status_label_/;
            this.uiNode.seekWidgets(function (node) {
              if (nodeNameExp.test(node.getName())) {
                node.setText("");
              }
            });
            if (!_.isUndefined(record.sub_effects)) {
              _.each(record.sub_effects, function (sub_effect, num) {
                this.setIconSubEffectLabel(num, sub_effect);
              }.bind(this));
            }
            break;
          default:
            break;
        }
      }

      kh.CoreCardAccessoryUI.prototype.setIconSubEffectLabel = function (num, icon) {
        var statusLabelNode = this.uiNode.seekWidgetByName("status_label_" + num)
        if (!statusLabelNode) {
          var position = null
          switch (num) {
            case 0:
              position = 98.5
              break;
            case 1:
              position = 70.5
              break;
            case 2:
              position = 42.5
              break;
            default:
              break;
          }
          var status_label_node = new ccui.Text()
          status_label_node.setName("status_label_" + num)
          status_label_node.setPosition(35, position);
          status_label_node.setAnchorPoint(0, 0.5);
          status_label_node.setFontSize(13);
          status_label_node.setFontName("GameFont")
          status_label_node.enableOutline(cc.color(0, 0, 0), 3);
          this.uiNode.addChild(status_label_node)
          statusLabelNode = status_label_node
        }

        var additionalDesciptor = ""
        var desciptorMap = {
          "Damage reduction* activated at 50% HP or less": "L",
          "Damage reduction *activates in front": "F",
          "Damage reduction *activates in rear": "R",
          "Damage reduction* activated at 75% HP or more": "H",
  		  "Damage UP*Effect decreases with the number of turns: Max": "↓",
		  "Damage UP*Effect increases with the number of turns: Max": "↑",
        }
        var mapEntry = desciptorMap[icon.name]
        if (mapEntry) {
          additionalDesciptor = " " + mapEntry
        }

        statusLabelNode.setText((icon.slot_number ? "[" + icon.slot_number + "] " + icon.effect_rate + "%" : icon.effect_rate + "%") + additionalDesciptor)

      }

    }
  }, 10);

})();