steamutils 1.3.73 → 1.3.74

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +48 -31
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -6048,7 +6048,7 @@ export default class SteamUser {
6048
6048
  }
6049
6049
  }
6050
6050
 
6051
- async getMyMarketHistory({ start = 0, count = 10 } = {}) {
6051
+ async getMyMarketHistory({ start = 0, count = 100 } = {}) {
6052
6052
  const result = await this._httpRequestAjax({
6053
6053
  url: `market/myhistory/render/?query=&start=${start}&count=${count}`,
6054
6054
  });
@@ -6057,40 +6057,57 @@ export default class SteamUser {
6057
6057
  }
6058
6058
  const data = result?.data;
6059
6059
  if (data?.success === true) {
6060
- const $ = cheerio.load(data.results_html);
6061
- const list = [];
6062
- $(".market_listing_row").each(function () {
6063
- const $1 = $(this);
6064
- const id = $1.attr("id");
6065
- const listingid = id.substringBetweenOrNull("history_row_", "_");
6066
- if (!listingid) {
6060
+ const hovers = StringUtils.cleanSpace(data.hovers);
6061
+ const assetById = data.assets?.[730]?.[2] || {};
6062
+ const assestByListingId = {};
6063
+ hovers.split("CreateItemHoverFromContainer").forEach(function (text) {
6064
+ text = text.trim();
6065
+ if (!text.startsWith("(")) {
6067
6066
  return;
6068
6067
  }
6069
- const gainOrLoss = StringUtils.cleanSpace($1.find(".market_listing_gainorloss").text());
6070
- const image = $1.find(`.market_listing_item_img`).attr("src");
6071
- const price = parseInt($1.find(`.market_table_value .market_listing_price`).text().replaceAll(`(`, "").replaceAll(`)`, "").replaceAll(`₫`, "").replaceAll(`.`, "").replaceAll(`,`, "").trim()) || "";
6072
- const item_name = $1.find(".market_listing_item_name").text();
6073
- const game_name = $1.find(".market_listing_game_name").text();
6074
-
6075
- const listedOn = StringUtils.cleanSpace($1.find(".market_listing_listed_date + .market_listing_listed_date").text().replaceAll(`Listed:`, ""));
6076
- const actedOn = StringUtils.cleanSpace($1.find(".market_listing_whoactedwith + .market_listing_listed_date").text().replaceAll(`Listed:`, ""));
6068
+ const texts = text.split(",");
6069
+ const listingId = texts[1]?.substringBetweenOrNull("history_row_", "_");
6070
+ const assestId = texts[4]?.trim()?.removeSurrounding("'");
6071
+ if (!listingId || !assestId || !assetById[assestId]) {
6072
+ return;
6073
+ }
6074
+ assestByListingId[listingId] = assestId;
6075
+ });
6077
6076
 
6078
- const status = StringUtils.cleanSpace($1.find(".market_listing_whoactedwith").text());
6077
+ const $ = cheerio.load(data.results_html);
6078
+ const list = [...$(".market_listing_row")]
6079
+ .map(function (el) {
6080
+ el = $(el);
6081
+ const id = el.attr("id");
6082
+ const listingid = id.substringBetweenOrNull("history_row_", "_");
6083
+ if (!listingid) {
6084
+ return;
6085
+ }
6086
+ const gainOrLoss = StringUtils.cleanSpace(el.find(".market_listing_gainorloss").text());
6087
+ const image = el.find(`.market_listing_item_img`).attr("src");
6088
+ const price = parseInt(el.find(`.market_table_value .market_listing_price`).text().replaceAll(`(`, "").replaceAll(`)`, "").replaceAll(`₫`, "").replaceAll(`.`, "").replaceAll(`,`, "").trim()) || "";
6089
+ const item_name = el.find(".market_listing_item_name").text();
6090
+ const game_name = el.find(".market_listing_game_name").text();
6091
+ const listedOn = StringUtils.cleanSpace(el.find(".market_listing_listed_date + .market_listing_listed_date").text().replaceAll(`Listed:`, ""));
6092
+ const actedOn = StringUtils.cleanSpace(el.find(".market_listing_whoactedwith + .market_listing_listed_date").text().replaceAll(`Listed:`, ""));
6093
+ const status = StringUtils.cleanSpace(el.find(".market_listing_whoactedwith").text());
6079
6094
 
6080
- list.push({
6081
- id,
6082
- listingid,
6083
- price,
6084
- item_name,
6085
- game_name,
6086
- listedOn,
6087
- actedOn,
6088
- image,
6089
- gainOrLoss,
6090
- status,
6091
- });
6092
- });
6093
- const assets = Object.values(data.assets["730"]?.["2"] || {});
6095
+ return {
6096
+ id,
6097
+ listingid,
6098
+ price,
6099
+ item_name,
6100
+ game_name,
6101
+ listedOn,
6102
+ actedOn,
6103
+ image,
6104
+ gainOrLoss,
6105
+ status,
6106
+ ...(!!assestByListingId[listingid] && { assetId: assestByListingId[listingid] }),
6107
+ };
6108
+ })
6109
+ .filter(Boolean);
6110
+ const assets = Object.values(assetById);
6094
6111
  return { ...data, list, assets, success: true };
6095
6112
  }
6096
6113
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "steamutils",
3
- "version": "1.3.73",
3
+ "version": "1.3.74",
4
4
  "main": "index.js",
5
5
  "dependencies": {
6
6
  "alpha-common-utils": "^1.0.6",