ctr / Kamihime Project R - Accessory enhancement exp/level preview

// ==UserScript==
// @name         Kamihime Project R - Accessory enhancement exp/level preview
// @description  Adds exp/level gain to accessory enhancement preview
// @license      MIT
// @match        https://cf.r.kamihimeproject.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.acce && kh.acce.view && kh.acce.view.AcceListEnhCheckPopup) {
            clearInterval(interval);

            kh.acce.view.AcceListEnhCheckPopup.prototype._setEnhanceInfo = function() {
        		var e = this._result.gained_exp.toString();
        		var c = '<p class="text_common_left"><span class="white">' + e + "</span></p>"
        
                var lvl_to_exp = [
                    0, 0, 10, 25, 45, 70, 100, 135, 175, 220,
                    270, 325, 385, 450, 520, 595, 675, 760, 850, 945,
                    1045, 1165, 1305, 1465, 1645, 1845, 2065, 2305, 2565, 2845,
        			3145, 3465, 3805, 4165, 4545, 4945, 5365, 5805, 6265, 6745, 
        			7245, 7765, 8305, 8865, 9445, 10045, 10665, 11305, 11965, 12645,
        			13345 									
                ];
        
                var beforeLvl = this._khAccessoryModel._accessory.level;
        		var beforeExp = lvl_to_exp[beforeLvl] + this._khAccessoryModel._accessory.exp;
        		var afterExp = beforeExp + this._result.gained_exp;
        		var afterLvl = lvl_to_exp.filter(t => t <= afterExp).length - 1;
        		if (this._khAccessoryModel._accessory.rare == "SSR") afterLvl = Math.min(afterLvl, 50);
        		if (this._khAccessoryModel._accessory.rare == "SR") afterLvl = Math.min(afterLvl, 40);
        		if (this._khAccessoryModel._accessory.rare == "R") afterLvl = Math.min(afterLvl, 30);
        		if (this._khAccessoryModel._accessory.rare == "N") afterLvl = Math.min(afterLvl, 20);
        
        		var s = '<p class="text_common_left"><span class="white">' + beforeLvl + " -> " + afterLvl + "</span></p>"
        		var i = {};
        		i[this.UI_NODE_NAMES.gainedExp] = c,
        		i[this.UI_NODE_NAMES.greatSuccessPercent] = s,
        		this._getNodeByName("success_rate_label").setText("Lvl change: ");
        		this._node.setHtmlStrings(i, kh.GameConfig.POPUP_CSS)
            }

        }
    }, 10);

})();