Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion websites/W/Warframe Market/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,20 @@
},
"url": "warframe.market",
"regExp": "^https?:[/][/](www[.])?warframe[.]market[/]",
"version": "1.0.1",
"version": "1.0.2",
"logo": "https://cdn.rcd.gg/PreMiD/websites/W/Warframe%20Market/assets/logo.png",
"thumbnail": "https://cdn.rcd.gg/PreMiD/websites/W/Warframe%20Market/assets/thumbnail.png",
"color": "#000000",
"category": "games",
"tags": [
"warframe"
],
"settings": [
{
"id": "showButtons",
"title": "Show Buttons",
"icon": "fas fa-external-link-alt",
"value": true
}
]
}
36 changes: 25 additions & 11 deletions websites/W/Warframe Market/presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ const presence = new Presence({
clientId: '1444444337445408869',
})

const browsingTimestamp = Math.floor(Date.now() / 1000)
let startTimestamp = Math.floor(Date.now() / 1000)
let lastPath = ''

function formatItemName(str: string): string {
if (!str)
Expand All @@ -36,12 +37,19 @@ function findImageByLink(keyword: string): string | undefined {
}

presence.on('UpdateData', async () => {
const { pathname } = document.location

if (pathname !== lastPath) {
startTimestamp = Math.floor(Date.now() / 1000)
lastPath = pathname
}

const presenceData: PresenceData = {
largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/W/Warframe%20Market/assets/logo.png',
startTimestamp: browsingTimestamp,
startTimestamp,
}

const { pathname } = document.location
const showButtons = await presence.getSetting('showButtons')

if (/^\/items\/\w+/.test(pathname)) {
const rawName = pathname.split('/')[2] || ''
Expand All @@ -55,21 +63,27 @@ presence.on('UpdateData', async () => {

presenceData.details = 'Looking at Item'
presenceData.state = itemName
presenceData.buttons = [{
label: 'View Market Prices',
url: document.location.href,
}]

if (showButtons) {
presenceData.buttons = [{
label: 'View Market Prices',
url: document.location.href,
}]
}
}
}
else if (pathname.startsWith('/profile/')) {
const username = pathname.split('/')[2] || 'User'

presenceData.details = 'Viewing User'
presenceData.state = username
presenceData.buttons = [{
label: 'View Profile',
url: document.location.href,
}]

if (showButtons) {
presenceData.buttons = [{
label: 'View Profile',
url: document.location.href,
}]
}
}
else if (pathname.startsWith('/auctions')) {
presenceData.details = 'Browsing Auctions'
Expand Down
Loading