TORN Quick Items → Hardcoded E (works with #quickItems)

Replace Can-of labels in Quick Items with fixed Energy values.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το 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         TORN Quick Items → Hardcoded E (works with #quickItems)
// @namespace    tvdw.torn.quickitems.energy.static
// @version      0.4
// @description  Replace Can-of labels in Quick Items with fixed Energy values.
// @match        https://www.torn.com/item.php*
// @match        https://www.torn.com/*item.php*
// @run-at       document-idle
// @grant        none
// @license MIT

// ==/UserScript==

(function () {
  'use strict';

  // Edit if your E values differ
  const E = Object.freeze({
    'can of crocozade': 23,
    'can of damp valley': 15,
    'can of goose juice': 8,
    'can of munster': 30,
    'can of red cow': 38,
    'can of santa shooters': 30,
    'can of rockstar rudolph': 30,
  });

  const norm = s => s.replace(/\s+/g, ' ').trim().toLowerCase();

  function rewriteQuickItems() {
    const items = document.querySelectorAll('#quickItems .inner-content .item');
    if (!items.length) return;

    items.forEach(item => {
      const labelEl = item.querySelector('.text');
      if (!labelEl) return;

      const name = norm(labelEl.textContent || '');
      const e = E[name];
      if (e != null) {
        labelEl.textContent = `${e}E`;
        item.setAttribute('title', `${e}E`);
      }
    });
  }

  // Run once visible, then keep in sync with SPA changes
  function init() {
    rewriteQuickItems();

    const qi = document.querySelector('#quickItems');
    const root = qi || document.body;
    const mo = new MutationObserver(rewriteQuickItems);
    mo.observe(root, { childList: true, subtree: true });
  }

  if (document.readyState === 'loading') {
    document.addEventListener('DOMContentLoaded', init);
  } else {
    init();
  }
})();