NW - inventory names

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

当前为 2015-05-15 提交的版本,查看 最新版本

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