steamutils 1.2.4 → 1.2.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/index.js +25 -10
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -962,6 +962,8 @@ class SteamUser {
962
962
  const name = $('.persona_name .actual_persona_name').text().trim()
963
963
  const $personaLevel = $('.persona_level .friendPlayerLevelNum')
964
964
  const level = $personaLevel.length ? parseInt($personaLevel.text()) : null
965
+ const notYetSetupLink = $('#btn > a').attr('href') || ''
966
+ const notYetSetup = NotYetSetupProfileTextList.includes(profile_private_info) || notYetSetupLink.endsWith("edit?welcomed=1")
965
967
 
966
968
  const g_rgProfileDataExample = {
967
969
  url: 'https://steamcommunity.com/id/natri99/',
@@ -969,9 +971,22 @@ class SteamUser {
969
971
  personaname: 'Natri',
970
972
  summary: 'Sub: <a class="bb_link" href="https://steamcommunity.com/id/Natri2099/" target="_blank" rel="noreferrer" >https://steamcommunity.com/id/Natri2099/</a> ',
971
973
  }
972
- const g_rgProfileData = JSON_parse(html.substringBetweenOrNull('g_rgProfileData = ', '"};') + '"}')
973
- if (!g_rgProfileData) {
974
- return
974
+ let g_rgProfileData = JSON_parse(html.substringBetweenOrNull('g_rgProfileData = ', '"};') + '"}')
975
+ if (!g_rgProfileData && notYetSetup) {
976
+ if (notYetSetupLink.endsWith("edit?welcomed=1")) {
977
+ const steamId = notYetSetupLink.split('https://steamcommunity.com/profiles/')[1].split('/')[0]
978
+ const helloText = $('#hello').text()
979
+ let personaname = helloText.substring(helloText.indexOf(",") + 1).trim()
980
+ if (personaname.endsWith(".")) {
981
+ personaname = personaname.substring(0, personaname.length - 1).trim()
982
+ }
983
+ g_rgProfileData = {
984
+ url: 'https://steamcommunity.com/profiles/' + steamId,
985
+ steamid: steamId,
986
+ personaname,
987
+ summary: ''
988
+ }
989
+ }
975
990
  }
976
991
 
977
992
  const lobbyLink = $(`.profile_in_game_joingame a[href*='steam://joinlobby/']`).attr('href')
@@ -1006,8 +1021,8 @@ class SteamUser {
1006
1021
  const avatarHash = SteamUser.GetAvatarHashFromMultipleURL(avatarFulls)
1007
1022
  const location = $('img.profile_flag').attr('src')?.substringBetweenOrNull('/images/countryflags/', '.')?.toUpperCase() || ''
1008
1023
 
1009
- const playerAvatarClass = $('.profile_header .playerAvatar').attr('class')
1010
- const onlineState = ['online', 'offline', 'in-game'].find(_onlineState => playerAvatarClass.includes(_onlineState))
1024
+ const playerAvatarClass = $('.profile_header .playerAvatar').attr('class') || ''
1025
+ const onlineState = ['online', 'offline', 'in-game'].find(_onlineState => playerAvatarClass.includes(_onlineState)) || 'offline'
1011
1026
  const gamename = $('.profile_in_game .profile_in_game_name').text()?.trim() || ''
1012
1027
  let stateMessageGame = ''
1013
1028
  if (onlineState === 'in-game') {
@@ -1015,7 +1030,7 @@ class SteamUser {
1015
1030
  }
1016
1031
 
1017
1032
  return {
1018
- name: g_rgProfileData.personaname,
1033
+ name: g_rgProfileData.personaname || '',
1019
1034
  realname: $('.header_real_name bdi').text()?.trim() || '',
1020
1035
  onlineState,
1021
1036
  steamID: g_rgProfileData.steamid,
@@ -1024,10 +1039,10 @@ class SteamUser {
1024
1039
  customURL,
1025
1040
  location,
1026
1041
  summary: SteamUser._formatSummary(g_rgProfileData.summary),
1027
- notYetSetup: NotYetSetupProfileTextList.includes(profile_private_info),
1028
- profile_private_info: profile_private_info ? ((NotYetSetupProfileTextList.includes(profile_private_info)
1029
- ? '___NotYetSetupProfile___'
1030
- : (PrivateProfileTextList.includes(profile_private_info) ? '___PrivateProfile___' : profile_private_info))) : null,
1042
+ notYetSetup,
1043
+ profile_private_info: notYetSetup
1044
+ ? '___NotYetSetupProfile___'
1045
+ : (PrivateProfileTextList.includes(profile_private_info) ? '___PrivateProfile___' : profile_private_info),
1031
1046
  lobbyLink,
1032
1047
  addFriendEnable,
1033
1048
  isPrivate: PrivateProfileTextList.includes(profile_private_info),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "steamutils",
3
- "version": "1.2.04",
3
+ "version": "1.2.06",
4
4
  "main": "index.js",
5
5
  "dependencies": {
6
6
  "axios": "^1.3.4",