WoD Skill Config Insertion

Make it easier to insert actions in skill config.

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         WoD Skill Config Insertion
// @namespace    https://www.wannaexpresso.com
// @version      0.3
// @description  Make it easier to insert actions in skill config.
// @author       DotIN13
// @include      https://*.wannaexpresso.com/wod/spiel/hero/skillconf*
// @include      http*://*.world-of-dungeons.*/wod/spiel/hero/skillconf*
// @grant        none
// ==/UserScript==

WodUiActionList.prototype.insertAction = function(action, index) {
    this.list.insertItem(new WodUiActionListItem(action), index);
};

(function () {
    'use strict';

    // Frontend button
    var insertButton = document.createElement("div");
    insertButton.innerHTML = "插入";

    // Add insertion button to both preroundAction and roundAction lists
    ["preroundActionList", "roundActionList"].forEach(el => {
        var _this = THE_ORDERS.dungeon.level[el];

        // Add a text button using native JavaScript to distinguish from the existing copy button
        var insertButton = document.createElement("button");
        insertButton.innerHTML = "插";
        insertButton.setAttribute("style", "color: white; background-color: #191919; width: 24px; height: 24px; padding: 0; text-align: center; font-weight: bold;");
        insertButton.addEventListener("click", function(e) {
            e.preventDefault();
            var src = _this.getSelectedAction();

            if (typeof src != undefined) {
                var dst = new WodAction();

                dst.copyFrom(src);
                _this.insertAction(dst, _this.list.getSelectedIndex());
                _this.rebuildModel();
                _this.list.setSelectedIndex( _this.list.getSelectedIndex()+1 );
            }
        });

        _this.list.buttonTd.element.appendChild(insertButton);

        /*_this.list.addButton(new WodUiImage('button-copy.png', 24, 24, "插入"), function() {
            var src = _this.getSelectedAction();

            if (typeof src != undefined) {
                var dst = new WodAction();

                dst.copyFrom(src);
                _this.insertAction(dst, _this.list.getSelectedIndex());
                _this.rebuildModel();
                _this.list.setSelectedIndex( _this.list.getSelectedIndex()+1 );
            }
        })*/

        // Make buttons sticky
        var buttons = _this.list.buttonTd.element;
        var stickyButtons = document.createElement("div");
        while (buttons.childNodes.length) {
            stickyButtons.appendChild(buttons.firstChild);
        }
        buttons.appendChild(stickyButtons);
        stickyButtons.setAttribute("style", "position: sticky; top: 0;");
        _this.list.buttonTd = stickyButtons;

        // Make modBox sticky
        _this.modBox.element.setAttribute("style", "width: 300px; padding-bottom: 10px; float: right; position: sticky; top: 0;");
    })
})();