NW - inventory names

Prints NeverWinterOnline items in inventory

当前为 2015-03-10 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name NW - inventory names
  3. // @description Prints NeverWinterOnline items in inventory
  4. // @include http://gatewaytest.playneverwinter.com/*
  5. // @include https://gateway.playneverwinter.com/*
  6. // @grant GM_addStyle
  7. // @version 0.0.1.20150310
  8. // @namespace https://greasyfork.org/users/8151
  9. // ==/UserScript==
  10.  
  11.  
  12. function Print_inventory() {
  13. var _bags = unsafeWindow.client.dataModel.model.ent.main.inventory.bags;
  14. var _bagNames = ["1.",
  15. "2.",
  16. "3.",
  17. "4. User bags",
  18. "5. Personal bank",
  19. "6.",
  20. "7.",
  21. "8. Active companions",
  22. "9. Equipment - head",
  23. "10. Equipment- neck",
  24. "11. Equipment - chest",
  25. "12. Equipment - arms",
  26. "13. Equipment - belt",
  27. "14. Equipment - boots",
  28. "15. Equipment - weapon & off-hand",
  29. "16. Equipment - shirt",
  30. "17. Equipment - pants",
  31. "18. Equipment - rings",
  32. "19. Proffesion assets",
  33. "20. Proffesion resources",
  34. "21. Other currencies",
  35. "22. Idle companions",
  36. "23. Fashion - head",
  37. "24.",
  38. "25. Fashion - shirt",
  39. "26. Fashion - pants",
  40. "27. Active mount",
  41. "28. Active slots",
  42. "29. Primary artifact",
  43. "30. Secondary artifacts",
  44. "31.",
  45. "32.",
  46. "33.",
  47. "34.",
  48. "35.",
  49. "36."];
  50. var i = 0;
  51. $.each(_bags, function (bi, bag) {
  52. console.log(_bagNames[i++]);
  53. bag.slots.forEach(function (slot) {
  54. if (slot) console.log(slot.name + ": x" + slot.count);
  55. });
  56. });
  57. }
  58. /*--- Create a button in a container div. It will be styled and
  59. positioned with CSS.
  60. */
  61.  
  62. var zNode = document.createElement ('div');
  63. zNode.innerHTML = '<button id="myButtonInventory" type="button">'
  64. + 'Don\'t click me! Okay, login first and then... click</button>'
  65. ;
  66. zNode.setAttribute ('id', 'myContainerInventory');
  67. document.body.appendChild (zNode);
  68.  
  69. //--- Activate the newly added button.
  70. document.getElementById ("myButtonInventory").addEventListener (
  71. "click", ButtonClickAction, false
  72. );
  73.  
  74. function ButtonClickAction (zEvent) {
  75. /*--- For our dummy action, we'll just add a line of text to the top
  76. of the screen.
  77. *///onclick();
  78. Print_inventory();
  79. var zNode = document.createElement ('p');
  80. zNode.innerHTML = 'The button was clicked. Look console log';
  81. document.getElementById ("myContainerInventory").replaceChild (zNode, zNode);
  82. }
  83.  
  84. //--- Style our newly added elements using CSS.
  85. GM_addStyle ( multilineStr ( function () {/*!
  86. #myContainerInventory {
  87. position: absolute;
  88. top: 70px;
  89. left: 0;
  90. font-size: 20px;
  91. background: yellow;
  92. border: 3px outset black;
  93. margin: 5px;
  94. opacity: 0.9;
  95. z-index: 222;
  96. padding: 5px 20px;
  97. }
  98. #myButtonInventory {
  99. cursor: pointer;
  100. }
  101. #myContainerInventory p {
  102. color: red;
  103. background: white;
  104. }
  105. */} ) );
  106.  
  107. function multilineStr (dummyFunc) {
  108. var str = dummyFunc.toString ();
  109. str = str.replace (/^[^\/]+\/\*!?/, '') // Strip function () { /*!
  110. .replace (/\s*\*\/\s*\}\s*$/, '') // Strip */ }
  111. .replace (/\/\/.+$/gm, '') // Double-slash comments wreck CSS. Strip them.
  112. ;
  113. return str;
  114. }