steamutils 1.2.85 → 1.2.87
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.
- package/index.js +39 -31
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -5486,12 +5486,11 @@ class SteamUser {
|
|
|
5486
5486
|
if (!result) return
|
|
5487
5487
|
|
|
5488
5488
|
const descriptions = result.descriptions
|
|
5489
|
-
const
|
|
5490
|
-
|
|
5489
|
+
const html = result.html?.replaceAll(/[\t\n\r]/gi, '')?.trim() || ''
|
|
5490
|
+
const $ = cheerio.load(html)
|
|
5491
5491
|
|
|
5492
5492
|
const tradehistory = []
|
|
5493
|
-
|
|
5494
|
-
const tradehistoryrow_el = $(this)
|
|
5493
|
+
for (const tradehistoryrow_el of querySelectorAll($, '.tradehistoryrow')) {
|
|
5495
5494
|
const tradehistory_date_el = tradehistoryrow_el.find('.tradehistory_date')
|
|
5496
5495
|
const tradehistory_timestamp_el = tradehistory_date_el.find('.tradehistory_timestamp')
|
|
5497
5496
|
|
|
@@ -5584,40 +5583,31 @@ class SteamUser {
|
|
|
5584
5583
|
|
|
5585
5584
|
const plusminus = tradehistoryrow_el.find('.tradehistory_items_plusminus').text().trim()//+ -
|
|
5586
5585
|
const tradehistory_items = []
|
|
5587
|
-
|
|
5588
|
-
|
|
5589
|
-
const
|
|
5590
|
-
|
|
5591
|
-
const
|
|
5592
|
-
const text = itemEl.text().trim()//You did not receive any items in this trade.
|
|
5586
|
+
|
|
5587
|
+
for (const tradehistory_items_el of querySelectorAll($, '.tradehistory_items', tradehistoryrow_el)) {
|
|
5588
|
+
const plusminus = tradehistory_items_el.find('.tradehistory_items_plusminus').text().trim()
|
|
5589
|
+
for (const itemEl of querySelectorAll($, '.tradehistory_items_group > .history_item', tradehistory_items_el)) {
|
|
5590
|
+
const text = plainText(itemEl.text())//You did not receive any items in this trade.
|
|
5593
5591
|
const appID = itemEl.attr('data-appid')
|
|
5594
5592
|
const classid = itemEl.attr('data-classid')
|
|
5595
5593
|
const instanceid = itemEl.attr('data-instanceid')
|
|
5596
5594
|
const contextid = itemEl.attr('data-contextid')
|
|
5597
5595
|
|
|
5598
5596
|
if (text !== `You did not receive any items in this trade.`) {
|
|
5599
|
-
|
|
5600
|
-
|
|
5601
|
-
|
|
5602
|
-
|
|
5603
|
-
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
contextid,
|
|
5609
|
-
steamId,
|
|
5610
|
-
plusminus: items_plusminus
|
|
5611
|
-
})
|
|
5612
|
-
}
|
|
5613
|
-
} else {
|
|
5614
|
-
// console.log("No app descriptions", appID);
|
|
5615
|
-
}
|
|
5597
|
+
tradehistory_items.push({
|
|
5598
|
+
appID,
|
|
5599
|
+
classid,
|
|
5600
|
+
instanceid,
|
|
5601
|
+
contextid,
|
|
5602
|
+
steamId,
|
|
5603
|
+
plusminus,
|
|
5604
|
+
...(descriptions[appID]?.[classid + '_' + instanceid])
|
|
5605
|
+
})
|
|
5616
5606
|
}
|
|
5617
|
-
}
|
|
5618
|
-
}
|
|
5607
|
+
}
|
|
5608
|
+
}
|
|
5619
5609
|
|
|
5620
|
-
if(tradehistory_items.length){
|
|
5610
|
+
if (tradehistory_items.length) {
|
|
5621
5611
|
const id = [timestamp, description, plusminus, tradehistory_items.map(item => (item.classid || '0') + "_" + (item.instanceid || '0')).join('|')]
|
|
5622
5612
|
.map(item => item.toString().replaceAll(/[^a-zA-Z0-9-+_|]/gi, ''))
|
|
5623
5613
|
.join('_').toLowerCase()
|
|
@@ -5633,9 +5623,10 @@ class SteamUser {
|
|
|
5633
5623
|
...(!!tradePeople && {tradePeople})
|
|
5634
5624
|
})
|
|
5635
5625
|
} else {
|
|
5626
|
+
fs.writeFileSync('tradehistory_items_empty_' + steamId + "_" + new Date().getTime(), html)
|
|
5636
5627
|
console.error("tradehistory_items empty", steamId);
|
|
5637
5628
|
}
|
|
5638
|
-
}
|
|
5629
|
+
}
|
|
5639
5630
|
|
|
5640
5631
|
return {cursor: result.cursor, tradehistory}
|
|
5641
5632
|
const exampleTradeHistory = [
|
|
@@ -6103,4 +6094,21 @@ class SteamUser {
|
|
|
6103
6094
|
}
|
|
6104
6095
|
}
|
|
6105
6096
|
|
|
6097
|
+
function plainText(text) {
|
|
6098
|
+
return text?.replaceAll(/[\t\n\r]/gi, ' ')?.replaceAll(/\s+/g, ' ')?.trim()
|
|
6099
|
+
}
|
|
6100
|
+
|
|
6101
|
+
function querySelectorAll($, selector, root) {
|
|
6102
|
+
try {
|
|
6103
|
+
if (root) {
|
|
6104
|
+
return [...root.find(selector)].map(el => $(el))
|
|
6105
|
+
} else {
|
|
6106
|
+
return [...$(selector)].map(el => $(el))
|
|
6107
|
+
}
|
|
6108
|
+
} catch (e) {
|
|
6109
|
+
console.error(e);
|
|
6110
|
+
return []
|
|
6111
|
+
}
|
|
6112
|
+
}
|
|
6113
|
+
|
|
6106
6114
|
export default SteamUser
|