ECCB

Editeur de Commentaires de Conteneurs en Banque

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name        ECCB
// @namespace   InGame
// @match       https://www.dreadcast.net/Main
// @grant GM_addStyle
// @version     1.2
// @author      Isilin/Pelagia
// @date        26/02/2024
// @description Editeur de Commentaires de Conteneurs en Banque
// @license      http://creativecommons.org/licenses/by-nc-nd/4.0/
// ==/UserScript==

GM_addStyle(`
    #liste_stocks .nom_item {
      top: 28px !important;
    }

    .nm_description_item_named_bank {
      position: absolute;
      top: 45px;
      right: 30px;
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 0.5rem;
      width: 160px;
      max-height: 50px;
    }

    .nm_description_item_named_bank span {
      max-height: 30px;
    }

    .nm_description_item_named_bank .btnTxt {
      min-width: 50px;
      max-width: 50px;
      left: unset !important;
      top: unset !important;
      margin-left: 0 !important;
      margin-top: 0 !important;
    }

    .nm_description_box {
      left: 97px;
      top: 20px;
      inline-size: 350px;
      max-height: 15px;
      overflow: hidden;
    }
`)

// ===== Core =====

function getDescription(index) {
  let jsonData = {}
  const data = localStorage.getItem('descriptionBankBags');
  if (data != null) {
    jsonData = JSON.parse(data);
  }
  return jsonData[index] || '';
}

function setDescription(index, description) {
  console.log(index);
  if (description != null && description.length > 0) {
    let jsonData = {}
    const data = localStorage.getItem('descriptionBankBags');
    if (data != null) {
      jsonData = JSON.parse(data);
    }
    jsonData[index] = description;
    console.log(JSON.stringify(jsonData));
    localStorage.setItem("descriptionBankBags",JSON.stringify(jsonData));
  }
}

// ===== Logic =====

function customDescription(index) {
  var input = prompt('Saisissez la description de votre coffre :', getDescription(index));
  if (input != null) {
    setDescription(index, input);
    $(`#nm_description_text_${index}`).text(input);
  }
}

// ===== UI =====
$(document).ready(function () {
  $(document).ajaxSuccess(function (e, xhr, opt) {
    if (opt.url.includes("Company/Account/View")) {
      for (var i = 1 ; i <= 10 ; ++i) {
        $(`.stock${i}`).append(`<div class="nm_description_item_named_bank" id="nm_edit_description_block_${i}"></div>`);
        $(`.stock${i}`).append(`<div class="nm_description_box" id="nm_description_text_${i}">${getDescription(i)}</div>`);
        $(`#nm_edit_description_block_${i}`).append(`<div class="btnTxt" style="top:19px;left:50%;margin-left:-48px;margin-top:-20px;" id="nm_edit_description_${i}">Editer</div>`);
        $(`#nm_edit_description_${i}`).click({index: i}, (event) => customDescription(event.data.index))
      }
    }
  });
});