@@ -14,7 +14,8 @@ const presence = new Presence({
1414 clientId : '1444444337445408869' ,
1515} )
1616
17- const browsingTimestamp = Math . floor ( Date . now ( ) / 1000 )
17+ let startTimestamp = Math . floor ( Date . now ( ) / 1000 )
18+ let lastPath = ''
1819
1920function formatItemName ( str : string ) : string {
2021 if ( ! str )
@@ -36,12 +37,19 @@ function findImageByLink(keyword: string): string | undefined {
3637}
3738
3839presence . on ( 'UpdateData' , async ( ) => {
40+ const { pathname } = document . location
41+
42+ if ( pathname !== lastPath ) {
43+ startTimestamp = Math . floor ( Date . now ( ) / 1000 )
44+ lastPath = pathname
45+ }
46+
3947 const presenceData : PresenceData = {
4048 largeImageKey : 'https://cdn.rcd.gg/PreMiD/websites/W/Warframe%20Market/assets/logo.png' ,
41- startTimestamp : browsingTimestamp ,
49+ startTimestamp,
4250 }
4351
44- const { pathname } = document . location
52+ const showButtons = await presence . getSetting ( 'showButtons' )
4553
4654 if ( / ^ \/ i t e m s \/ \w + / . test ( pathname ) ) {
4755 const rawName = pathname . split ( '/' ) [ 2 ] || ''
@@ -55,21 +63,27 @@ presence.on('UpdateData', async () => {
5563
5664 presenceData . details = 'Looking at Item'
5765 presenceData . state = itemName
58- presenceData . buttons = [ {
59- label : 'View Market Prices' ,
60- url : document . location . href ,
61- } ]
66+
67+ if ( showButtons ) {
68+ presenceData . buttons = [ {
69+ label : 'View Market Prices' ,
70+ url : document . location . href ,
71+ } ]
72+ }
6273 }
6374 }
6475 else if ( pathname . startsWith ( '/profile/' ) ) {
6576 const username = pathname . split ( '/' ) [ 2 ] || 'User'
6677
6778 presenceData . details = 'Viewing User'
6879 presenceData . state = username
69- presenceData . buttons = [ {
70- label : 'View Profile' ,
71- url : document . location . href ,
72- } ]
80+
81+ if ( showButtons ) {
82+ presenceData . buttons = [ {
83+ label : 'View Profile' ,
84+ url : document . location . href ,
85+ } ]
86+ }
7387 }
7488 else if ( pathname . startsWith ( '/auctions' ) ) {
7589 presenceData . details = 'Browsing Auctions'
0 commit comments