Unblock GameModels3D

2020/6/28 15:39:04

目前为 2021-08-04 提交的版本。查看 最新版本

// ==UserScript==
// @name        Unblock GameModels3D
// @namespace   Violentmonkey Scripts
// @match       *://gamemodels3d.com/*
// @grant       none
// @version     1.7
// @author      WengH
// @run-at      document-idle
// @description 2020/6/28 15:39:04
// ==/UserScript==

(function () {
    if (typeof viewer !== 'undefined') {
        viewer.saveButton.onclick = function () {
            self.saveModel(document.title.split(':')[0].trim())
        }
    }

    if (typeof loginForm !== 'undefined') {
        const _loginForm = loginForm;
        loginForm = function (a, b) {
            console.log(a, b);

            if (a === undefined && b === undefined) {
                _loginForm();
            }

            else if (['visual', 'armor', 'hitbox'].includes(a))
                go(a);

            else if (b !== undefined)
                SetModule(a, b);

            else if (a in VIEW.components)
                CONTROLLER.setComponents(a);

            else if (a in VIEW.characteristics)
                CONTROLLER.setCharacteristics(a);

            else if (a instanceof PointerEvent)
                CONTROLLER.setModule();
        }
    }

    if (typeof ELEMENTS !== 'undefined') {
        let isFirst = true;
        ELEMENTS.openModalDialog = function (params) {
            console.log(params)
            if (params.id === "LoginDialog" && isFirst) {
                isFirst = false;
                return;
            }
            params.type = "modaldialog";
            ELEMENTS.open(params);
        }
    }

    function fixModules() {
        document.querySelectorAll('.button.unit-item').forEach(x => {
            x.onclick = CONTROLLER.setModule;
            x.addEventListener('click', fixModules);
        });
    }

    fixModules();
})();