TW Big Inventory

This script, just make inventory biggest!

  1. // ==UserScript==
  2. // @name TW Big Inventory
  3. // @namespace TW_Jack
  4. // @author Jackson
  5. // @description This script, just make inventory biggest!
  6. // @include https://*.the-west.*/game.php*
  7. // @version 1.8
  8. // @website https://liberdesign.eu
  9. // @icon https://www.liberdesign.eu/wp-content/uploads/west/biginv.ico
  10. // @license Free
  11. // @grant none
  12. // ==/UserScript==
  13. (function(fn) {
  14. var script = document.createElement('script');
  15. script.setAttribute('type', 'application/javascript');
  16. script.textContent = '(' + fn + ')();';
  17. document.body.appendChild(script);
  18. document.body.removeChild(script);
  19. })(function() {
  20. var bigInventor = {
  21. version: '1.7',
  22. author: 'Jackson',
  23. minGame: '2.03',
  24. maxGame: Game.version.toString(),
  25. website: 'https://greasyfork.org/ru/scripts/31626-tw-big-inventory',
  26. updateUrl: 'https://raw.githubusercontent.com/Vartanov/Tre-Pulsanti/master/agg.js',
  27. images: {}
  28. };
  29. Inventory.uid = "inventory";
  30. Inventory.size = 66;
  31. Inventory.sizeSearch = 55;
  32. Inventory.sizeCustom = 55;
  33. Inventory.width = 608;
  34. Inventory.availableCategories = ['new', 'belt', 'body', 'foot', 'head', 'neck', 'pants', 'animal', 'right_arm', 'left_arm', 'yield', 'upgradeable'];
  35. Inventory.defaultCategory = 'new';
  36. Inventory.latestSize = 66;
  37. Inventory.context = null;
  38. $("<link href='https://www.liberdesign.eu/wp-content/uploads/west/inv.css' rel='stylesheet' type='text/css'>").appendTo("head");
  39. var langs;
  40. langs = {
  41. it_IT: {
  42. lang_select: 'Lingua selezionata',
  43. language: 'Italiano',
  44. ApiGui: 'Questo script aumenta lo spazio nell inventario.',
  45. contact: 'Contatti',
  46. title: 'Big Inventory',
  47. update: 'Aggiorna',
  48. updateAvailable: 'Nuova versione dello script disponibile',
  49. name: 'Big Inventory',
  50. msgme: 'Mandami un messaggio in gioco',
  51. mailme: 'Mandami una mail',
  52. Doppioni : {
  53. tip : 'Mostra solo duplicati',
  54. upgradeable:'Migliorabile',
  55. noset : 'Non appartengono ai set',
  56. sellable : 'Vendibile',
  57. auctionable : 'Vendibile all asta',
  58. tipuse : 'Mostra solo consumabili',
  59. tiprecipe : 'Mostra solo ricette',
  60. tipsets : 'Mostra solo i set',
  61. tutteOpz : 'Tutto',
  62. }
  63. },
  64. en_US: {
  65. lang_select: 'Language selected',
  66. language: 'English',
  67. ApiGui: 'This script increases space in the inventory.',
  68. contact: 'Contact',
  69. title: 'Big Inventory',
  70. update: 'Update',
  71. updateAvailable: 'New version of the script are avialable.',
  72. name: 'Big Inventory',
  73. msgme: 'Message me in game',
  74. mailme: 'Send me a mail',
  75. Doppioni : {
  76. tip : 'Show only duplicates',
  77. upgradeable:'Upgradeables',
  78. noset : 'Without set items',
  79. sellable : 'Sellables',
  80. auctionable : 'Auctionables',
  81. tipuse : 'Show only useables',
  82. tiprecipe : 'Show only recipes',
  83. tipsets : 'Show only set items',
  84. tutteOpz : 'All',
  85. }
  86. },
  87. ru_RU: {
  88. lang_select: 'Выбранный язык',
  89. language: 'Русский',
  90. ApiGui: 'Этот скрипт, увеличивает пространство инвентаря!',
  91. contact: 'Контакты',
  92. title: 'Большой инвентарь',
  93. name: 'Большой инвентарь',
  94. update: 'Обновление',
  95. updateAvailable: 'Доступно обновление скрипта.',
  96. msgme: 'Напиши мне в игре',
  97. mailme: 'Почтовый ящик',
  98. Doppioni : {
  99. tip : 'Показывать только дубликаты',
  100. upgradeable:'Можно улучшить',
  101. noset : 'Не подлежащие наборам',
  102. sellable : 'Продаваемые',
  103. auctionable : 'Продаваемые на аукционе',
  104. tipuse : 'Показать только используемые',
  105. tiprecipe : 'Показать только рецепты',
  106. tipsets : 'Показывать только наборы',
  107. tutteOpz : 'Все',
  108. }
  109. },
  110. de_DE: {
  111. lang_select: 'Sprache',
  112. language: 'Deutsch',
  113. ApiGui: 'Dieses Skript vergrössert dein Inventar.',
  114. contact: 'Kontakt',
  115. title: 'Big Inventory',
  116. update: 'Update',
  117. updateAvailable: 'Für das Script ist eine neue Version erhältlich.',
  118. name: 'Big Inventory',
  119. msgme: 'Ingame Nachricht (Nur the-west.it)',
  120. mailme: 'Schicke mir eine E-Mail',
  121. Doppioni: {
  122. tip : 'Duplikate',
  123. upgradeable: 'Veredelbare',
  124. noset: 'Ohne Set-Items',
  125. sellable: 'Verkaufbare',
  126. auctionable: 'Auktionierbare',
  127. tipuse: 'Verbrauchbare',
  128. tiprecipe: 'Rezepte',
  129. tipsets: 'Set-Items',
  130. tutteOpz: 'Alle',
  131. }
  132. },
  133. ro_RO: {
  134. lang_select: 'Limba selectionata',
  135. language: 'Romana',
  136. ApiGui: 'Acest script, mareste spatiul in inventar',
  137. contact: 'Contacte',
  138. title: 'Big Inventory',
  139. name: 'Big Inventory',
  140. update: 'Actualizare',
  141. updateAvailable: 'Disponibila o noua actualizare.',
  142. msgme: 'Trimitemi mesaj in joc',
  143. mailme: 'Trimitemi un mail',
  144. Doppioni : {
  145. tip : 'Afișați numai duplicate',
  146. upgradeable:'Actualizabile',
  147. noset : 'Fără elemente din set',
  148. sellable : 'Sellables',
  149. auctionable : 'Auctionables',
  150. tipuse : 'Afișați numai utilizabile',
  151. tiprecipe : 'Afișați numai ricete',
  152. tipsets : 'Afișați numai seturi',
  153. tutteOpz : 'All',
  154. }
  155. }
  156. };
  157. var MPlang = langs.hasOwnProperty(Game.locale) ? langs[Game.locale] : langs.it_IT;
  158. var bigInventorApi = TheWestApi.register('bigInventor', MPlang.title, bigInventor.minGame, bigInventor.maxGame, bigInventor.author, bigInventor.website);
  159. bigInventorApi.setGui('<br><i>' + MPlang.lang_select + ': </i>' + MPlang.language + '<br><br>' + MPlang.ApiGui + '<br><br><i>' + MPlang.name + ' v' + bigInventor.version +
  160. '</i><br><br>' + MPlang.contact + ':</b><ul style="margin-left:15px;"><li>' + MPlang.msgme + '<a style="margin-left:15px;" href="javascript:void(PlayerProfileWindow.open(542314));">Jackson</a>' + '</li><li>' + MPlang.mailme + '<a style="margin-left:15px;" href="mailto:info@liberstudio.com">info@liberstudio.com</a>' + '</li></ul>');
  161. bigInventor.gui = {};
  162. var ICONE = {
  163. init: function () {
  164. try {
  165. EventHandler.signal("ICONE.init");
  166. var that = this;
  167. var timeout = 0;
  168. this.interval = setInterval(
  169. function () {
  170. var loading = false;
  171. if (isDefined(Character.playerId) && Character.playerId === 0) {
  172. loading = false;
  173. } else if (!isDefined(ItemManager)) {
  174. loading = false;
  175. } else if (isDefined(ItemManager.initialized) && !ItemManager.initialized) {
  176. loading = false;
  177. } else if (isDefined(window.TWDB)) {
  178. if (!window.TWDB.ClothCalc.ready) {
  179. loading = false;
  180. timeout++;
  181. if (timeout > 20) {
  182. ErrorLog.log('Errore, caricamento TWDB non possibile ?');
  183. ICONE.isTWDBHere = true;
  184. loading = true;
  185. }
  186. } else {
  187. ICONE.isTWDBHere = true;
  188. loading = true;
  189. }
  190. } else {
  191.  
  192. loading = true;
  193. }
  194. if (loading) {
  195. clearInterval(that.interval);
  196. if (ICONE.scriptStorage === null) {
  197. ICONE.scriptStorage = new Storage("local", "Storage.");
  198. }
  199. ICONE.ready = true;
  200. EventHandler.signal('ICONE.ready');
  201. ICONE.Inventario.create();
  202. }
  203.  
  204. }, 500);
  205. } catch (e) {
  206.  
  207. ErrorLog.log("Errore inizializzazione", e);
  208. ErrorLog.showLog();
  209. ICONE.ready = false;
  210. }
  211. },
  212. Inventario: {
  213. create: function () {
  214. ICONE.Inventario.attach();
  215. },
  216. attach: function () {
  217. EventHandler.listen("inventory_ready", ICONE.Inventario.addCheckBoxBag, "duplbag");
  218. },
  219. detach: function () {
  220. EventHandler.unlisten("inventory_ready", ICONE.Inventario.addCheckBoxBag, "duplbag");
  221. $('#bagFilterIsCollect', Inventory.DOM).remove();
  222. },
  223. cercaDuplicati: function (filtru) {
  224.  
  225. var searchTxt = "";
  226. var searchVal = $('#inventory_search', Inventory.DOM).val();
  227. if (searchVal.lenght === 0 || Inventory.category != 'set') {
  228. searchVal = ".*";
  229. } else {
  230. searchTxt = (searchVal.lenght === 0) ? "" : " (" + searchVal + ")";
  231. }
  232. var res = Bag.search(searchVal);
  233. $('#inventory_search', Inventory.DOM).val("");
  234. var doppioni = [];
  235. var sell = 0;
  236. $.each(res, function (ind1, item) {
  237. if (item.obj.type != 'yield' && ($.inArray(item.getType(), Inventory.getCategoryTypes(Inventory.category)) > -1 || Inventory.category == 'set' || Inventory.category == 'new')) {
  238. var count = item.getCount();
  239. var weared = Wear.carries(item.obj.item_base_id);
  240. if (weared) {
  241. count += 1;
  242. }
  243. if (count > 1) {
  244. switch (filtru) {
  245. case 'upgradeable':
  246. if (count < 3 || !item.obj.upgradeable) {
  247. item = null;
  248. }
  249. break;
  250. case 'nosets':
  251. if (item.obj.set !== null) {
  252. item = null;
  253. }
  254. break;
  255. case 'sellable':
  256. if (!item.obj.sellable) {
  257. item = null;
  258. }
  259. break;
  260. case 'auctionable':
  261. if (!item.obj.auctionable) {
  262. item = null;
  263. }
  264. break;
  265. default:
  266. break;
  267. }
  268. if (isDefined(item)) {
  269. doppioni.push(item);
  270. sell += (item.getSellPrice()) * (count - 1);
  271. }
  272. }
  273. } else {
  274. }
  275. });
  276. var lastCat = Inventory.category;
  277. Inventory.showSearchResult(doppioni || []);
  278. $('#sumsearch', Inventory.DOM).remove();
  279. },
  280. searchSpeciales: function (what) {
  281. $('#inventory_search', Inventory.DOM).val(what);
  282. var res = Bag.search(what);
  283. Inventory.showSearchResult(res || []);
  284. return res;
  285. },
  286. getDetSearchBox: function () {
  287. if (isDefined(west.storage.ItemSetManager)) {
  288. var selSets = new west.gui.Selectbox();
  289. selSets.setWidth(200);
  290. $(selSets.elContent).css({
  291. "max-height": "270px",
  292. "width": "250px",
  293. "overflow-y": 'auto'
  294. });
  295. ICONE.selAdded = [];
  296. selSets.addItem('all', MPlang.Doppioni.tutteOpz);
  297. selSets.addItem('upgradeable', MPlang.Doppioni.upgradeable);
  298. selSets.addItem('nosets', MPlang.Doppioni.noset);
  299. selSets.addItem('sellable', MPlang.Doppioni.sellable);
  300. selSets.addItem('auctionable', MPlang.Doppioni.auctionable);
  301. selSets.addListener(function (e) {
  302. switch (e) {
  303. case 'all':
  304. $('#inventory_search', Inventory.DOM)
  305. .val("");
  306.  
  307. break;
  308. default:
  309.  
  310. break;
  311. }
  312. ICONE.Inventario.cercaDuplicati(e);
  313.  
  314. return true;
  315. });
  316.  
  317. return selSets;
  318.  
  319. }
  320. // return selSets;
  321. },
  322. getSetNamesBox: function (setsCache) {
  323.  
  324. if (isDefined(west.storage.ItemSetManager)) {
  325.  
  326. var selSets = new west.gui.Selectbox();
  327. selSets.setWidth(200);
  328.  
  329. $(selSets.elContent).css({
  330. "max-height": "270px",
  331. "width": "250px",
  332. "overflow-y": 'auto'
  333. });
  334.  
  335. ICONE.selAdded = [];
  336.  
  337. selSets.addItem('setitems',
  338. MPlang.Doppioni.tutteOpz);
  339.  
  340. $
  341. .each(
  342. setsCache,
  343. function (ind2, item) {
  344.  
  345. var itemsSet = west.storage.ItemSetManager
  346. .get(item.obj.set);
  347. if (!isDefined(ICONE.selAdded[itemsSet.name])) {
  348. ICONE.selAdded[itemsSet.name] = true;
  349. selSets.addItem(
  350. itemsSet.name,
  351. itemsSet.name);
  352. }
  353.  
  354. });
  355.  
  356. selSets.addListener(function (e) {
  357. ICONE.Inventario.searchSpeciales(e);
  358. return true;
  359. });
  360. return selSets;
  361. }
  362. return selSets;
  363. },
  364. addCheckBoxBag: function (div) {
  365. if ($('#bagFilterIsCollect', Inventory.DOM).length === 0) {
  366.  
  367. var setsCache = Bag.search('setitems');
  368.  
  369. setsCache.sort(function (a, b) {
  370. var x = west.storage.ItemSetManager
  371. .get(a.obj.set).name;
  372. var y = west.storage.ItemSetManager
  373. .get(b.obj.set).name;
  374.  
  375. if (typeof x === 'string' && typeof x === 'string') {
  376.  
  377. return x.localeCompare(y);
  378. }
  379. return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  380. });
  381.  
  382. var selBox = ICONE.Inventario.getSetNamesBox(setsCache);
  383. var spanD = $('<div id="bagFilterIsCollect" ' + 'style="display: flex; position: inherit; float: right;"/>');
  384. var duplicat = $("<span title='" + MPlang.Doppioni.tip + "' id='inventory_doublons'"
  385. + '" class="filter_inventory filter_dopp hasMousePopup"'
  386. + '" style="cursor: pointer; position: relative; background: url(https://www.liberdesign.eu/wp-content/uploads/west/small.png) no-repeat; background-position: -2px 0;" />'
  387. + "</span>");
  388. duplicat.click(function (e) {
  389. $('#sumsearch').remove();
  390. ICONE.Inventario.getDetSearchBox().show(e);
  391. });
  392. spanD.append(duplicat);
  393. var utilizz = $('<span title="'
  394. + MPlang.Doppioni.tipuse
  395. + '" id="inventory_useables"'
  396. + '" class="filter_inventory filter_utiliz hasMousePopup"'
  397. + '" style="cursor: pointer; position: relative; background: url(https://www.liberdesign.eu/wp-content/uploads/west/small.png) no-repeat; background-position: -45px 0;">'
  398. + "</span>");
  399. utilizz.click(function () {
  400. $('#sumsearch').remove();
  401. ICONE.Inventario.searchSpeciales('useable');
  402. });
  403. spanD.append(utilizz);
  404. var ricetta = $('<span title="'
  405. + MPlang.Doppioni.tiprecipe
  406. + '" id="inventory_recipe"'
  407. + '" class="filter_inventory filter_ricet hasMousePopup"'
  408. + '" style="position: relative; background: url(https://www.liberdesign.eu/wp-content/uploads/west/small.png) no-repeat; cursor: pointer; background-position: -88px 0;" >'
  409. + '</span>');
  410. ricetta.click(function () {
  411. $('#sumsearch').remove();
  412. ICONE.Inventario.searchSpeciales('recipe');
  413. });
  414. spanD.append(ricetta);
  415. var naboru = $('<span title="'
  416. + MPlang.Doppioni.tipsets
  417. + '" id="inventory_sets"'
  418. + '" class="filter_inventory filter_nabor hasMousePopup"'
  419. + '" style="cursor: pointer; position: relative; background: url(https://www.liberdesign.eu/wp-content/uploads/west/small.png) no-repeat; background-position: -131px 0;" >'
  420. + "</span>");
  421. naboru.click(function (e) {
  422. $('#sumsearch').remove();
  423. selBox.show(e);
  424. });
  425. spanD.append(naboru);
  426. $('.search_container').css('left', '35%').css('bottom', '10px');
  427. $('.filters', Inventory.DOM).append(spanD);
  428.  
  429. }
  430.  
  431. }
  432. }
  433. };
  434. bigInventor.gui.init = function () {
  435. bigInventor.gui.makeButton = function (caption, callback) {
  436. return new west.gui.Button(caption, callback);
  437. };
  438. };
  439. bigInventor.Updater = function () {
  440. $.getScript(bigInventor.updateUrl, function () {
  441. if (aggiornaScript.bigInventor != bigInventor.version) {
  442. var updateMessage = new west.gui.Dialog(MPlang.update + ': ' + MPlang.name, '<span>' +
  443. MPlang.updateAvailable + '<br><br><b>v' +
  444. aggiornaScript.bigInventor + ':</b><br>' +
  445. aggiornaScript.bigInventorNew + '</span>', west.gui.Dialog.SYS_WARNING).addButton(MPlang.update, function () {
  446. updateMessage.hide();
  447. location.href = bigInventor.website + '/code.user.js';
  448. }).addButton('cancel').show();
  449. }
  450. });
  451. };
  452. function Storage(type, namespace) {
  453. var object = this;
  454. if (typeof (type) != "string")
  455. type = "session";
  456. switch (type) {
  457. case "local": {
  458. object.storage = localStorage;
  459. }
  460. break;
  461. case "session": {
  462. object.storage = sessionStorage;
  463. }
  464. break;
  465. default: {
  466. object.storage = sessionStorage;
  467. }
  468. break;
  469. }
  470. if (!namespace || (typeof (namespace) != "string" && typeof (namespace) != "number"))
  471. namespace = "ScriptStorage";
  472.  
  473. object.namespace = [ namespace, "." ].join("");
  474.  
  475. object.setItem = function(key, value) {
  476. try {
  477. object.storage.setItem(escape( [ object.namespace,
  478. key ].join("")), JSON.stringify(value));
  479. } catch (e) {
  480. }
  481. };
  482. object.getItem = function(key, defaultValue) {
  483. try {
  484. var value = object.storage.getItem(escape( [
  485. object.namespace, key ].join("")));
  486. if (value)
  487. return eval(value);
  488. else
  489. return defaultValue;
  490. } catch (e) {
  491. return defaultValue;
  492. }
  493. };
  494. object.removeItem = function(key) {
  495. try {
  496. object.storage.removeItem(escape(collection.craftfilterMarket[object.namespace, key].join("")));
  497. } catch (e) {
  498. }
  499. };
  500. object.keys = function() {
  501. var array = [];
  502. var indJack = 0;
  503. do {
  504. try {
  505. var key = unescape(object.storage.key(indJack++));
  506. if (key.indexOf(object.namespace) == 0
  507. && object.storage.getItem(key))
  508. array.push(key
  509. .slice(object.namespace.length));
  510. } catch (e) {
  511. break;
  512. }
  513. } while (true);
  514. return array;
  515. };
  516. }
  517. $(document).ready(function () {
  518. try {
  519. bigInventor.gui.init();
  520. ICONE.init();
  521. setTimeout(bigInventor.Updater, 5000);
  522. } catch (e) {
  523. console.log(e.stack);
  524. }
  525. });
  526. });