Skip to content

Conversation

@noxygalaxy
Copy link

<3

largeImageText: songInfo.album
? truncateString(songInfo.album, 128)
: undefined,
smallImageKey: config.showYouTubeUser ? this.getYouTubeUserAvatar() : undefined,
Copy link
Contributor

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()⏎·······

Suggested change
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,
Copy link
Contributor

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()⏎·······

Suggested change
smallImageText: config.showYouTubeUser ? this.getYouTubeUserName() : undefined,
smallImageText: config.showYouTubeUser
? this.getYouTubeUserName()
: undefined,
Comment on lines +419 to +420

/**
Copy link
Contributor

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

Suggested change
/**
/**
Comment on lines +426 to +478
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;
}
})();
`);
Copy link
Contributor

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) {
Copy link
Contributor

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}`);
Copy link
Contributor

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}`);
Copy link
Contributor

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');
Copy link
Contributor

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',⏎········

Suggested change
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 = [];
}
}
}
Copy link
Contributor

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

Suggested change
}
}
statusDisplayType: (typeof StatusDisplayType)[keyof typeof StatusDisplayType];
/**
* Show YouTube Music user avatar and username in Discord Rich Presence
*
Copy link
Contributor

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 ·

Suggested change
*
*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant