Item Stats Sort

description

Verze ze dne 16. 07. 2019. Zobrazit nejnovější verzi.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         Item Stats Sort
// @namespace    namespace
// @version      0.1
// @description  description
// @author       tos
// @match       *.torn.com/bazaar.php*
// @match       *.torn.com/displaycase.php*
// @match       *.torn.com/item.php*
// @grant        GM_addStyle
// ==/UserScript==

GM_addStyle(`
#x_item_stats {
  background-color: #c13c3c;
  color: #eaeaea;
  cursor: pointer;
  padding: 1em;
  position: fixed;
  right: 0;
}
`)

const item_stats = async () => {
  const category_wrap = document.querySelector('.category-wrap')
  let cat_index = 0
  category_wrap.querySelectorAll('UL.items-cont').forEach((UL) => {
    console.log(cat_index)
    for (const LI of UL.children) {
      const name_DIV = LI.querySelector('.name-wrap')
      if (name_DIV) {
        const item_name = name_DIV.innerText
        const acc_icon = LI.querySelector('.bonus-attachment-item-accuracy-bonus')
        const dmg_icon = LI.querySelector('.bonus-attachment-item-damage-bonus')
        const def_icon = LI.querySelector('.bonus-attachment-item-defence-bonus')
        if (acc_icon && dmg_icon) {
          const acc = parseFloat(acc_icon.parentElement.innerText)
          const dmg = parseFloat(dmg_icon.parentElement.innerText)
          LI.querySelector('.bonuses-wrap').children[2].innerHTML = ((dmg * acc)/100).toFixed(2)
        }
        else if(def_icon) {
          const def = parseFloat(def_icon.parentElement.innerText)
        }
      }
    }
    cat_index += 1
  })
}

document.querySelector('div.content').insertAdjacentHTML('beforebegin', `<div id="x_item_stats">Item Stats</div>`)
document.querySelector('#x_item_stats').addEventListener('click', (e) => {
  item_stats()
})