Skip to content
This repository has been archived by the owner on Dec 24, 2022. It is now read-only.

Commit

Permalink
Fix playtime check in profile
Browse files Browse the repository at this point in the history
  • Loading branch information
CJMAXiK committed Apr 29, 2021
1 parent 2fc7005 commit 4dc486f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
10 changes: 7 additions & 3 deletions source/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const delay = (key) => new Promise(resolve => setTimeout(resolve, key * 150 + Ma
const queryPlayer = async (request) => {
const playerInfo = await readFromCache(request.steamId, async function () {
await delay(request.key)
const response = await fetch(`https://api.truckersmp.com/v2/player/${request.steamId}?ref=truckersmp-steam-helper`)
const response = await fetch(`https://api.truckersmp.com/v2/player/${request.steamId}?ref=truckersmp-steam-helper&v=${cacheBusting()}`)
return await response.json()
})

Expand All @@ -55,13 +55,17 @@ const queryOptions = async () => {
return await optionsStorage.getAll()
}

const cacheBusting = () => {
return Math.floor(Math.random() * 69420)
}

/**
* Check user games
* @param {Object} request Data object
* @param {String} request.steamId Steam ID
*/
const queryGames = async (request) => {
const response = await fetch(`https://steamcommunity.com/profiles/${request.steamId}/games/?xml=1`)
const response = await fetch(`https://steamcommunity.com/profiles/${request.steamId}/games/?xml=1&v=${cacheBusting()}`)
const data = await response.text()

const parser = new DOMParser()
Expand Down Expand Up @@ -93,7 +97,7 @@ const queryGames = async (request) => {

case '270880':
games.ats = 0
return
break
}

// Check the game time
Expand Down
10 changes: 5 additions & 5 deletions source/templates/noProfile.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@
<div class="label">Playtime</div>
<div class="value">
{{#if count}}
{{#if all}}
Public
{{#ifEquals all -1}}
Private
{{else}}
Private?
{{/if}}
Public
{{/ifEquals}}
{{else}}
Private
Private?
{{/if}}
</div>
</div>
Expand Down

0 comments on commit 4dc486f

Please sign in to comment.