Skip to content

small-user-avatars improvements - #10085

Draft
fregante wants to merge 1 commit into
mainfrom
meh
Draft

fregante wants to merge 1 commit into
mainfrom
meh

Conversation

@fregante

Copy link
Copy Markdown
Member

Comment thread source/manifest.json
"homepage_url": "https://github.com/refined-github/refined-github",
"manifest_version": 3,
"minimum_chrome_version": "123",
"minimum_chrome_version": "125",

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Due to repeated regex group names


export default function getUserAvatar(username: string, size: number): string | void {
const cleanName = username.replace('[bot]', '');
const cleanName = username.replace('[bot]', '').replace('app/', '');

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

// Prefer reading username from URL if present.
// - [data-hovercard-url]: everywhere but the React PR lists (global and repo)
// - [aria-label="Filter by author github-user-here"]: in React PR lists (global and repo)
const attribute = element.getAttribute('data-hovercard-url') ?? element.getAttribute('aria-label');

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'd rather read the value from attributes because they're generally parseable with fewer surprises.

One exception here is the issue list https://github.com/eslint/eslint/issues?q=author%3Aapp%2Fdependabot, which doesn't include any attributes except href. So maybe I should parse author:app/dependabot from there

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

On more scenario that this might be fixing is where GitHub has started showing full names in the links, like on eslint's repo. I might just want to extract the username from textContent since that might have fewer variations and since it always exists.

// GitHub appends `[bot]` to bots in PR lists.
assertUsername(username?.replace(/\[bot\]$/, ''));

return username;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Perhaps this should standardize one of app/ vs [bot]

import regexJoin from 'regex-join';

import features from '../feature-manager.js';
import getUserAvatarURL from '../github-helpers/get-user-avatar.js';

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

getUserAvatarURL should probably be modified to return | undefined for unknown bots. It seems that it fails otherwise.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant