DH3 Named Presets

Name your combat presets for easy identification in combat.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         DH3 Named Presets
// @namespace    com.anwinity.dh3
// @version      1.0.0
// @description  Name your combat presets for easy identification in combat.
// @author       Anwinity
// @match        dh3.diamondhunt.co
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    const NamedPresets = {
        init: function() {
            window.savePresetName = function(color) {
                console.log(color);
                let key = `dh3.anwinity.presetName.${color}`;
                let value = $(`#preset-${color}-name`).val() || "";
                localStorage.setItem(key, value);
                $(`span#combat-preset-name-${color}`).text(value);
            };

            // remove normal stuff
            $(".fighting-screen-combat-area").empty();
            // add our stuff
            $(".fighting-screen-combat-area").append(`
             <div onclick="sendBytes('USE_PRESET=1')" style="text-align: left">
               <img src="images/combatPresetsRed.png" class="img-30" style="display: inline-block">
               <span style="color: white">1. <span id="combat-preset-name-red"></span></span>
             </div>
             <div onclick="sendBytes('USE_PRESET=2')" style="text-align: left">
               <img src="images/combatPresetsGreen.png" class="img-30" style="display: inline-block">
               <span style="color: white">2. <span id="combat-preset-name-green"></span></span>
             </div>
             <div onclick="sendBytes('USE_PRESET=3')" style="text-align: left">
               <img src="images/combatPresetsBlue.png" class="img-30" style="display: inline-block">
               <span style="color: white">3. <span id="combat-preset-name-blue"></span></span>
             </div>
             <div onclick="sendBytes('USE_PRESET=4')" style="text-align: left">
               <img src="images/combatPresetsYellow.png" class="img-30" style="display: inline-block">
               <span style="color: white">4. <span id="combat-preset-name-yellow"></span></span>
             </div>
             <div onclick="sendBytes('USE_PRESET=5')" style="text-align: left">
               <img src="images/combatPresetsPurple.png" class="img-30" style="display: inline-block">
               <span style="color: white">5. <span id="combat-preset-name-purple"></span></span>
             </div>
            `);

            for(let i = 1; i <= 5; i++) {
                let color = {1: "red", 2: "green", 3: "blue", 4: "yellow", 5: "purple"}[i];
                let el = $("#dialogue-combatPresets tbody tr:nth-child("+i+")");
                el.append(`
                  <td>
                    NAME
                    <br />
                    <input id="preset-${color}-name" name="preset-${color}-name" type="text" style="text-align: center">
                    <button type="button" onclick="savePresetName('${color}')" style="margin-top: 0.25em">Save Name</button>
                  </td>
                `);
                let key = "dh3.anwinity.presetName."+color;
                let value = localStorage.getItem(key);
                if(value) {
                    $(`#preset-${color}-name`).val(value);
                    $(`span#combat-preset-name-${color}`).text(value);
                }
            }
        }
    };
    $(function() {
        NamedPresets.init();
    });
})();