-
Notifications
You must be signed in to change notification settings - Fork 1.7k
add: show YTM user pfp / name in Discord RPC #4103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
| largeImageText: songInfo.album | ||
| ? truncateString(songInfo.album, 128) | ||
| : undefined, | ||
| smallImageKey: config.showYouTubeUser ? this.getYouTubeUserAvatar() : undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [eslint] <prettier/prettier> reported by reviewdog 🐶
Replace ·?·this.getYouTubeUserAvatar() with ⏎········?·this.getYouTubeUserAvatar()⏎·······
| smallImageKey: config.showYouTubeUser ? this.getYouTubeUserAvatar() : undefined, | |
| smallImageKey: config.showYouTubeUser | |
| ? this.getYouTubeUserAvatar() | |
| : undefined, |
| ? truncateString(songInfo.album, 128) | ||
| : undefined, | ||
| smallImageKey: config.showYouTubeUser ? this.getYouTubeUserAvatar() : undefined, | ||
| smallImageText: config.showYouTubeUser ? this.getYouTubeUserName() : undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [eslint] <prettier/prettier> reported by reviewdog 🐶
Replace ·?·this.getYouTubeUserName() with ⏎········?·this.getYouTubeUserName()⏎·······
| smallImageText: config.showYouTubeUser ? this.getYouTubeUserName() : undefined, | |
| smallImageText: config.showYouTubeUser | |
| ? this.getYouTubeUserName() | |
| : undefined, |
|
|
||
| /** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [eslint] <prettier/prettier> reported by reviewdog 🐶
Delete ⏎
| /** | |
| /** |
| const result = await this.mainWindow.webContents.executeJavaScript(` | ||
| (async function() { | ||
| try { | ||
| // Find avatar first - this is always visible | ||
| const accountButton = document.querySelector('ytmusic-settings-button img#img') | ||
| || document.querySelector('ytmusic-settings-button yt-img-shadow img') | ||
| || document.querySelector('ytmusic-settings-button img'); | ||
| let avatar = null; | ||
| if (accountButton) { | ||
| avatar = accountButton.src || accountButton.getAttribute('src'); | ||
| } | ||
| // Now get the username by clicking the settings button | ||
| const settingsButton = document.querySelector('ytmusic-settings-button button') | ||
| || document.querySelector('ytmusic-settings-button tp-yt-paper-icon-button'); | ||
| let name = 'Pear Desktop User'; | ||
| if (settingsButton) { | ||
| // Click to open the menu | ||
| settingsButton.click(); | ||
| // Wait for the menu to appear (check multiple times) | ||
| for (let i = 0; i < 20; i++) { | ||
| await new Promise(resolve => setTimeout(resolve, 50)); | ||
| const accountNameElement = document.querySelector('ytd-active-account-header-renderer #account-name') | ||
| || document.querySelector('yt-formatted-string#account-name'); | ||
| if (accountNameElement) { | ||
| name = accountNameElement.textContent?.trim() | ||
| || accountNameElement.getAttribute('title') | ||
| || name; | ||
| break; | ||
| } | ||
| } | ||
| // Close the menu by pressing Escape | ||
| document.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', keyCode: 27 })); | ||
| } | ||
| if (avatar) { | ||
| return { avatar, name }; | ||
| } | ||
| return null; | ||
| } catch (e) { | ||
| console.error('Failed to fetch YouTube user info:', e); | ||
| return null; | ||
| } | ||
| })(); | ||
| `); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [eslint] <@typescript-eslint/no-unsafe-assignment> reported by reviewdog 🐶
Unsafe assignment of an any value.
| })(); | ||
| `); | ||
|
|
||
| if (result && result.avatar) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [eslint] <@typescript-eslint/no-unsafe-member-access> reported by reviewdog 🐶
Unsafe member access .avatar on an any value.
| name: result.name, | ||
| avatar: result.avatar, | ||
| }; | ||
| console.log(LoggerPrefix, `Fetched YouTube user: ${result.name}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [eslint] <@typescript-eslint/no-unsafe-member-access> reported by reviewdog 🐶
Unsafe member access .name on an any value.
| avatar: result.avatar, | ||
| }; | ||
| console.log(LoggerPrefix, `Fetched YouTube user: ${result.name}`); | ||
| console.log(LoggerPrefix, `Fetched Avatar URL: ${result.avatar}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [eslint] <@typescript-eslint/no-unsafe-member-access> reported by reviewdog 🐶
Unsafe member access .avatar on an any value.
| console.log(LoggerPrefix, `Fetched YouTube user: ${result.name}`); | ||
| console.log(LoggerPrefix, `Fetched Avatar URL: ${result.avatar}`); | ||
| } else { | ||
| console.log(LoggerPrefix, 'Could not fetch YouTube user info - retrying in 5 seconds'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [eslint] <prettier/prettier> reported by reviewdog 🐶
Replace LoggerPrefix,·'Could·not·fetch·YouTube·user·info·-·retrying·in·5·seconds' with ⏎··········LoggerPrefix,⏎··········'Could·not·fetch·YouTube·user·info·-·retrying·in·5·seconds',⏎········
| console.log(LoggerPrefix, 'Could not fetch YouTube user info - retrying in 5 seconds'); | |
| console.log( | |
| LoggerPrefix, | |
| 'Could not fetch YouTube user info - retrying in 5 seconds', | |
| ); |
| this.refreshCallbacks = []; | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [eslint] <prettier/prettier> reported by reviewdog 🐶
Insert ⏎
| } | |
| } | |
| statusDisplayType: (typeof StatusDisplayType)[keyof typeof StatusDisplayType]; | ||
| /** | ||
| * Show YouTube Music user avatar and username in Discord Rich Presence | ||
| * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [eslint] <prettier/prettier> reported by reviewdog 🐶
Delete ·
| * | |
| * |
<3