-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
75 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
async function fetchBasicInformation(userCustomId:string, sessionId:string): Promise<null> | ||
{ | ||
if (!userCustomId || !sessionId) | ||
return null; | ||
|
||
let response:Response; | ||
|
||
const headers = new Headers(); | ||
|
||
headers.set("Cookie", `sessionId=${sessionId};`); | ||
|
||
try | ||
{ | ||
response = await fetch(`https://steamcommunity.com/id/${userCustomId}/inventory`, {headers}); | ||
} | ||
catch (e) | ||
{ | ||
return null; | ||
}; | ||
|
||
const parser = new DOMParser(); | ||
const html = parser.parseFromString(await response.text(), "text/html"); | ||
|
||
const header = html.querySelector("#global_header"); | ||
const generalScript = header.nextElementSibling; | ||
const economyScriptContainer = html.querySelector("#responsive_page_template_content"); | ||
const economyScript = economyScriptContainer.querySelector("script"); | ||
|
||
return null; | ||
}; | ||
|
||
export default fetchBasicInformation; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
async function fetchCustomId(userId:string): Promise<string> | ||
{ | ||
const fetchUrl = `https://steamcommunity.com/profiles/${userId}`; | ||
|
||
let response:Response; | ||
|
||
try | ||
{ | ||
response = await fetch(fetchUrl); | ||
} | ||
catch (e) | ||
{ | ||
return null; | ||
}; | ||
|
||
const profileUrl = response.url; | ||
const splittedUrl = profileUrl.split("/").filter((part) => part.length > 0); | ||
|
||
return splittedUrl[splittedUrl.length - 1]; | ||
}; | ||
|
||
export default fetchCustomId; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters