steamutils 1.3.72 → 1.3.74

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/index.js +64 -0
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -6048,6 +6048,70 @@ export default class SteamUser {
6048
6048
  }
6049
6049
  }
6050
6050
 
6051
+ async getMyMarketHistory({ start = 0, count = 100 } = {}) {
6052
+ const result = await this._httpRequestAjax({
6053
+ url: `market/myhistory/render/?query=&start=${start}&count=${count}`,
6054
+ });
6055
+ if (result instanceof ResponseError) {
6056
+ return result;
6057
+ }
6058
+ const data = result?.data;
6059
+ if (data?.success === true) {
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("(")) {
6066
+ return;
6067
+ }
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
+ });
6076
+
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());
6094
+
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);
6111
+ return { ...data, list, assets, success: true };
6112
+ }
6113
+ }
6114
+
6051
6115
  async getPlayerReports(token) {
6052
6116
  const param = {
6053
6117
  sessionid: this._sessionId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "steamutils",
3
- "version": "1.3.72",
3
+ "version": "1.3.74",
4
4
  "main": "index.js",
5
5
  "dependencies": {
6
6
  "alpha-common-utils": "^1.0.6",