NW - inventory names

Prints NeverWinterOnline items in inventory (including content of user bags!)

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

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