Skip to content
Open
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ pmd-results.sarif

# Coverage files
coverage
*.zip

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

undo

16 changes: 15 additions & 1 deletion websites/N/Nintendo Music/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"description": {
"de": "Mit Nintendo Music kannst du überall eine Vielzahl von Nintendo-Melodien hören.",
"en": "With Nintendo Music, you can listen to a variety of Nintendo tunes anywhere.",
"es": "Con Nintendo Music, puedes escuchar una gran variedad de melodías de Nintendo en cualquier lugar.",
"es": "Con Nintendo Music, puedes escuchar una gran variedad di melodías de Nintendo en cualquier lugar.",
"it": "Con Nintendo Music, puoi ascoltare una varietà di brani Nintendo ovunque.",
"nl": "Met Nintendo Music kun je overal naar een verscheidenheid aan Nintendo-melodieën luisteren.",
"ru": "С Nintendo Music ты можешь слушать разнообразные мелодии Nintendo где угодно."
Expand Down Expand Up @@ -39,6 +39,20 @@
"icon": "fas fa-image",
"value": true,
"description": "Show the song artwork as the large image."
},
{
"id": "displayFormat",
"title": "Display Format",
"icon": "fas fa-paragraph",
"value": 0,
"values": ["Song Name", "Soundtrack Name", "Nintendo Music"]
},
{
"id": "marioKartTrackOrigin",
"title": "Display Racetrack Console Origin",
"icon": "fas fa-font",
"value": false,
"description": "For Mario Kart soundtracks, show which console a racetrack originates from if they don't already."
}
]
}
70 changes: 66 additions & 4 deletions websites/N/Nintendo Music/presence.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,63 @@
import { ActivityType } from 'premid'
import { ActivityType, StatusDisplayType } from 'premid'

const presence = new Presence({
clientId: '1511505666664038460',
})
const NintendoMusicLogo = 'https://cdn.rcd.gg/PreMiD/websites/N/Nintendo%20Music/assets/logo.png'

const TrackOriginList: Record<string, Record<string, string>> = {
'Mario Kart World': {
'Desert Hills': 'DS Desert Hills',
'Shy Guy Bazaar': '3DS Shy Guy Bazaar',
'Wario Stadium': 'N64 Wario Stadium',
'Airship Fortress': 'DS Airship Fortress',
'DK Pass': 'DS DK Pass',
'Sky-High Sundae': 'SW Sky-High Sundae',
"Wario's Galleon": "3DS Wario's Galleon",

Check failure

Code scanning / ESLint

Enforce the consistent use of either backticks, double, or single quotes Error

Strings must use singlequote.

Check failure

Code scanning / ESLint

Enforce the consistent use of either backticks, double, or single quotes Error

Strings must use singlequote.
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
"Wario's Shipyard": "3DS Wario's Shipyard",

Check failure

Code scanning / ESLint

Enforce the consistent use of either backticks, double, or single quotes Error

Strings must use singlequote.

Check failure

Code scanning / ESLint

Enforce the consistent use of either backticks, double, or single quotes Error

Strings must use singlequote.
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
'Koopa Troopa Beach': 'SNES Koopa Troopa Beach',
'Peach Beach': 'GCN Peach Beach',
'Dino Dino Jungle': 'GCN Dino Dino Jungle',
'Moo Moo Meadows': 'Wii Moo Moo Meadows',
'Choco Mountain': 'N64 Choco Mountain',
'Toad\'s Factory': 'Wii Toad\'s Factory',
'Mario Circuit': 'SNES Mario Circuit',
'Desert Hills (Intro)': 'DS Desert Hills (Intro)',
'Shy Guy Bazaar (Intro)': '3DS Shy Guy Bazaar (Intro)',
'Wario Stadium (Intro)': 'N64 Wario Stadium (Intro)',
'Airship Fortress (Intro)': 'DS Airship Fortress (Intro)',
'DK Pass (Intro)': 'DS DK Pass (Intro)',
'Sky-High Sundae (Intro)': 'SW Sky-High Sundae (Intro)',
"Wario's Galleon (Intro)": "3DS Wario's Galleon (Intro)",

Check failure

Code scanning / ESLint

Enforce the consistent use of either backticks, double, or single quotes Error

Strings must use singlequote.

Check failure

Code scanning / ESLint

Enforce the consistent use of either backticks, double, or single quotes Error

Strings must use singlequote.
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
"Wario's Shipyard (Intro)": "3DS Wario's Shipyard (Intro)",

Check failure

Code scanning / ESLint

Enforce the consistent use of either backticks, double, or single quotes Error

Strings must use singlequote.

Check failure

Code scanning / ESLint

Enforce the consistent use of either backticks, double, or single quotes Error

Strings must use singlequote.
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
'Koopa Troopa Beach (Intro)': 'SNES Koopa Troopa Beach (Intro)',
'Peach Beach (Intro)': 'GCN Peach Beach (Intro)',
'Dino Dino Jungle (Intro)': 'GCN Dino Dino Jungle (Intro)',
'Moo Moo Meadows (Intro)': 'Wii Moo Moo Meadows (Intro)',
'Choco Mountain (Intro)': 'N64 Choco Mountain (Intro)',
'Toad\'s Factory (Intro)': 'Wii Toad\'s Factory (Intro)',
'Mario Circuit (Intro)': 'SNES Mario Circuit (Intro)',
},
}

presence.on('UpdateData', async () => {
const { pathname } = document.location
const title = document.title
const audio = document.querySelector('audio')
const mediaSession = navigator.mediaSession
const isPlaying = mediaSession.playbackState === 'playing'
const currentTime = audio?.currentTime ?? 0
const duration = audio?.duration || 0 // NOTE: audio.duration is NaN before loadedmetadata fires
const duration = audio?.duration || 0
const now = Math.floor(Date.now() / 1000)

const albumArt = document.querySelector<HTMLImageElement>('#main-column img')?.src ?? NintendoMusicLogo

const [showTimestamps, showSongArt] = await Promise.all([
const [showTimestamps, showSongArt, displayFormat, marioKartTrackOrigin] = await Promise.all([
presence.getSetting<boolean>('showTimestamps'),
presence.getSetting<boolean>('showSongArt'),
presence.getSetting<number>('displayFormat'),
presence.getSetting<boolean>('marioKartTrackOrigin')
])

Check failure

Code scanning / ESLint

Require or disallow trailing commas Error

Missing trailing comma.

const presenceData: PresenceData = {
largeImageKey: NintendoMusicLogo,
Expand Down Expand Up @@ -59,7 +96,7 @@
}
}
else if (pathname.includes('/user-playlist')) {
const parts = title.replace(' - Nintendo Music', '').trim().split(/[・·]/)
const parts = title.replace(' - Nintendo Music', '').trim().split(/[/[・·]/)
const songName = parts[0]?.trim() ?? 'Unknown'

presenceData.details = songName
Expand Down Expand Up @@ -99,6 +136,31 @@
delete presenceData.endTimestamp
}

if (marioKartTrackOrigin) {

Check failure

Code scanning / ESLint

Disallow trailing whitespace at the end of lines Error

Trailing spaces not allowed.
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
const soundtrackName = presenceData.state;

Check failure

Code scanning / ESLint

Require or disallow semicolons instead of ASI Error

Extra semicolon.
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
const songName = presenceData.details;

Check failure

Code scanning / ESLint

Require or disallow semicolons instead of ASI Error

Extra semicolon.
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
if (typeof soundtrackName === 'string' && typeof songName === 'string') {
const gameKey = soundtrackName as keyof typeof TrackOriginList;

Check failure

Code scanning / ESLint

Require or disallow semicolons instead of ASI Error

Extra semicolon.
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
const gameTrack = TrackOriginList[gameKey];

Check failure

Code scanning / ESLint

Require or disallow semicolons instead of ASI Error

Extra semicolon.
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
if (gameTrack && (songName in gameTrack)) {
const mappedTrackValue = (gameTrack as Record<string, string>)[songName]
presenceData.details = mappedTrackValue;

Check failure

Code scanning / ESLint

Require or disallow semicolons instead of ASI Error

Extra semicolon.
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
}
}

Check failure

Code scanning / ESLint

Disallow trailing whitespace at the end of lines Error

Trailing spaces not allowed.
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
}

switch(displayFormat) {

Check failure

Code scanning / ESLint

Enforce consistent spacing before and after keywords Error

Expected space(s) after "switch".
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
case 0:
presenceData.statusDisplayType = StatusDisplayType.Details
break;

Check failure

Code scanning / ESLint

Require or disallow semicolons instead of ASI Error

Extra semicolon.
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
case 1:
presenceData.statusDisplayType = StatusDisplayType.State;

Check failure

Code scanning / ESLint

Require or disallow semicolons instead of ASI Error

Extra semicolon.
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
break;

Check failure

Code scanning / ESLint

Require or disallow semicolons instead of ASI Error

Extra semicolon.
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
case 2:
presenceData.statusDisplayType = StatusDisplayType.Name
break;

Check failure

Code scanning / ESLint

Require or disallow semicolons instead of ASI Error

Extra semicolon.
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
}

if (presenceData.details) {
presence.setActivity(presenceData)
}
Expand Down
Loading