Item Stats Sort

description

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

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