steamutils 1.3.6 → 1.3.8
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +11 -13
- package/package.json +2 -1
package/index.js
CHANGED
@@ -16,6 +16,7 @@ import axios from 'axios'
|
|
16
16
|
import * as cheerio from 'cheerio'
|
17
17
|
import fs from "fs";
|
18
18
|
import FormData from "form-data";
|
19
|
+
import {StringUtils} from "alpha-common-utils/src/index.js";
|
19
20
|
|
20
21
|
const MAX_RETRY = 10
|
21
22
|
let requestTimestamp = 0
|
@@ -998,7 +999,7 @@ class SteamUser {
|
|
998
999
|
const text = $(line).text()
|
999
1000
|
$(line).remove()
|
1000
1001
|
return text
|
1001
|
-
}).concat(profileBanStatusEl.text()).map(text => text
|
1002
|
+
}).concat(profileBanStatusEl.text()).map(text => StringUtils.cleanSpace(text)).filter(Boolean)
|
1002
1003
|
const GameBan = SteamUser.parseGameBanType(gameBanFull)
|
1003
1004
|
let dayLastBan = null
|
1004
1005
|
if (GameBan && GameBan.daysSinceLastBan !== null) {
|
@@ -2357,10 +2358,10 @@ class SteamUser {
|
|
2357
2358
|
|
2358
2359
|
const isNickname = !!friendBlockContent.find('.player_nickname_hint').length
|
2359
2360
|
|
2360
|
-
const game = friendBlockContent.find(`.friend_game_link, .linkFriend_in-game`).text()
|
2361
|
+
const game = StringUtils.cleanSpace(friendBlockContent.find(`.friend_game_link, .linkFriend_in-game`).text()).removePrefix('In-Game').trim()
|
2361
2362
|
friendBlockContent.find(`.friend_small_text, .friendSmallText`).remove()
|
2362
2363
|
|
2363
|
-
const lastOnline = friendBlockContent.find(`.friend_last_online_text`).text()
|
2364
|
+
const lastOnline = StringUtils.cleanSpace(friendBlockContent.find(`.friend_last_online_text`).text())
|
2364
2365
|
friendBlockContent.find(`.friend_last_online_text`).remove()
|
2365
2366
|
|
2366
2367
|
let username = friendBlockContent.text().trim()
|
@@ -5532,6 +5533,7 @@ class SteamUser {
|
|
5532
5533
|
"You listed an item on the Community Market.",
|
5533
5534
|
"You canceled a listing on the Community Market. The item was returned to you.",
|
5534
5535
|
"Crafted",
|
5536
|
+
"Expired",
|
5535
5537
|
"Earned a new rank and got a drop",
|
5536
5538
|
"Got an item drop",
|
5537
5539
|
"Random item drop",
|
@@ -5603,7 +5605,7 @@ class SteamUser {
|
|
5603
5605
|
for (const tradehistory_items_el of querySelectorAll($, '.tradehistory_items', tradehistoryrow_el)) {
|
5604
5606
|
const plusminus = tradehistory_items_el.find('.tradehistory_items_plusminus').text().trim()
|
5605
5607
|
for (const itemEl of querySelectorAll($, '.tradehistory_items_group > .history_item', tradehistory_items_el)) {
|
5606
|
-
const text =
|
5608
|
+
const text = StringUtils.cleanSpace(itemEl.text())//You did not receive any items in this trade.
|
5607
5609
|
const appID = itemEl.attr('data-appid')
|
5608
5610
|
const classid = itemEl.attr('data-classid')
|
5609
5611
|
const instanceid = itemEl.attr('data-instanceid')
|
@@ -5837,7 +5839,7 @@ class SteamUser {
|
|
5837
5839
|
const playerAvatar = $1.find('.playerAvatar')
|
5838
5840
|
const avatar = playerAvatar.find('img')?.attr('src')
|
5839
5841
|
const link = playerAvatar.find('a')?.attr('href')
|
5840
|
-
const header = $1.find('.tradeoffer_header').text()
|
5842
|
+
const header = StringUtils.cleanSpace($1.find('.tradeoffer_header').text())
|
5841
5843
|
const active = $1.find('.tradeoffer_items_ctn').hasClass("active")
|
5842
5844
|
|
5843
5845
|
tradeOffers.push({
|
@@ -5989,12 +5991,12 @@ class SteamUser {
|
|
5989
5991
|
const market_headertip_container_warning_el = $('.market_headertip_container_warning')
|
5990
5992
|
const market_warning_header_el = market_headertip_container_warning_el.find('#market_warning_header')
|
5991
5993
|
if (market_headertip_container_warning_el.length && market_warning_header_el.length) {
|
5992
|
-
const market_warning_header = market_warning_header_el.text()
|
5994
|
+
const market_warning_header = StringUtils.cleanSpace(market_warning_header_el.text())
|
5993
5995
|
const market_restrictions = []
|
5994
5996
|
market_headertip_container_warning_el.find('ul.market_restrictions > li').each(function () {
|
5995
5997
|
const el = $(this);
|
5996
5998
|
el.find('a').remove()
|
5997
|
-
market_restrictions.push(el.text()
|
5999
|
+
market_restrictions.push(StringUtils.cleanSpace(el.text()))
|
5998
6000
|
})
|
5999
6001
|
return {
|
6000
6002
|
market_warning_header,
|
@@ -6013,7 +6015,7 @@ class SteamUser {
|
|
6013
6015
|
return null
|
6014
6016
|
}
|
6015
6017
|
const $ = cheerio.load(response)
|
6016
|
-
const text = $('.help_event_limiteduser .help_event_limiteduser_spend').text()
|
6018
|
+
const text = StringUtils.cleanSpace($('.help_event_limiteduser .help_event_limiteduser_spend').text())
|
6017
6019
|
if (text?.startsWith("Amount Spent on Steam")) {
|
6018
6020
|
return text
|
6019
6021
|
} else {
|
@@ -6091,7 +6093,7 @@ class SteamUser {
|
|
6091
6093
|
const receive_price = parseInt($1.find(`.market_listing_price span[title="This is how much you will receive."]`).text().replaceAll(`(`, '').replaceAll(`)`, '').replaceAll(`₫`, '').replaceAll(`.`, '').replaceAll(`,`, '').trim())
|
6092
6094
|
const item_name = $1.find('.market_listing_item_name_link').text()
|
6093
6095
|
const game_name = $1.find('.market_listing_game_name').text()
|
6094
|
-
const date_combined = $1.find('.market_listing_listed_date_combined').text().replaceAll(`Listed:`, '')
|
6096
|
+
const date_combined = StringUtils.cleanSpace($1.find('.market_listing_listed_date_combined').text().replaceAll(`Listed:`, ''))
|
6095
6097
|
list.push({
|
6096
6098
|
listingid,
|
6097
6099
|
appid,
|
@@ -6113,10 +6115,6 @@ class SteamUser {
|
|
6113
6115
|
}
|
6114
6116
|
}
|
6115
6117
|
|
6116
|
-
function plainText(text) {
|
6117
|
-
return text?.replaceAll(/[\t\n\r]/gi, ' ')?.replaceAll(/\s+/g, ' ')?.trim()
|
6118
|
-
}
|
6119
|
-
|
6120
6118
|
function querySelectorAll($, selector, root) {
|
6121
6119
|
try {
|
6122
6120
|
if (root) {
|