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
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ Thanks for contributing! 🦋🙌
- [](# "linkify-notification-repository-header") [Linkifies the header of each notification group (when grouped by repository).](https://user-images.githubusercontent.com/1402241/80849887-81531c00-8c19-11ea-8777-7294ce318630.png)
- [](# "prevent-pr-commit-link-loss") [Suggests fixing your PR Commit links before commenting. GitHub has a bug that causes these link to appear as plain commit links, without association to the PR.](https://user-images.githubusercontent.com/1402241/82131169-93fd5180-97d2-11ea-9695-97051c55091f.gif)
- [](# "align-repository-header") [Aligns the repository header to the repository content on wide screens.](https://user-images.githubusercontent.com/1402241/86574587-587f3800-bf76-11ea-9961-5c25cdb6e357.gif)
- [](# "linkify-user-edit-history-popup") [Linkifies the username in the edit history popup.](https://user-images.githubusercontent.com/1402241/88917988-9ebb7480-d260-11ea-8690-0a3440f1ebbc.png)

<!-- Refer to style guide above. Keep this message between sections. -->

Expand Down
32 changes: 32 additions & 0 deletions source/features/linkify-user-edit-history-popup.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React from 'dom-chef';
import {observe} from 'selector-observer';
import * as pageDetect from 'github-url-detection';

import features from '.';
import {wrap} from '../helpers/dom-utils';

function init(): void {
observe('details-dialog .Box-header .mr-3 > img:not([alt*="[bot]"])', {
add(avatar) {
const userName = (avatar as HTMLImageElement).alt.slice(1);
Comment on lines +10 to +11
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
add(avatar) {
const userName = (avatar as HTMLImageElement).alt.slice(1);
constructor: HTMLImageElement,
add(avatar) {
const userName = avatar.alt.slice(1);

Copy link
Member Author

Choose a reason for hiding this comment

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

I do it later today

Copy link
Member

Choose a reason for hiding this comment

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

Or as part of a lint PR :D

// Linkify name first
wrap(avatar.nextElementSibling!, <a className="link-gray-dark" href={`/${userName}`}/>);

// Then linkify avatar
wrap(avatar, <a href={`/${userName}`}/>);
}
});
}

void features.add({
id: __filebasename,
description: 'Linkifies the username in the edit history popup.',
screenshot: 'https://user-images.githubusercontent.com/1402241/88917988-9ebb7480-d260-11ea-8690-0a3440f1ebbc.png'
}, {
init,
include: [
pageDetect.isIssue,
pageDetect.isPRConversation
],
repeatOnAjax: false
Copy link
Member

@fregante fregante Jul 29, 2020

Choose a reason for hiding this comment

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

I realized that this can be improved (separately). The logic shouldn't be "repeat on ajax", but just "don't run more than once"

Suggested change
repeatOnAjax: false
once: true

This would solve the issues we had elsewhere because repeatOnAjax: false also prevents the include filters to run

});
1 change: 1 addition & 0 deletions source/refined-github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ import './features/pr-jump-to-first-non-viewed-file';
import './features/keyboard-navigation';
import './features/vertical-front-matter';
import './features/use-first-commit-message-for-new-prs';
import './features/linkify-user-edit-history-popup';
import './features/cleanup-repo-filelist-actions';

// Add global for easier debugging
Expand Down