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

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

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램을 설치해야 합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==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();
  }
})();