Skip to content

Commit d96c1da

Browse files
feat(Warframe Market): add settings and improve timestamp (#10312)
* feat(warframe-market): add settings * feat(warframe-market): reset timer on page change * fix(Warframe Market): add correct version number
1 parent d6d018d commit d96c1da

File tree

2 files changed

+34
-12
lines changed

2 files changed

+34
-12
lines changed

websites/W/Warframe Market/metadata.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,20 @@
1111
},
1212
"url": "warframe.market",
1313
"regExp": "^https?:[/][/](www[.])?warframe[.]market[/]",
14-
"version": "1.0.1",
14+
"version": "1.0.2",
1515
"logo": "https://cdn.rcd.gg/PreMiD/websites/W/Warframe%20Market/assets/logo.png",
1616
"thumbnail": "https://cdn.rcd.gg/PreMiD/websites/W/Warframe%20Market/assets/thumbnail.png",
1717
"color": "#000000",
1818
"category": "games",
1919
"tags": [
2020
"warframe"
21+
],
22+
"settings": [
23+
{
24+
"id": "showButtons",
25+
"title": "Show Buttons",
26+
"icon": "fas fa-external-link-alt",
27+
"value": true
28+
}
2129
]
2230
}

websites/W/Warframe Market/presence.ts

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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

1920
function formatItemName(str: string): string {
2021
if (!str)
@@ -36,12 +37,19 @@ function findImageByLink(keyword: string): string | undefined {
3637
}
3738

3839
presence.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 (/^\/items\/\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

Comments
 (0)