nike / Kamihime Project R - More enemy statuses

// ==UserScript==
// @name         Kamihime Project R - More enemy statuses
// @description  Displays more enemy statuses, max 40 instead of 8
// @updateURL    https://openuserjs.org/meta/nike/Kamihime_Project_R_-_More_enemy_statuses.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.EnemyStatusBar) {
            clearInterval(interval);

            kh.ENEMY_STATUS_BAR_ELEMENT_NAMES.STATUS_ICONS.COUNT = 40

            var generateEnemyStatusUi = function(enemyCard, index, x, y, opacity) {
                var newStatusName = "status_position_" + index.toString()
                var targetStatus = ccui.helper.seekWidgetByName(enemyCard, newStatusName)
                if (typeof targetStatus === 'undefined' || targetStatus === null) {
                    var status7 = ccui.helper.seekWidgetByName(enemyCard, "status_position_7")
                    var new_status = khutil.cloneWithAction(status7)
                    new_status.setName(newStatusName)
                    new_status.setPosition(x, y)
                    new_status.setOpacity(opacity)
                    var enemyHudBase = ccui.helper.seekWidgetByName(enemyCard, "enemy_hud_base")
                    enemyHudBase.addChild(new_status)
                }
            }

            kh.EnemyStatusBar.prototype._initStatusEffectIconHandler = function(rootNode, widgetNamePrefixes) {
                generateEnemyStatusUi(rootNode, 8, 242 + 23 * 1, 11, 255)
                generateEnemyStatusUi(rootNode, 9, 242 + 23 * 2, 11, 255)
                generateEnemyStatusUi(rootNode, 10, 242 + 23 * -7, 11 - 25, 255)
                generateEnemyStatusUi(rootNode, 11, 242 + 23 * -6, 11 - 25, 255)
                generateEnemyStatusUi(rootNode, 12, 242 + 23 * -5, 11 - 25, 255)
                generateEnemyStatusUi(rootNode, 13, 242 + 23 * -4, 11 - 25, 255)
                generateEnemyStatusUi(rootNode, 14, 242 + 23 * -3, 11 - 25, 255)
                generateEnemyStatusUi(rootNode, 15, 242 + 23 * -2, 11 - 25, 255)
                generateEnemyStatusUi(rootNode, 16, 242 + 23 * -1, 11 - 25, 255)
                generateEnemyStatusUi(rootNode, 17, 242 + 23 * 0, 11 - 25, 255)
                generateEnemyStatusUi(rootNode, 18, 242 + 23 * 1, 11 - 25, 255)
                generateEnemyStatusUi(rootNode, 19, 242 + 23 * 2, 11 - 25, 255)
                generateEnemyStatusUi(rootNode, 20, 242 + 23 * -7, 11 - 25 * 2, 255)
                generateEnemyStatusUi(rootNode, 21, 242 + 23 * -6, 11 - 25 * 2, 255)
                generateEnemyStatusUi(rootNode, 22, 242 + 23 * -5, 11 - 25 * 2, 255)
                generateEnemyStatusUi(rootNode, 23, 242 + 23 * -4, 11 - 25 * 2, 255)
                generateEnemyStatusUi(rootNode, 24, 242 + 23 * -3, 11 - 25 * 2, 255)
                generateEnemyStatusUi(rootNode, 25, 242 + 23 * -2, 11 - 25 * 2, 255)
                generateEnemyStatusUi(rootNode, 26, 242 + 23 * -1, 11 - 25 * 2, 255)
                generateEnemyStatusUi(rootNode, 27, 242 + 23 * 0, 11 - 25 * 2, 255)
                generateEnemyStatusUi(rootNode, 28, 242 + 23 * 1, 11 - 25 * 2, 255)
                generateEnemyStatusUi(rootNode, 29, 242 + 23 * 2, 11 - 25 * 2, 255)
                generateEnemyStatusUi(rootNode, 30, 242 + 23 * -7, 11 - 25 * 3, 255)
                generateEnemyStatusUi(rootNode, 31, 242 + 23 * -6, 11 - 25 * 3, 255)
                generateEnemyStatusUi(rootNode, 32, 242 + 23 * -5, 11 - 25 * 3, 255)
                generateEnemyStatusUi(rootNode, 33, 242 + 23 * -4, 11 - 25 * 3, 255)
                generateEnemyStatusUi(rootNode, 34, 242 + 23 * -3, 11 - 25 * 3, 255)
                generateEnemyStatusUi(rootNode, 35, 242 + 23 * -2, 11 - 25 * 3, 255)
                generateEnemyStatusUi(rootNode, 36, 242 + 23 * -1, 11 - 25 * 3, 255)
                generateEnemyStatusUi(rootNode, 37, 242 + 23 * 0, 11 - 25 * 3, 255)
                generateEnemyStatusUi(rootNode, 38, 242 + 23 * 1, 11 - 25 * 3, 255)
                generateEnemyStatusUi(rootNode, 39, 242 + 23 * 2, 11 - 25 * 3, 255)

                var widgetList = this._seekWidgetsByListInfo(rootNode, widgetNamePrefixes);
                var statusEffectIconList = _.map(widgetList, function(widget, index) {
                    return kh.createInstance("StatusEffectIcon").init(widget, index);
                }, this);
                return kh.createInstance("StatusEffectIconHandler").init(statusEffectIconList, 'enemy');
                242 - 7 * 23
            }
        }
    }, 10);

})();