steamutils 1.2.85 → 1.2.86

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 +17 -20
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -5486,8 +5486,8 @@ class SteamUser {
5486
5486
  if (!result) return
5487
5487
 
5488
5488
  const descriptions = result.descriptions
5489
- const $ = cheerio.load(result.html?.replaceAll(/[\t\n\r]/gi, '')
5490
- ?.trim() || '')
5489
+ const html = result.html?.replaceAll(/[\t\n\r]/gi, '')?.trim() || ''
5490
+ const $ = cheerio.load(html)
5491
5491
 
5492
5492
  const tradehistory = []
5493
5493
  $('.tradehistoryrow').each(function () {
@@ -5589,30 +5589,22 @@ class SteamUser {
5589
5589
  const items_plusminus = tradehistory_items_el.find('.tradehistory_items_plusminus').text().trim()
5590
5590
  tradehistory_items_el.find('.tradehistory_items_group > .history_item').each(function () {
5591
5591
  const itemEl = $(this)
5592
- const text = itemEl.text().trim()//You did not receive any items in this trade.
5592
+ const text = plainText(itemEl.text())//You did not receive any items in this trade.
5593
5593
  const appID = itemEl.attr('data-appid')
5594
5594
  const classid = itemEl.attr('data-classid')
5595
5595
  const instanceid = itemEl.attr('data-instanceid')
5596
5596
  const contextid = itemEl.attr('data-contextid')
5597
5597
 
5598
5598
  if (text !== `You did not receive any items in this trade.`) {
5599
- if (descriptions[appID]) {
5600
- const item = descriptions[appID][classid + '_' + instanceid]
5601
- if (item) {
5602
- tradehistory_items.push({...item, plusminus: items_plusminus})
5603
- } else {
5604
- tradehistory_items.push({
5605
- appID,
5606
- classid,
5607
- instanceid,
5608
- contextid,
5609
- steamId,
5610
- plusminus: items_plusminus
5611
- })
5612
- }
5613
- } else {
5614
- // console.log("No app descriptions", appID);
5615
- }
5599
+ tradehistory_items.push({
5600
+ appID,
5601
+ classid,
5602
+ instanceid,
5603
+ contextid,
5604
+ steamId,
5605
+ plusminus: items_plusminus,
5606
+ ...(descriptions[appID]?.[classid + '_' + instanceid])
5607
+ })
5616
5608
  }
5617
5609
  })
5618
5610
  })
@@ -5633,6 +5625,7 @@ class SteamUser {
5633
5625
  ...(!!tradePeople && {tradePeople})
5634
5626
  })
5635
5627
  } else {
5628
+ fs.writeFileSync('tradehistory_items_empty_' + steamId + "_" + new Date().getTime(), html)
5636
5629
  console.error("tradehistory_items empty", steamId);
5637
5630
  }
5638
5631
  })
@@ -6103,4 +6096,8 @@ class SteamUser {
6103
6096
  }
6104
6097
  }
6105
6098
 
6099
+ function plainText(text) {
6100
+ return text?.replaceAll(/[\t\n\r]/gi, ' ')?.replaceAll(/\s+/g, ' ')?.trim()
6101
+ }
6102
+
6106
6103
  export default SteamUser
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "steamutils",
3
- "version": "1.2.85",
3
+ "version": "1.2.86",
4
4
  "main": "index.js",
5
5
  "dependencies": {
6
6
  "axios": "^1.5.1",