Item Stats Sort

description

  1. // ==UserScript==
  2. // @name Item Stats Sort
  3. // @namespace namespace
  4. // @version 0.1
  5. // @description description
  6. // @author tos
  7. // @match *.torn.com/bazaar.php*
  8. // @match *.torn.com/displaycase.php*
  9. // @match *.torn.com/item.php*
  10. // @grant GM_addStyle
  11. // ==/UserScript==
  12.  
  13. GM_addStyle(`
  14. #x_item_stats {
  15. background-color: #c13c3c;
  16. color: #eaeaea;
  17. cursor: pointer;
  18. padding: 1em;
  19. position: fixed;
  20. right: 0;
  21. }
  22. `)
  23.  
  24. const item_stats = async () => {
  25. const category_wrap = document.querySelector('.category-wrap')
  26. let cat_index = 0
  27. category_wrap.querySelectorAll('UL.items-cont').forEach((UL) => {
  28. console.log(cat_index)
  29. for (const LI of UL.children) {
  30. const name_DIV = LI.querySelector('.name-wrap')
  31. if (name_DIV) {
  32. const item_name = name_DIV.innerText
  33. const acc_icon = LI.querySelector('.bonus-attachment-item-accuracy-bonus')
  34. const dmg_icon = LI.querySelector('.bonus-attachment-item-damage-bonus')
  35. const def_icon = LI.querySelector('.bonus-attachment-item-defence-bonus')
  36. if (acc_icon && dmg_icon) {
  37. const acc = parseFloat(acc_icon.parentElement.innerText)
  38. const dmg = parseFloat(dmg_icon.parentElement.innerText)
  39. LI.querySelector('.bonuses-wrap').children[2].innerHTML = ((dmg * acc)/100).toFixed(2)
  40. }
  41. else if(def_icon) {
  42. const def = parseFloat(def_icon.parentElement.innerText)
  43. }
  44. }
  45. }
  46. cat_index += 1
  47. })
  48. }
  49.  
  50. document.querySelector('div.content').insertAdjacentHTML('beforebegin', `<div id="x_item_stats">Item Stats</div>`)
  51. document.querySelector('#x_item_stats').addEventListener('click', (e) => {
  52. item_stats()
  53. })