From 2c9c12daa245c64b69497da37cb1f18f3c978860 Mon Sep 17 00:00:00 2001 From: Andrii Lavrenko Date: Mon, 7 Oct 2024 21:35:11 +0300 Subject: [PATCH 1/3] Items stack listing --- code.user.js | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/code.user.js b/code.user.js index 0e65810..8723cac 100644 --- a/code.user.js +++ b/code.user.js @@ -508,7 +508,7 @@ appid: item.appid, contextid: item.contextid, assetid: item.assetid || item.id, - amount: 1, + amount: item.amount, price: price }, responseType: 'json' @@ -1294,6 +1294,14 @@ } } + function getAmountString(amount) { + if (amount == 1) { + return ''; + } + + return ` [x${amount}]`; + } + const sellQueue = async.queue( (task, next) => { market.sellItem( @@ -1313,11 +1321,11 @@ const callback = () => setTimeout(() => next(), getRandomInt(1000, 1500)); if (success) { - logDOM(`${padLeft} - ${itemName} listed for ${formatPrice(market.getPriceIncludingFees(task.sellPrice))}, you will receive ${formatPrice(task.sellPrice)}.`); + logDOM(`${padLeft} - ${itemName}${getAmountString(task.item.amount)} listed for ${formatPrice(market.getPriceIncludingFees(task.sellPrice) * task.item.amount)}, you will receive ${formatPrice(task.sellPrice * task.item.amount)}.`); $(`#${task.item.appid}_${task.item.contextid}_${itemId}`).css('background', COLOR_SUCCESS); - totalPriceWithoutFeesOnMarket += task.sellPrice; - totalPriceWithFeesOnMarket += market.getPriceIncludingFees(task.sellPrice); + totalPriceWithoutFeesOnMarket += task.sellPrice * task.item.amount; + totalPriceWithFeesOnMarket += market.getPriceIncludingFees(task.sellPrice) * task.item.amount; updateTotals(); callback() @@ -3048,17 +3056,19 @@ let totalPriceBuyer = 0; let totalPriceSeller = 0; + let totalAmount = 0; // Add the listings to the queue to be checked for the price. for (let i = 0; i < marketLists.length; i++) { for (let j = 0; j < marketLists[i].items.length; j++) { const listingid = replaceNonNumbers(marketLists[i].items[j].values().market_listing_item_name); const assetInfo = getAssetInfoFromListingId(listingid); + totalAmount += assetInfo.amount if (!isNaN(assetInfo.priceBuyer)) { - totalPriceBuyer += assetInfo.priceBuyer; + totalPriceBuyer += assetInfo.priceBuyer * assetInfo.amount; } if (!isNaN(assetInfo.priceSeller)) { - totalPriceSeller += assetInfo.priceSeller; + totalPriceSeller += assetInfo.priceSeller * assetInfo.amount; } marketListingsQueue.push({ @@ -3071,7 +3081,9 @@ } } - $('#my_market_selllistings_number').append(`, ${formatPrice(totalPriceBuyer)} ➤ ${formatPrice(totalPriceSeller)}`); + $('#my_market_selllistings_number') + .append(` [${totalAmount}]`) + .append(`, ${formatPrice(totalPriceBuyer)} ➤ ${formatPrice(totalPriceSeller)}`); } @@ -3094,10 +3106,12 @@ const appid = replaceNonNumbers(itemIds[2]); const contextid = replaceNonNumbers(itemIds[3]); const assetid = replaceNonNumbers(itemIds[4]); + const amount = Number(unsafeWindow.g_rgAssets[appid][contextid][assetid].amount); return { appid, contextid, assetid, + amount, priceBuyer, priceSeller }; From 805469b2be830e096d7feb8c5b3cf041577303fc Mon Sep 17 00:00:00 2001 From: Andrii Lavrenko Date: Wed, 18 Dec 2024 20:43:32 +0200 Subject: [PATCH 2/3] fix style --- code.user.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/code.user.js b/code.user.js index 8723cac..dd6693b 100644 --- a/code.user.js +++ b/code.user.js @@ -3081,9 +3081,8 @@ } } - $('#my_market_selllistings_number') - .append(` [${totalAmount}]`) - .append(`, ${formatPrice(totalPriceBuyer)} ➤ ${formatPrice(totalPriceSeller)}`); + $('#my_market_selllistings_number').append(` [${totalAmount}]`) + .append(`, ${formatPrice(totalPriceBuyer)} ➤ ${formatPrice(totalPriceSeller)}`); } From 494a094828dd0a1efc1fd0812498a038d268de17 Mon Sep 17 00:00:00 2001 From: Andrii Lavrenko Date: Thu, 19 Dec 2024 20:36:32 +0200 Subject: [PATCH 3/3] change logDOM string --- code.user.js | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/code.user.js b/code.user.js index dd6693b..d680a76 100644 --- a/code.user.js +++ b/code.user.js @@ -1294,14 +1294,6 @@ } } - function getAmountString(amount) { - if (amount == 1) { - return ''; - } - - return ` [x${amount}]`; - } - const sellQueue = async.queue( (task, next) => { market.sellItem( @@ -1321,7 +1313,8 @@ const callback = () => setTimeout(() => next(), getRandomInt(1000, 1500)); if (success) { - logDOM(`${padLeft} - ${itemName}${getAmountString(task.item.amount)} listed for ${formatPrice(market.getPriceIncludingFees(task.sellPrice) * task.item.amount)}, you will receive ${formatPrice(task.sellPrice * task.item.amount)}.`); + const amount = task.item.amount == 1 ? '' : `${task.item.amount}x `; + logDOM(`${padLeft} - ${amount}${itemName} listed for ${formatPrice(market.getPriceIncludingFees(task.sellPrice) * task.item.amount)}, you will receive ${formatPrice(task.sellPrice * task.item.amount)}.`); $(`#${task.item.appid}_${task.item.contextid}_${itemId}`).css('background', COLOR_SUCCESS); totalPriceWithoutFeesOnMarket += task.sellPrice * task.item.amount;