nike / Kamihime Project R - Compact drops window

// ==UserScript==
// @name         Kamihime Project R - Compact drops window
// @description  Instead of scroll, fit all drops inside window by zooming out if needed
// @license      MIT
// @updateURL    https://openuserjs.org/meta/nike/Kamihime_Project_R_-_Compact_drops_window.meta.js
// @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.pc && kh.pc.quest && kh.pc.quest.q_result && kh.pc.quest.q_result.Methods && kh.pc.quest.q_result.Methods._initSubPage) {
            clearInterval(interval);
            kh.pc.quest.q_result.Methods._initSubPage = function(e, n) {
                var count
                /*if (n.length <= 8) {
                    count = 4
                } else */
                if (n.length <= 15) {
                    count = 5
                } else if (n.length <= 18) {
                    count = 6
                } else if (n.length <= 28) {
                    count = 7
                } else if (n.length <= 40) {
                    count = 8
                } else if (n.length <= 45) {
                    count = 9
                } else if (n.length <= 60) {
                    count = 10
                } else if (n.length <= 66) {
                    count = 11
                } else if (n.length <= 84) {
                    count = 12
                } else if (n.length <= 104) {
                    count = 13
                } else if (n.length <= 112) {
                    count = 14
                } else if (n.length <= 135) {
                    count = 15
                } else if (n.length <= 144) {
                    count = 16
                } else if (n.length <= 170) {
                    count = 17
                } else if (n.length <= 198) {
                    count = 18
                } else if (n.length <= 209) {
                    count = 19
                } else if (n.length <= 240) {
                    count = 20
                } else {
                    count = 21
                }

                var scale = 5.0 / count

                var a = .53 * scale,
                    i = count,
                    s = cc.size(82 * scale, 83 * scale),
                    o = cc.p(5.5, 5),
                    u = e.getContentSize().width,
                    l = new ccui.Widget;
                l.setName("top_padding"),
                    l.setContentSize(u, o.y),
                    e.addChild(l),
                    _.each(n, function(t, n) {
                        var c = new ccui.Widget;
                        c.setName("corecard_ui"),
                            c.setAnchorPoint(0, 0),
                            c.setContentSize(150, 150),
                            c.setScale(a, a);
                        var h = (Math.floor(n / i),
                            n % i);
                        0 == h && (l = new ccui.Widget,
                                l.setName("list_row"),
                                l.setContentSize(u, s.height),
                                l.setAnchorPoint(0, 0),
                                e.addChild(l)),
                            c.setPosition(o.x + s.width * h, 0),
                            l.addChild(c);
                        var d = c.seekWidgetByName(this.CORECARD_WIDGET);
                        c.setVisible(!0),
                            d.setVisible(!0);
                        var p = this["_create" + _.capitalize(t.treasure_type) + "CorecardHandler"](d, t);
                        d.addChild(p.uiNode),
                            this["_fill" + _.capitalize(t.treasure_type) + "CorecardHandler"](p, t),
                            this["_add" + _.capitalize(t.treasure_type) + "CorecardTouchEvent"](p, t)
                    }, this),
                    e.setVisible(!0)
            }
        }
    }, 10);

})();