steamutils 1.1.38 → 1.1.40
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/example.js +89 -4
- package/index.js +6 -3
- 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/example.js
CHANGED
@@ -11,9 +11,94 @@ import * as cherrio from "cheerio";
|
|
11
11
|
// const user = new SteamUser(loginResult.cookie)
|
12
12
|
|
13
13
|
|
14
|
-
let cookies = `timezoneOffset=25200,0; _ga=GA1.2.187887660.1678676715; browserid=2823232875076552481; strInventoryLastContext=730_2; recentlyVisitedAppHubs=730%2C1859270; sessionid=83e614b63d78d0d2b4d93680; steamCountry=VN%7C3c7bd5df99a265a3e5102a225d1ab62d; steamLoginSecure=76561199040402348%7C%7CeyAidHlwIjogIkpXVCIsICJhbGciOiAiRWREU0EiIH0.eyAiaXNzIjogInI6MEQwM18yMjM1ODQ2MF8xM0YyNCIsICJzdWIiOiAiNzY1NjExOTkwNDA0MDIzNDgiLCAiYXVkIjogWyAid2ViIiBdLCAiZXhwIjogMTY4NTA2NTUzMiwgIm5iZiI6IDE2NzYzMzc4MDcsICJpYXQiOiAxNjg0OTc3ODA3LCAianRpIjogIjBEMkRfMjI5NkUxQkNfQzNERjUiLCAib2F0IjogMTY3ODY3NjgzMywgInJ0X2V4cCI6IDE2OTY4NjYxMDEsICJwZXIiOiAwLCAiaXBfc3ViamVjdCI6ICIxNC4yMzIuMjE0LjE4NiIsICJpcF9jb25maXJtZXIiOiAiMTQuMjMyLjIxNC4xODYiIH0.AhLuV9mQzv2j2CEgBe5ZpGyUqpHXogHFClfdsd3Ve7-Dt4aHagrJhOsgLewh1gmkO5ZewAN4FO4Y5S3D7u4FCw; webTradeEligibility=%7B%22allowed%22%3A1%2C%22allowed_at_time%22%3A0%2C%22steamguard_required_days%22%3A15%2C%22new_device_cooldown_days%22%3A0%2C%22time_checked%22%3A1684981543%7D; tsTradeOffersLastRead=1684321053`;
|
15
|
-
const user = new SteamUser("timezoneOffset=25200,0; _ga=GA1.2.187887660.1678676715; browserid=2823232875076552481; strInventoryLastContext=730_2; recentlyVisitedAppHubs=730%2C1859270; sessionid=83e614b63d78d0d2b4d93680; steamCountry=VN%7C3c7bd5df99a265a3e5102a225d1ab62d; steamLoginSecure=76561199040402348%7C%7CeyAidHlwIjogIkpXVCIsICJhbGciOiAiRWREU0EiIH0.eyAiaXNzIjogInI6MEQwM18yMjM1ODQ2MF8xM0YyNCIsICJzdWIiOiAiNzY1NjExOTkwNDA0MDIzNDgiLCAiYXVkIjogWyAid2ViIiBdLCAiZXhwIjogMTY4NTA2NTUzMiwgIm5iZiI6IDE2NzYzMzc4MDcsICJpYXQiOiAxNjg0OTc3ODA3LCAianRpIjogIjBEMkRfMjI5NkUxQkNfQzNERjUiLCAib2F0IjogMTY3ODY3NjgzMywgInJ0X2V4cCI6IDE2OTY4NjYxMDEsICJwZXIiOiAwLCAiaXBfc3ViamVjdCI6ICIxNC4yMzIuMjE0LjE4NiIsICJpcF9jb25maXJtZXIiOiAiMTQuMjMyLjIxNC4xODYiIH0.AhLuV9mQzv2j2CEgBe5ZpGyUqpHXogHFClfdsd3Ve7-Dt4aHagrJhOsgLewh1gmkO5ZewAN4FO4Y5S3D7u4FCw; webTradeEligibility=%7B%22allowed%22%3A1%2C%22allowed_at_time%22%3A0%2C%22steamguard_required_days%22%3A15%2C%22new_device_cooldown_days%22%3A0%2C%22time_checked%22%3A1684981543%7D; tsTradeOffersLastRead=1684321053")
|
16
|
-
const
|
17
|
-
|
14
|
+
// let cookies = `timezoneOffset=25200,0; _ga=GA1.2.187887660.1678676715; browserid=2823232875076552481; strInventoryLastContext=730_2; recentlyVisitedAppHubs=730%2C1859270; sessionid=83e614b63d78d0d2b4d93680; steamCountry=VN%7C3c7bd5df99a265a3e5102a225d1ab62d; steamLoginSecure=76561199040402348%7C%7CeyAidHlwIjogIkpXVCIsICJhbGciOiAiRWREU0EiIH0.eyAiaXNzIjogInI6MEQwM18yMjM1ODQ2MF8xM0YyNCIsICJzdWIiOiAiNzY1NjExOTkwNDA0MDIzNDgiLCAiYXVkIjogWyAid2ViIiBdLCAiZXhwIjogMTY4NTA2NTUzMiwgIm5iZiI6IDE2NzYzMzc4MDcsICJpYXQiOiAxNjg0OTc3ODA3LCAianRpIjogIjBEMkRfMjI5NkUxQkNfQzNERjUiLCAib2F0IjogMTY3ODY3NjgzMywgInJ0X2V4cCI6IDE2OTY4NjYxMDEsICJwZXIiOiAwLCAiaXBfc3ViamVjdCI6ICIxNC4yMzIuMjE0LjE4NiIsICJpcF9jb25maXJtZXIiOiAiMTQuMjMyLjIxNC4xODYiIH0.AhLuV9mQzv2j2CEgBe5ZpGyUqpHXogHFClfdsd3Ve7-Dt4aHagrJhOsgLewh1gmkO5ZewAN4FO4Y5S3D7u4FCw; webTradeEligibility=%7B%22allowed%22%3A1%2C%22allowed_at_time%22%3A0%2C%22steamguard_required_days%22%3A15%2C%22new_device_cooldown_days%22%3A0%2C%22time_checked%22%3A1684981543%7D; tsTradeOffersLastRead=1684321053`;
|
15
|
+
// const user = new SteamUser("timezoneOffset=25200,0; _ga=GA1.2.187887660.1678676715; browserid=2823232875076552481; strInventoryLastContext=730_2; recentlyVisitedAppHubs=730%2C1859270; sessionid=83e614b63d78d0d2b4d93680; steamCountry=VN%7C3c7bd5df99a265a3e5102a225d1ab62d; steamLoginSecure=76561199040402348%7C%7CeyAidHlwIjogIkpXVCIsICJhbGciOiAiRWREU0EiIH0.eyAiaXNzIjogInI6MEQwM18yMjM1ODQ2MF8xM0YyNCIsICJzdWIiOiAiNzY1NjExOTkwNDA0MDIzNDgiLCAiYXVkIjogWyAid2ViIiBdLCAiZXhwIjogMTY4NTA2NTUzMiwgIm5iZiI6IDE2NzYzMzc4MDcsICJpYXQiOiAxNjg0OTc3ODA3LCAianRpIjogIjBEMkRfMjI5NkUxQkNfQzNERjUiLCAib2F0IjogMTY3ODY3NjgzMywgInJ0X2V4cCI6IDE2OTY4NjYxMDEsICJwZXIiOiAwLCAiaXBfc3ViamVjdCI6ICIxNC4yMzIuMjE0LjE4NiIsICJpcF9jb25maXJtZXIiOiAiMTQuMjMyLjIxNC4xODYiIH0.AhLuV9mQzv2j2CEgBe5ZpGyUqpHXogHFClfdsd3Ve7-Dt4aHagrJhOsgLewh1gmkO5ZewAN4FO4Y5S3D7u4FCw; webTradeEligibility=%7B%22allowed%22%3A1%2C%22allowed_at_time%22%3A0%2C%22steamguard_required_days%22%3A15%2C%22new_device_cooldown_days%22%3A0%2C%22time_checked%22%3A1684981543%7D; tsTradeOffersLastRead=1684321053")
|
16
|
+
// const friendList = await user.getTradeURL()
|
17
|
+
|
18
|
+
function CookieManager(cookie) {
|
19
|
+
const _CookieObj = {}
|
20
|
+
if (typeof cookie === "string") {
|
21
|
+
cookie.split(";").forEach(function (_cookie) {
|
22
|
+
setCookie(_cookie.split("=")[0].trim(), _cookie.split("=")[1].trim())
|
23
|
+
})
|
24
|
+
} else if (Array.isArray(cookie)) {
|
25
|
+
cookie.forEach(function (_cookie) {
|
26
|
+
if (typeof _cookie === "string") {
|
27
|
+
setCookie(_cookie.split("=")[0].trim(), _cookie.split("=")[1].trim())
|
28
|
+
} else {
|
29
|
+
//to do
|
30
|
+
}
|
31
|
+
})
|
32
|
+
} else if (typeof cookie === "object" && Object.keys(cookie).length) {
|
33
|
+
for (const key in cookie) {
|
34
|
+
setCookie(key, cookie[key])
|
35
|
+
}
|
36
|
+
} else {
|
37
|
+
//to do
|
38
|
+
}
|
39
|
+
|
40
|
+
function setCookie(name, value) {
|
41
|
+
const existedKey = Object.keys(_CookieObj).find(k => k.toLowerCase() === name.toLowerCase())
|
42
|
+
if (existedKey) {
|
43
|
+
delete _CookieObj[existedKey]
|
44
|
+
}
|
45
|
+
_CookieObj[name] = value
|
46
|
+
}
|
47
|
+
|
48
|
+
function setCookies(cookies) {
|
49
|
+
if (Array.isArray(cookies)) {
|
50
|
+
for (let cookie of cookies) {
|
51
|
+
if (typeof cookie === "string") {
|
52
|
+
cookie = cookie.split(";")[0].trim()
|
53
|
+
setCookie(cookie.split("=")[0].trim(), cookie.split("=")[1].trim())
|
54
|
+
}
|
55
|
+
}
|
56
|
+
}
|
57
|
+
}
|
58
|
+
|
59
|
+
function getCookie(name) {
|
60
|
+
const existedKey = Object.keys(_CookieObj).find(k => k.toLowerCase() === name.toLowerCase())
|
61
|
+
return _CookieObj[existedKey]
|
62
|
+
}
|
63
|
+
|
64
|
+
|
65
|
+
function toString() {
|
66
|
+
return Object.keys(_CookieObj).map(k => `${k}=${_CookieObj[k]}`).join(';')
|
67
|
+
}
|
68
|
+
|
69
|
+
return {
|
70
|
+
setCookie,
|
71
|
+
setCookies,
|
72
|
+
getCookie,
|
73
|
+
toString,
|
74
|
+
}
|
75
|
+
}
|
76
|
+
|
77
|
+
const cookiesObj = new CookieManager("steamLoginSecure=76561199490333788%7C%7CeyAidHlwIjogIkpXVCIsICJhbGciOiAiRWREU0EiIH0.eyAiaXNzIjogInI6MEQyRF8yMjhEQTcxQV9DOEZGRCIsICJzdWIiOiAiNzY1NjExOTk0OTAzMzM3ODgiLCAiYXVkIjogWyAid2ViIiwgIm1vYmlsZSIgXSwgImV4cCI6IDE2ODUwNjY0MzgsICJuYmYiOiAxNjc2MzQwMDAwLCAiaWF0IjogMTY4NDk4MDAwMCwgImp0aSI6ICIwRDJCXzIyOTZFMUJGXzUyNEU2IiwgIm9hdCI6IDE2ODQzODUwODksICJydF9leHAiOiAxNzAyNzQzMDU3LCAicGVyIjogMCwgImlwX3N1YmplY3QiOiAiMTQuMjMyLjIxNC4xODYiLCAiaXBfY29uZmlybWVyIjogIjE0LjIzMi4yMTQuMTg2IiB9.t884pdEgtcWk8Apy1HrzhQixy0u-RQFM-qb3JuaYMZjCwTRXdCnOZFbCxFe2JesC5xfFttHe4ufqtyizcEmVDA")
|
78
|
+
|
79
|
+
let url = `my/tradeoffers/privacy`
|
80
|
+
while (true) {
|
81
|
+
const response = await axios({
|
82
|
+
baseURL: "https://steamcommunity.com",
|
83
|
+
url,
|
84
|
+
validateStatus: () => true,
|
85
|
+
headers: {
|
86
|
+
cookie: cookiesObj.toString()
|
87
|
+
},
|
88
|
+
maxRedirects: 0,
|
89
|
+
})
|
90
|
+
cookiesObj.setCookies(response.headers["set-cookie"])
|
91
|
+
if (response.status === 302) {
|
92
|
+
url = response.headers.location
|
93
|
+
console.log(`Redirect to ${url}`)
|
94
|
+
} else if (response.status === 200) {
|
95
|
+
const $ = cherrio.load(response.data)
|
96
|
+
const trade_offer_access_url = $('#trade_offer_access_url').attr('value')
|
97
|
+
console.log(trade_offer_access_url);
|
98
|
+
return response
|
99
|
+
} else {
|
100
|
+
console.log(response.status);
|
101
|
+
}
|
102
|
+
}
|
18
103
|
|
19
104
|
})()
|
package/index.js
CHANGED
@@ -2296,7 +2296,7 @@ class SteamUser {
|
|
2296
2296
|
i = MAX_RETRY
|
2297
2297
|
while (result?.data?.success !== true && i--) {
|
2298
2298
|
result = await _self._httpRequest(
|
2299
|
-
`${this.getMySteamUserProfileURL()}/gcpd/${AppID_CSGO}?ajax=1&tab=${matchHistoryType}
|
2299
|
+
`${this.getMySteamUserProfileURL()}/gcpd/${AppID_CSGO}?ajax=1&tab=${matchHistoryType}${token ? `&continue_token=${token}` : ''}&sessionid=${_self._sessionid}`)
|
2300
2300
|
}
|
2301
2301
|
if (!result.data) {
|
2302
2302
|
return null
|
@@ -2432,7 +2432,10 @@ class SteamUser {
|
|
2432
2432
|
}
|
2433
2433
|
|
2434
2434
|
const myTeam = players.find(p => p.isMe)?.team
|
2435
|
-
myTeam && players.forEach(p =>
|
2435
|
+
myTeam && players.forEach(p => {
|
2436
|
+
p.isTeammate = p.team === myTeam && !p.isMe
|
2437
|
+
p.teamScore = p.team === 'ct' ? ctScore : tScore
|
2438
|
+
})
|
2436
2439
|
|
2437
2440
|
const matchIDs = [matchInfo.map, matchInfo.time, matchInfo.waitTime, matchInfo.duration]
|
2438
2441
|
const nonHashMatchID = matchIDs.join('').replaceAll(/[^a-zA-Z0-9]/gi, '')
|
@@ -2508,7 +2511,7 @@ class SteamUser {
|
|
2508
2511
|
const matches = []
|
2509
2512
|
|
2510
2513
|
do {
|
2511
|
-
result = await
|
2514
|
+
result = await this._getHistoryMatches(matchHistoryType, result?.continue_token)
|
2512
2515
|
stop = shouldStop({
|
2513
2516
|
maxPage,
|
2514
2517
|
currentPage: page,
|