steamutils 1.1.4 → 1.1.6
Sign up to get free protection for your applications and to get access to all the features.
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/steamutils.iml +1 -1
- package/.idea/vcs.xml +1 -1
- package/SteamClient.js +9 -4
- package/index.js +0 -226
- package/package.json +1 -1
package/.idea/steamutils.iml
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
<module type="WEB_MODULE" version="4">
|
3
3
|
<component name="NewModuleRootManager">
|
4
4
|
<content url="file://$MODULE_DIR$">
|
5
|
-
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
6
5
|
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
6
|
+
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
7
7
|
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
8
8
|
</content>
|
9
9
|
<orderEntry type="inheritedJdk" />
|
package/.idea/vcs.xml
CHANGED
package/SteamClient.js
CHANGED
@@ -99,6 +99,7 @@ function SteamClient({
|
|
99
99
|
friendTyping: [],
|
100
100
|
disconnected: [],
|
101
101
|
error: [],
|
102
|
+
playersProfile: [],
|
102
103
|
}
|
103
104
|
|
104
105
|
const gcCallback = {}
|
@@ -115,7 +116,7 @@ function SteamClient({
|
|
115
116
|
clearTimeout(t)
|
116
117
|
}
|
117
118
|
delete gcCallback[name][id]
|
118
|
-
cb(
|
119
|
+
cb(arg)
|
119
120
|
}
|
120
121
|
|
121
122
|
if (timeout) {
|
@@ -127,7 +128,7 @@ function SteamClient({
|
|
127
128
|
function callGCCallback(name, ...arg) {
|
128
129
|
if (gcCallback[name]) {
|
129
130
|
for (let id in gcCallback[name]) {
|
130
|
-
gcCallback[name][id](
|
131
|
+
gcCallback[name][id](arg)
|
131
132
|
}
|
132
133
|
}
|
133
134
|
}
|
@@ -651,8 +652,12 @@ function SteamClient({
|
|
651
652
|
player_xp_bonus_flags: 0
|
652
653
|
}]
|
653
654
|
|
654
|
-
const
|
655
|
-
|
655
|
+
const player = data?.[0];
|
656
|
+
if (player) {
|
657
|
+
player.prime = !!(player.ranking?.account_id || player.player_level || player.player_cur_xp)
|
658
|
+
}
|
659
|
+
callGCCallback('PlayersProfile' + player?.account_id, player)
|
660
|
+
callEvent(events.playersProfile, player)
|
656
661
|
break
|
657
662
|
}
|
658
663
|
default:
|
package/index.js
CHANGED
@@ -4951,232 +4951,6 @@ class SteamUser {
|
|
4951
4951
|
"median_price": "30.936,57₫"
|
4952
4952
|
}
|
4953
4953
|
}
|
4954
|
-
|
4955
|
-
async getFullInventoryHistory() {
|
4956
|
-
let result = null
|
4957
|
-
do {
|
4958
|
-
result = await this.getInventoryHistory(result?.cursor)
|
4959
|
-
result.tradehistory.forEach(r => console.log(r))
|
4960
|
-
} while (result?.cursor)
|
4961
|
-
}
|
4962
|
-
async getInventoryHistory(cursor) {
|
4963
|
-
if (!cursor) {
|
4964
|
-
cursor = {
|
4965
|
-
time: parseInt(new Date().getTime() / 1000),
|
4966
|
-
time_frac: 0,
|
4967
|
-
s: 0,
|
4968
|
-
}
|
4969
|
-
}
|
4970
|
-
|
4971
|
-
// let cursor = null
|
4972
|
-
let result = null
|
4973
|
-
for (let i = 0; i < 10; i++) {
|
4974
|
-
const query = {sessionid: this._sessionid, ajax: 1, l: 'english'}
|
4975
|
-
if (cursor) {
|
4976
|
-
query['cursor[s]'] = cursor.s
|
4977
|
-
query['cursor[time_frac]'] = cursor.time_frac
|
4978
|
-
query['cursor[time]'] = cursor.time
|
4979
|
-
}
|
4980
|
-
const url = `https://steamcommunity.com/my/inventoryhistory/?${Object.keys(query).map(k => `${encodeURIComponent(k)}=${encodeURIComponent(query[k])}`).join('&')}`;
|
4981
|
-
let _result
|
4982
|
-
try {
|
4983
|
-
_result = (await this._httpRequestAjax({url}))?.data
|
4984
|
-
} catch (e) {
|
4985
|
-
}
|
4986
|
-
if (!_result) {
|
4987
|
-
await sleep(5000)
|
4988
|
-
} else if (typeof _result === "string") {
|
4989
|
-
|
4990
|
-
} else if (_result.success !== true) {
|
4991
|
-
console.error(url)
|
4992
|
-
console.error(_result)
|
4993
|
-
await sleep(5000)
|
4994
|
-
} else {
|
4995
|
-
result = _result
|
4996
|
-
break
|
4997
|
-
}
|
4998
|
-
}
|
4999
|
-
|
5000
|
-
const descriptions = result.descriptions
|
5001
|
-
const $ = cheerio.load(result.html?.replaceAll(/[\t\n\r]/gi, '')
|
5002
|
-
?.trim() || '')
|
5003
|
-
|
5004
|
-
const tradehistory = []
|
5005
|
-
$('.tradehistoryrow').each(function () {
|
5006
|
-
const tradehistoryrow_el = $(this)
|
5007
|
-
const tradehistory_date_el = tradehistoryrow_el.find('.tradehistory_date')
|
5008
|
-
const tradehistory_timestamp_el = tradehistory_date_el.find('.tradehistory_timestamp')
|
5009
|
-
|
5010
|
-
const tradehistory_timestamp = tradehistory_timestamp_el.text().trim()//3:49pm
|
5011
|
-
tradehistory_timestamp_el.remove()
|
5012
|
-
const tradehistory_date = tradehistory_date_el.text().trim()//24 Mar, 2023
|
5013
|
-
|
5014
|
-
let timestamp = 0
|
5015
|
-
const timestampMoment = moment(`${tradehistory_date} ${tradehistory_timestamp}`, `D MMM, YYYY h:mma`, true)
|
5016
|
-
if (!timestampMoment.isValid()) {
|
5017
|
-
console.log(`${tradehistory_date} ${tradehistory_timestamp}`);
|
5018
|
-
} else {
|
5019
|
-
timestamp = timestampMoment.valueOf() / 1000
|
5020
|
-
}
|
5021
|
-
|
5022
|
-
const tradehistory_event_description_el = tradehistoryrow_el.find('.tradehistory_event_description')
|
5023
|
-
let description = tradehistory_event_description_el.text().trim()
|
5024
|
-
let tradePeople = null
|
5025
|
-
|
5026
|
-
switch (description) {
|
5027
|
-
case "You purchased an item on the Community Market.": {
|
5028
|
-
break
|
5029
|
-
}
|
5030
|
-
case "You listed an item on the Community Market.": {
|
5031
|
-
break
|
5032
|
-
}
|
5033
|
-
case "You canceled a listing on the Community Market. The item was returned to you.": {
|
5034
|
-
break
|
5035
|
-
}
|
5036
|
-
case "Crafted": {
|
5037
|
-
break
|
5038
|
-
}
|
5039
|
-
case "Earned a new rank and got a drop": {
|
5040
|
-
break
|
5041
|
-
}
|
5042
|
-
case "Got an item drop": {
|
5043
|
-
break
|
5044
|
-
}
|
5045
|
-
case "Purchased a gift": {
|
5046
|
-
break
|
5047
|
-
}
|
5048
|
-
case "Earned by redeeming Steam Points": {
|
5049
|
-
break
|
5050
|
-
}
|
5051
|
-
case "Earned by completing your Store Discovery Queue": {
|
5052
|
-
break
|
5053
|
-
}
|
5054
|
-
case "Earned": {
|
5055
|
-
break
|
5056
|
-
}
|
5057
|
-
case "Earned due to game play time": {
|
5058
|
-
break
|
5059
|
-
}
|
5060
|
-
default: {
|
5061
|
-
if (description.startsWith("You traded with ")) {
|
5062
|
-
const peopleEl = tradehistory_event_description_el.find('a[href]')
|
5063
|
-
tradePeople = {
|
5064
|
-
name: peopleEl.text().trim(),
|
5065
|
-
url: peopleEl.attr('href')
|
5066
|
-
}
|
5067
|
-
description = "You traded with"
|
5068
|
-
} else if (description.startsWith("Gift sent to and redeemed by ")) {
|
5069
|
-
const peopleEl = tradehistory_event_description_el.find('a[href]')
|
5070
|
-
tradePeople = {
|
5071
|
-
name: peopleEl.text().trim(),
|
5072
|
-
url: peopleEl.attr('href')
|
5073
|
-
}
|
5074
|
-
description = "Gift sent to and redeemed by"
|
5075
|
-
} else if (description.startsWith("Your trade with ") && description.endsWith(" was on hold, and the trade has now completed.")) {
|
5076
|
-
const peopleEl = tradehistory_event_description_el.find('a[href]')
|
5077
|
-
tradePeople = {
|
5078
|
-
name: peopleEl.text().trim(),
|
5079
|
-
url: peopleEl.attr('href')
|
5080
|
-
}
|
5081
|
-
description = "Your trade with friend was on hold, and the trade has now completed."
|
5082
|
-
} else if (description.startsWith("You listed an item on the Community Market. The listing was placed on hold until")) {
|
5083
|
-
//You listed an item on the Community Market. The listing was placed on hold until 24 Jan @ 3:06am.
|
5084
|
-
description = "You listed an item on the Community Market. The listing was placed on hold until"
|
5085
|
-
} else {
|
5086
|
-
console.log(description);
|
5087
|
-
}
|
5088
|
-
}
|
5089
|
-
}
|
5090
|
-
|
5091
|
-
const plusminus = tradehistoryrow_el.find('.tradehistory_items_plusminus').text().trim()//+ -
|
5092
|
-
const tradehistory_items = []
|
5093
|
-
tradehistoryrow_el.find('.tradehistory_items').each(function () {
|
5094
|
-
const tradehistory_items_el = $(this)
|
5095
|
-
const items_plusminus = tradehistory_items_el.find('.tradehistory_items_plusminus').text().trim()
|
5096
|
-
tradehistory_items_el.find('.tradehistory_items_group > .history_item').each(function () {
|
5097
|
-
const itemEl = $(this)
|
5098
|
-
const text = itemEl.text().trim()//You did not receive any items in this trade.
|
5099
|
-
const appID = itemEl.attr('data-appid')
|
5100
|
-
const classid = itemEl.attr('data-classid')
|
5101
|
-
const instanceid = itemEl.attr('data-instanceid')
|
5102
|
-
const contextid = itemEl.attr('data-contextid')
|
5103
|
-
|
5104
|
-
if (text !== `You did not receive any items in this trade.`) {
|
5105
|
-
const item = descriptions[appID][classid + '_' + instanceid]
|
5106
|
-
if (item) {
|
5107
|
-
tradehistory_items.push({...item, plusminus: items_plusminus})
|
5108
|
-
} else {
|
5109
|
-
tradehistory_items.push({
|
5110
|
-
appID,
|
5111
|
-
classid,
|
5112
|
-
instanceid,
|
5113
|
-
contextid,
|
5114
|
-
plusminus: items_plusminus
|
5115
|
-
})
|
5116
|
-
}
|
5117
|
-
}
|
5118
|
-
})
|
5119
|
-
})
|
5120
|
-
|
5121
|
-
tradehistory.push({
|
5122
|
-
timestamp,
|
5123
|
-
description,
|
5124
|
-
plusminus,
|
5125
|
-
tradehistory_items,
|
5126
|
-
...(!!tradePeople && {tradePeople})
|
5127
|
-
})
|
5128
|
-
})
|
5129
|
-
|
5130
|
-
return {cursor: result.cursor, tradehistory}
|
5131
|
-
const exampleTradeHistory = [
|
5132
|
-
{
|
5133
|
-
timestamp: 1684108140,
|
5134
|
-
description: "Got an item drop",
|
5135
|
-
plusminus: "+",
|
5136
|
-
tradehistory_items: [
|
5137
|
-
{
|
5138
|
-
icon_url: "-9a81dlWLwJ2UUGcVs_nsVtzdOEdtWwKGZZLQHTxDZ7I56KU0Zwwo4NUX4oFJZEHLbXU5A1PIYQNqhpOSV-fRPasw8rsUFJ5KBFZv668FFQwnfCcJmxDv9rhwIHZwqP3a-uGwz9Xv8F0j-qQrI3xiVLkrxVuZW-mJoWLMlhpWhFkc9M",
|
5139
|
-
icon_drag_url: "",
|
5140
|
-
name: "Dreams & Nightmares Case",
|
5141
|
-
market_hash_name: "Dreams & Nightmares Case",
|
5142
|
-
market_name: "Dreams & Nightmares Case",
|
5143
|
-
name_color: "D2D2D2",
|
5144
|
-
background_color: "",
|
5145
|
-
type: "Base Grade Container",
|
5146
|
-
tradable: 1,
|
5147
|
-
marketable: 1,
|
5148
|
-
commodity: 1,
|
5149
|
-
market_tradable_restriction: "7",
|
5150
|
-
market_buy_country_restriction: "FR",
|
5151
|
-
descriptions: [
|
5152
|
-
{
|
5153
|
-
type: "html",
|
5154
|
-
value: " "
|
5155
|
-
},
|
5156
|
-
{
|
5157
|
-
type: "html",
|
5158
|
-
value: "",
|
5159
|
-
color: "00a000",
|
5160
|
-
app_data: {
|
5161
|
-
limited: 1
|
5162
|
-
}
|
5163
|
-
}
|
5164
|
-
],
|
5165
|
-
tags: [
|
5166
|
-
{
|
5167
|
-
internal_name: "CSGO_Type_WeaponCase",
|
5168
|
-
name: "Container",
|
5169
|
-
category: "Type",
|
5170
|
-
category_name: "Type"
|
5171
|
-
},
|
5172
|
-
],
|
5173
|
-
classid: "4717330486",
|
5174
|
-
plusminus: "+"
|
5175
|
-
}
|
5176
|
-
]
|
5177
|
-
},
|
5178
|
-
]
|
5179
|
-
}
|
5180
4954
|
}
|
5181
4955
|
|
5182
4956
|
export default SteamUser
|